Skip to content

Commit 2db8068

Browse files
committed
Auto-generated commit
1 parent 4de2e5f commit 2db8068

File tree

14 files changed

+731
-1
lines changed

14 files changed

+731
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-07-16)
7+
## Unreleased (2025-07-26)
88

99
<section class="features">
1010

1111
### Features
1212

13+
- [`44d590b`](https://github.com/stdlib-js/stdlib/commit/44d590b9dd5f64e263fc3687ba12a52c14bccb8d) - add `zip2object` to namespace
14+
- [`455c0d4`](https://github.com/stdlib-js/stdlib/commit/455c0d44ca137051ceb8a331ef66890ee74bd45c) - add `array/base/zip2object`
1315
- [`0b89b56`](https://github.com/stdlib-js/stdlib/commit/0b89b56db0aa040a643ef859ac71795462e947d5) - add `hasAlmostEqualValues` to namespace
1416
- [`fee6898`](https://github.com/stdlib-js/stdlib/commit/fee68983980c006c27c7f1f5d1f3f11b20602974) - add `array/base/assert/has-almost-equal-values`
1517
- [`7f0421e`](https://github.com/stdlib-js/stdlib/commit/7f0421e54502fdd9e92758d9c9123216372287fd) - add inital implementation of `array/struct-factory`
@@ -219,6 +221,8 @@ A total of 32 issues were closed in this release:
219221

220222
<details>
221223

224+
- [`44d590b`](https://github.com/stdlib-js/stdlib/commit/44d590b9dd5f64e263fc3687ba12a52c14bccb8d) - **feat:** add `zip2object` to namespace _(by Athan Reines)_
225+
- [`455c0d4`](https://github.com/stdlib-js/stdlib/commit/455c0d44ca137051ceb8a331ef66890ee74bd45c) - **feat:** add `array/base/zip2object` _(by Athan Reines)_
222226
- [`5388bba`](https://github.com/stdlib-js/stdlib/commit/5388bba36044d2de93dacb0134c6e5539b02928c) - **chore:** minor clean-up _(by Philipp Burckhardt)_
223227
- [`0b89b56`](https://github.com/stdlib-js/stdlib/commit/0b89b56db0aa040a643ef859ac71795462e947d5) - **feat:** add `hasAlmostEqualValues` to namespace _(by Athan Reines)_
224228
- [`fee6898`](https://github.com/stdlib-js/stdlib/commit/fee68983980c006c27c7f1f5d1f3f11b20602974) - **feat:** add `array/base/assert/has-almost-equal-values` _(by Athan Reines)_

CONTRIBUTORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Anshu Kumar <[email protected]>
3030
Anudeep Sanapala <[email protected]>
3131
Arihant Pal <[email protected]>
3232
Aryan Bhirud <[email protected]>
33+
3334
Athan Reines <[email protected]>
3435
Atharva Patil <[email protected]>
3536
@@ -167,6 +168,7 @@ Sai Avinash <[email protected]>
167168
Sai Srikar Dumpeti <[email protected]>
168169
Sanchay Ketan Sinha <[email protected]>
169170
Sarthak Paandey <[email protected]>
171+
Satyajeet Chavan <[email protected]>
170172
Saurabh Singh <[email protected]>
171173
Seyyed Parsa Neshaei <[email protected]>
172174
Shabareesh Shetty <[email protected]>
@@ -176,6 +178,7 @@ Shivansh <[email protected]>
176178
Shraddheya Shendre <[email protected]>
177179
Shubh Mehta <[email protected]>
178180
Shubham Mishra <[email protected]>
181+
Siddhesh waje <[email protected]>
179182
Sivam Das <[email protected]>
180183
Snehil Shah <[email protected]>
181184
Soumajit Chatterjee <[email protected]>

base/lib/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,15 @@ setReadOnly( ns, 'zeros5d', require( './../../base/zeros5d' ) );
19531953
*/
19541954
setReadOnly( ns, 'zerosnd', require( './../../base/zerosnd' ) );
19551955

1956+
/**
1957+
* @name zip2object
1958+
* @memberof ns
1959+
* @readonly
1960+
* @type {Function}
1961+
* @see {@link module:@stdlib/array/base/zip2object}
1962+
*/
1963+
setReadOnly( ns, 'zip2object', require( './../../base/zip2object' ) );
1964+
19561965

19571966
// EXPORTS //
19581967

base/zip2object/README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# zip2object
22+
23+
> Create an object from a provided list of properties and a provided list of corresponding values.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var zip2object = require( '@stdlib/array/base/zip2object' );
31+
```
32+
33+
#### zip2object( properties, values )
34+
35+
Returns an object from a provided list of properties and a provided list of corresponding values.
36+
37+
```javascript
38+
var properties = [ 'a', 'b' ];
39+
var values = [ 1, 2 ];
40+
41+
var out = zip2object( properties, values );
42+
// returns { 'a': 1, 'b': 2 }
43+
```
44+
45+
The function supports the following parameters:
46+
47+
- **properties**: list of properties.
48+
- **values**: list of values.
49+
50+
</section>
51+
52+
<!-- /.usage -->
53+
54+
<section class="notes">
55+
56+
- The function assumes that both input arrays have the same length.
57+
58+
</section>
59+
60+
<!-- /.notes -->
61+
62+
<section class="examples">
63+
64+
## Examples
65+
66+
<!-- eslint no-undef: "error" -->
67+
68+
```javascript
69+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
70+
var zeroTo = require( '@stdlib/array/base/zero-to' );
71+
var zip2object = require( '@stdlib/array/base/zip2object' );
72+
73+
var x1 = zeroTo( 10 );
74+
var x2 = discreteUniform( x1.length, -100, 100 );
75+
76+
var out = zip2object( x1, x2 );
77+
// returns {...}
78+
```
79+
80+
</section>
81+
82+
<!-- /.examples -->
83+
84+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
85+
86+
<section class="related">
87+
88+
</section>
89+
90+
<!-- /.related -->
91+
92+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
93+
94+
<section class="links">
95+
96+
</section>
97+
98+
<!-- /.links -->
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var isPlainObject = require( '@stdlib/assert/is-plain-object' );
25+
var zeroTo = require( './../../../base/zero-to' );
26+
var pkg = require( './../package.json' ).name;
27+
var zip2object = require( './../lib' );
28+
29+
30+
// MAIN //
31+
32+
bench( pkg+':len=100', function benchmark( b ) {
33+
var x;
34+
var i;
35+
var v;
36+
37+
x = zeroTo( 10 );
38+
39+
b.tic();
40+
for ( i = 0; i < b.iterations; i++ ) {
41+
v = zip2object( x, x );
42+
if ( typeof v !== 'object' ) {
43+
b.fail( 'should return an object' );
44+
}
45+
}
46+
b.toc();
47+
if ( !isPlainObject( v ) ) {
48+
b.fail( 'should return an object' );
49+
}
50+
b.pass( 'benchmark finished' );
51+
b.end();
52+
});
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pow = require( '@stdlib/math/base/special/pow' );
25+
var zeroTo = require( './../../../base/zero-to' );
26+
var isPlainObject = require( '@stdlib/assert/is-plain-object' );
27+
var pkg = require( './../package.json' ).name;
28+
var zip2object = require( './../lib' );
29+
30+
31+
// FUNCTIONS //
32+
33+
/**
34+
* Creates a benchmark function.
35+
*
36+
* @private
37+
* @param {PositiveInteger} len - array length
38+
* @returns {Function} benchmark function
39+
*/
40+
function createBenchmark( len ) {
41+
var x = zeroTo( len );
42+
return benchmark;
43+
44+
/**
45+
* Benchmark function.
46+
*
47+
* @private
48+
* @param {Benchmark} b - benchmark instance
49+
*/
50+
function benchmark( b ) {
51+
var v;
52+
var i;
53+
54+
b.tic();
55+
for ( i = 0; i < b.iterations; i++ ) {
56+
v = zip2object( x, x );
57+
if ( typeof v !== 'object' ) {
58+
b.fail( 'should return an object' );
59+
}
60+
}
61+
b.toc();
62+
if ( !isPlainObject( v ) ) {
63+
b.fail( 'should return an object' );
64+
}
65+
b.pass( 'benchmark finished' );
66+
b.end();
67+
}
68+
}
69+
70+
71+
// MAIN //
72+
73+
/**
74+
* Main execution sequence.
75+
*
76+
* @private
77+
*/
78+
function main() {
79+
var len;
80+
var min;
81+
var max;
82+
var f;
83+
var i;
84+
85+
min = 1; // 10^min
86+
max = 6; // 10^max
87+
88+
for ( i = min; i <= max; i++ ) {
89+
len = pow( 10, i );
90+
f = createBenchmark( len );
91+
bench( pkg+':len='+len, f );
92+
}
93+
}
94+
95+
main();

base/zip2object/docs/repl.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
{{alias}}( properties, values )
3+
Creates an object from a provided list of properties and a provided list of
4+
corresponding values.
5+
6+
The function assumes that both input arrays are the same length.
7+
8+
Parameters
9+
----------
10+
properties: ArrayLikeObject
11+
List of properties.
12+
13+
values: ArrayLikeObject
14+
List of values.
15+
16+
Returns
17+
-------
18+
out: Object
19+
Result.
20+
21+
Examples
22+
--------
23+
> var x1 = [ 1, 2 ];
24+
> var x2 = [ 3, 4 ];
25+
> var out = {{alias}}( x1, x2 )
26+
{ '1': 3, '2': 4 }
27+
28+
See Also
29+
--------
30+

base/zip2object/docs/types/index.d.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 4.1
20+
21+
/// <reference types="@stdlib/types"/>
22+
23+
import { Collection, AccessorArrayLike } from '@stdlib/types/array';
24+
25+
/**
26+
* Property key.
27+
*/
28+
type PropertyKey = string | number | symbol;
29+
30+
/**
31+
* Creates an object from a provided list of properties and a provided list of corresponding values.
32+
*
33+
* ## Notes
34+
*
35+
* - The function assumes that both input arrays are the same length.
36+
*
37+
* @param properties - list of properties
38+
* @param values - list of values
39+
* @returns result
40+
*
41+
* @example
42+
* var properties = [ 1, 2 ];
43+
* var values = [ 3, 4 ];
44+
*
45+
* var out = zip2object( properties, values );
46+
* // returns { '1': 3, '2': 4 }
47+
*/
48+
declare function zip2object<T extends PropertyKey = PropertyKey, U = unknown>( properties: Collection<T> | AccessorArrayLike<T>, values: Collection<U> | AccessorArrayLike<U> ): Record<T, U>;
49+
50+
51+
// EXPORTS //
52+
53+
export = zip2object;

0 commit comments

Comments
 (0)