Skip to content

Commit 2ca88b8

Browse files
committed
Auto-generated commit
1 parent 2db8068 commit 2ca88b8

File tree

24 files changed

+1667
-1
lines changed

24 files changed

+1667
-1
lines changed

CHANGELOG.md

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

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

99
<section class="features">
1010

1111
### Features
1212

13+
- [`302966e`](https://github.com/stdlib-js/stdlib/commit/302966e9b30769c05537f07169c2bda2fbee83f1) - add `zip` to namespace
14+
- [`e669353`](https://github.com/stdlib-js/stdlib/commit/e669353fc68d57800199dcb773accd5ce9943cef) - add `array/base/zip`
15+
- [`1626ce4`](https://github.com/stdlib-js/stdlib/commit/1626ce436f5b49949f6f49c70f351d3d25149097) - add `zip2objects` to namespace
16+
- [`44a8a87`](https://github.com/stdlib-js/stdlib/commit/44a8a871353908788328432c303704843c4a5eb4) - add `array/base/zip2objects`
1317
- [`44d590b`](https://github.com/stdlib-js/stdlib/commit/44d590b9dd5f64e263fc3687ba12a52c14bccb8d) - add `zip2object` to namespace
1418
- [`455c0d4`](https://github.com/stdlib-js/stdlib/commit/455c0d44ca137051ceb8a331ef66890ee74bd45c) - add `array/base/zip2object`
1519
- [`0b89b56`](https://github.com/stdlib-js/stdlib/commit/0b89b56db0aa040a643ef859ac71795462e947d5) - add `hasAlmostEqualValues` to namespace
@@ -221,6 +225,11 @@ A total of 32 issues were closed in this release:
221225

222226
<details>
223227

228+
- [`302966e`](https://github.com/stdlib-js/stdlib/commit/302966e9b30769c05537f07169c2bda2fbee83f1) - **feat:** add `zip` to namespace _(by Athan Reines)_
229+
- [`e669353`](https://github.com/stdlib-js/stdlib/commit/e669353fc68d57800199dcb773accd5ce9943cef) - **feat:** add `array/base/zip` _(by Athan Reines)_
230+
- [`73b048a`](https://github.com/stdlib-js/stdlib/commit/73b048a2cef0d2e2ab0ea10887f45fe7365c71bb) - **bench:** fix assertions _(by Athan Reines)_
231+
- [`1626ce4`](https://github.com/stdlib-js/stdlib/commit/1626ce436f5b49949f6f49c70f351d3d25149097) - **feat:** add `zip2objects` to namespace _(by Athan Reines)_
232+
- [`44a8a87`](https://github.com/stdlib-js/stdlib/commit/44a8a871353908788328432c303704843c4a5eb4) - **feat:** add `array/base/zip2objects` _(by Athan Reines)_
224233
- [`44d590b`](https://github.com/stdlib-js/stdlib/commit/44d590b9dd5f64e263fc3687ba12a52c14bccb8d) - **feat:** add `zip2object` to namespace _(by Athan Reines)_
225234
- [`455c0d4`](https://github.com/stdlib-js/stdlib/commit/455c0d44ca137051ceb8a331ef66890ee74bd45c) - **feat:** add `array/base/zip2object` _(by Athan Reines)_
226235
- [`5388bba`](https://github.com/stdlib-js/stdlib/commit/5388bba36044d2de93dacb0134c6e5539b02928c) - **chore:** minor clean-up _(by Philipp Burckhardt)_

base/lib/index.js

Lines changed: 18 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 zip
1958+
* @memberof ns
1959+
* @readonly
1960+
* @type {Function}
1961+
* @see {@link module:@stdlib/array/base/zip}
1962+
*/
1963+
setReadOnly( ns, 'zip', require( './../../base/zip' ) );
1964+
19561965
/**
19571966
* @name zip2object
19581967
* @memberof ns
@@ -1962,6 +1971,15 @@ setReadOnly( ns, 'zerosnd', require( './../../base/zerosnd' ) );
19621971
*/
19631972
setReadOnly( ns, 'zip2object', require( './../../base/zip2object' ) );
19641973

1974+
/**
1975+
* @name zip2objects
1976+
* @memberof ns
1977+
* @readonly
1978+
* @type {Function}
1979+
* @see {@link module:@stdlib/array/base/zip2objects}
1980+
*/
1981+
setReadOnly( ns, 'zip2objects', require( './../../base/zip2objects' ) );
1982+
19651983

19661984
// EXPORTS //
19671985

base/zip/README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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+
# zip
22+
23+
> Zip one or more arrays.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var zip = require( '@stdlib/array/base/zip' );
31+
```
32+
33+
#### zip( arrays )
34+
35+
Zips one or more arrays.
36+
37+
```javascript
38+
var x = [ 1, 2 ];
39+
var y = [ 3, 4 ];
40+
41+
var out = zip( [ x, y ] );
42+
// returns [ [ 1, 3 ], [ 2, 4 ] ]
43+
```
44+
45+
The function supports the following parameters:
46+
47+
- **arrays**: list of arrays to zip.
48+
49+
</section>
50+
51+
<!-- /.usage -->
52+
53+
<section class="notes">
54+
55+
- The function assumes that the list of arrays to be zipped all have the same length.
56+
57+
</section>
58+
59+
<!-- /.notes -->
60+
61+
<section class="examples">
62+
63+
## Examples
64+
65+
<!-- eslint no-undef: "error" -->
66+
67+
```javascript
68+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
69+
var zeroTo = require( '@stdlib/array/base/zero-to' );
70+
var zip = require( '@stdlib/array/base/zip' );
71+
72+
var x = zeroTo( 10 );
73+
var y = discreteUniform( x.length, -100, 100 );
74+
75+
var out = zip( [ x, y ] );
76+
// returns [...]
77+
```
78+
79+
</section>
80+
81+
<!-- /.examples -->
82+
83+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
84+
85+
<section class="related">
86+
87+
</section>
88+
89+
<!-- /.related -->
90+
91+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
92+
93+
<section class="links">
94+
95+
</section>
96+
97+
<!-- /.links -->

base/zip/benchmark/benchmark.js

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 isArrayArray = require( '@stdlib/assert/is-array-array' );
25+
var zeroTo = require( './../../../base/zero-to' );
26+
var pkg = require( './../package.json' ).name;
27+
var zip = 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 = zip( [ x, x ] );
42+
if ( typeof v !== 'object' ) {
43+
b.fail( 'should return an array of arrays' );
44+
}
45+
}
46+
b.toc();
47+
if ( !isArrayArray( v ) ) {
48+
b.fail( 'should return an array of arrays' );
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 isArrayArray = require( '@stdlib/assert/is-array-array' );
27+
var pkg = require( './../package.json' ).name;
28+
var zip = 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 = zip( [ x, x ] );
57+
if ( typeof v !== 'object' ) {
58+
b.fail( 'should return an array of arrays' );
59+
}
60+
}
61+
b.toc();
62+
if ( !isArrayArray( v ) ) {
63+
b.fail( 'should return an array of arrays' );
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/zip/docs/repl.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
{{alias}}( arrays )
3+
Zips one or more arrays.
4+
5+
The function assumes that the list of arrays to be zipped all have the same
6+
length.
7+
8+
Parameters
9+
----------
10+
arrays: ArrayLikeObject<ArrayLikeObject>
11+
List of arrays to zip.
12+
13+
Returns
14+
-------
15+
out: Array<Array>
16+
Output array.
17+
18+
Examples
19+
--------
20+
> var x = [ 1, 2 ];
21+
> var y = [ 3, 4 ];
22+
> var out = {{alias}}( [ x, y ] )
23+
[ [ 1, 3 ], [ 2, 4 ] ]
24+
25+
See Also
26+
--------
27+

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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, ArrayLike } from '@stdlib/types/array';
24+
25+
/**
26+
* Zips one or more arrays.
27+
*
28+
* ## Notes
29+
*
30+
* - The function assumes that the list of arrays to be zipped all have the same length.
31+
*
32+
* @param arrays - list of arrays to be zipped
33+
* @returns output array
34+
*
35+
* @example
36+
* var x = [ 1, 2, 3 ];
37+
* var y = [ 'a', 'b', 'c' ];
38+
*
39+
* var z = zip( [ x, y ] );
40+
* // returns [ [ 1, 'a' ], [ 2, 'b' ], [ 3, 'c' ] ]
41+
*/
42+
declare function zip<T = unknown>( arrays: ArrayLike<Collection<T> | AccessorArrayLike<T>> ): Array<Array<T>>;
43+
44+
45+
// EXPORTS //
46+
47+
export = zip;

0 commit comments

Comments
 (0)