Skip to content

Commit 15a96d4

Browse files
committed
Auto-generated commit
1 parent b851dd7 commit 15a96d4

File tree

36 files changed

+1744
-29
lines changed

36 files changed

+1744
-29
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
### Features
1212

13+
- [`1535192`](https://github.com/stdlib-js/stdlib/commit/1535192162a5b372854dd62cb028c2c5e32d7c0a) - add `nested2views` to namespace
14+
- [`e484f42`](https://github.com/stdlib-js/stdlib/commit/e484f42a6bd37fcafb4309bcecad5c4270c132cc) - add `array/base/nested2views`
15+
- [`e83fc9a`](https://github.com/stdlib-js/stdlib/commit/e83fc9abdd3c0bbd6d7ba91794ced8774757aeae) - add `nested2objects` to namespace
16+
- [`0c087b7`](https://github.com/stdlib-js/stdlib/commit/0c087b783f86d415abe0a0698b54b6755f72cbaa) - add `array/base/nested2objects`
1317
- [`0482e74`](https://github.com/stdlib-js/stdlib/commit/0482e7449c3d3d59fd0f89f1352cb90e59127756) - add `entries2views` to namespace
1418
- [`7e5f17b`](https://github.com/stdlib-js/stdlib/commit/7e5f17bf1d04ec84b0c137454a467ebee1370cf0) - add `array/base/entries2views`
1519
- [`62be202`](https://github.com/stdlib-js/stdlib/commit/62be202d080ca6b785ae018c95570242cbbf5873) - add `entries2objects` to namespace
@@ -142,6 +146,8 @@
142146

143147
### Bug Fixes
144148

149+
- [`f53879d`](https://github.com/stdlib-js/stdlib/commit/f53879de98a2f80792d3d97c7748fd7425800aac) - ensure support for outer accessor arrays
150+
- [`5741019`](https://github.com/stdlib-js/stdlib/commit/57410198f53879784c97784af6bbe0b482b235ae) - ensure accessor support for provided fields
145151
- [`2a0ea7f`](https://github.com/stdlib-js/stdlib/commit/2a0ea7feb22806685fef9eac8a32d7012dab7adc) - use correct package names in package.json
146152
- [`d3426a4`](https://github.com/stdlib-js/stdlib/commit/d3426a41ee92d8024bf7fc03d200aa98fb62a6f0) - use correct dimensions for array
147153
- [`aa59ef8`](https://github.com/stdlib-js/stdlib/commit/aa59ef8461be08dc612cf4826bb020915d362239) - pass in correct number of arguments
@@ -231,6 +237,16 @@ A total of 32 issues were closed in this release:
231237

232238
<details>
233239

240+
- [`d25ee66`](https://github.com/stdlib-js/stdlib/commit/d25ee665c0ae01b053bb4aeae117db1a27a282fd) - **bench:** fix sample array _(by Athan Reines)_
241+
- [`4fd7c3c`](https://github.com/stdlib-js/stdlib/commit/4fd7c3c4193f809283db6672754b35bbe00fd79f) - **bench:** fix sample array _(by Athan Reines)_
242+
- [`1535192`](https://github.com/stdlib-js/stdlib/commit/1535192162a5b372854dd62cb028c2c5e32d7c0a) - **feat:** add `nested2views` to namespace _(by Athan Reines)_
243+
- [`e484f42`](https://github.com/stdlib-js/stdlib/commit/e484f42a6bd37fcafb4309bcecad5c4270c132cc) - **feat:** add `array/base/nested2views` _(by Athan Reines)_
244+
- [`f389a19`](https://github.com/stdlib-js/stdlib/commit/f389a19fcb158cc48a624577d2dea87391a0be13) - **refactor:** remove unnecessary variable _(by Athan Reines)_
245+
- [`e83fc9a`](https://github.com/stdlib-js/stdlib/commit/e83fc9abdd3c0bbd6d7ba91794ced8774757aeae) - **feat:** add `nested2objects` to namespace _(by Athan Reines)_
246+
- [`f53879d`](https://github.com/stdlib-js/stdlib/commit/f53879de98a2f80792d3d97c7748fd7425800aac) - **fix:** ensure support for outer accessor arrays _(by Athan Reines)_
247+
- [`0c087b7`](https://github.com/stdlib-js/stdlib/commit/0c087b783f86d415abe0a0698b54b6755f72cbaa) - **feat:** add `array/base/nested2objects` _(by Athan Reines)_
248+
- [`5741019`](https://github.com/stdlib-js/stdlib/commit/57410198f53879784c97784af6bbe0b482b235ae) - **fix:** ensure accessor support for provided fields _(by Athan Reines)_
249+
- [`7f0568c`](https://github.com/stdlib-js/stdlib/commit/7f0568c02fad49db0292ed2c15eed93e281b3d3f) - **bench:** fix descriptions _(by Athan Reines)_
234250
- [`0482e74`](https://github.com/stdlib-js/stdlib/commit/0482e7449c3d3d59fd0f89f1352cb90e59127756) - **feat:** add `entries2views` to namespace _(by Athan Reines)_
235251
- [`7e5f17b`](https://github.com/stdlib-js/stdlib/commit/7e5f17bf1d04ec84b0c137454a467ebee1370cf0) - **feat:** add `array/base/entries2views` _(by Athan Reines)_
236252
- [`62be202`](https://github.com/stdlib-js/stdlib/commit/62be202d080ca6b785ae018c95570242cbbf5873) - **feat:** add `entries2objects` to namespace _(by Athan Reines)_

base/entries2objects/benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var entries2objects = require( './../lib' );
2929

3030
// MAIN //
3131

32-
bench( pkg+':len=100', function benchmark( b ) {
32+
bench( pkg+':len=10', function benchmark( b ) {
3333
var labels;
3434
var x;
3535
var i;

base/entries2objects/lib/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ function entries2objects( arr, fields ) {
5656
if ( N < 1 ) {
5757
return [];
5858
}
59-
k = fields[ 0 ];
60-
v = fields[ 1 ];
59+
get = resolveGetter( fields );
60+
k = get( fields, 0 );
61+
v = get( fields, 1 );
6162

6263
get = resolveGetter( arr );
6364
out = [];

base/entries2objects/test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ tape( 'the function converts array entries to an array of objects (accessors)',
8383

8484
x = toAccessorArray( [ 1, 2 ] );
8585

86-
actual = entries2objects( x, fields );
86+
actual = entries2objects( x, toAccessorArray( fields ) );
8787
expected = [
8888
{
8989
'x': 0,

base/entries2views/benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var entries2views = require( './../lib' );
2929

3030
// MAIN //
3131

32-
bench( pkg+':len=100', function benchmark( b ) {
32+
bench( pkg+':len=10', function benchmark( b ) {
3333
var fields;
3434
var x;
3535
var i;

base/lib/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,24 @@ setReadOnly( ns, 'mskunary5d', require( './../../base/mskunary5d' ) );
13501350
*/
13511351
setReadOnly( ns, 'nCartesianProduct', require( './../../base/n-cartesian-product' ) );
13521352

1353+
/**
1354+
* @name nested2objects
1355+
* @memberof ns
1356+
* @readonly
1357+
* @type {Function}
1358+
* @see {@link module:@stdlib/array/base/nested2objects}
1359+
*/
1360+
setReadOnly( ns, 'nested2objects', require( './../../base/nested2objects' ) );
1361+
1362+
/**
1363+
* @name nested2views
1364+
* @memberof ns
1365+
* @readonly
1366+
* @type {Function}
1367+
* @see {@link module:@stdlib/array/base/nested2views}
1368+
*/
1369+
setReadOnly( ns, 'nested2views', require( './../../base/nested2views' ) );
1370+
13531371
/**
13541372
* @name none
13551373
* @memberof ns

base/nested2objects/README.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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+
# nested2objects
22+
23+
> Convert nested arrays to objects.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var nested2objects = require( '@stdlib/array/base/nested2objects' );
31+
```
32+
33+
#### nested2objects( arr, fields )
34+
35+
Converts each nested array to an object.
36+
37+
```javascript
38+
var x = [ [ 1, 2 ], [ 3, 4 ] ];
39+
40+
var fields = [ 'x', 'y' ];
41+
42+
var out = nested2objects( x, fields );
43+
// returns [ { 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 } ]
44+
```
45+
46+
The function supports the following parameters:
47+
48+
- **arr**: input array containing nested arrays.
49+
- **fields**: list of field names.
50+
51+
</section>
52+
53+
<!-- /.usage -->
54+
55+
<section class="notes">
56+
57+
- The function assumes that all nested arrays have the same length.
58+
- The number of provided array labels should equal the length of each nested array.
59+
60+
</section>
61+
62+
<!-- /.notes -->
63+
64+
<section class="examples">
65+
66+
## Examples
67+
68+
<!-- eslint no-undef: "error" -->
69+
70+
```javascript
71+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
72+
var filled2dBy = require( '@stdlib/array/base/filled2d-by' );
73+
var nested2objects = require( '@stdlib/array/base/nested2objects' );
74+
75+
var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) );
76+
var fields = [ 'x', 'y' ];
77+
78+
var out = nested2objects( x, fields );
79+
// returns [...]
80+
```
81+
82+
</section>
83+
84+
<!-- /.examples -->
85+
86+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
87+
88+
<section class="related">
89+
90+
</section>
91+
92+
<!-- /.related -->
93+
94+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
95+
96+
<section class="links">
97+
98+
</section>
99+
100+
<!-- /.links -->
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 isArray = require( '@stdlib/assert/is-array' );
25+
var filled2d = require( './../../../base/filled2d' );
26+
var pkg = require( './../package.json' ).name;
27+
var nested2objects = require( './../lib' );
28+
29+
30+
// MAIN //
31+
32+
bench( pkg+':size=100', function benchmark( b ) {
33+
var fields;
34+
var x;
35+
var i;
36+
var v;
37+
38+
fields = [ 'x', 'y' ];
39+
x = filled2d( 10, [ 50, 2 ] );
40+
41+
b.tic();
42+
for ( i = 0; i < b.iterations; i++ ) {
43+
v = nested2objects( x, fields );
44+
if ( typeof v !== 'object' ) {
45+
b.fail( 'should return an array' );
46+
}
47+
}
48+
b.toc();
49+
if ( !isArray( v ) ) {
50+
b.fail( 'should return an array' );
51+
}
52+
b.pass( 'benchmark finished' );
53+
b.end();
54+
});

base/nested2objects/docs/repl.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
{{alias}}( arr, fields )
3+
Converts each nested array to an object.
4+
5+
The function assumes that all nested arrays have the same length.
6+
7+
The number of provided array labels should equal the length of each nested
8+
array.
9+
10+
Parameters
11+
----------
12+
arr: ArrayLikeObject<ArrayLikeObject>
13+
Input array containing nested arrays.
14+
15+
fields: ArrayLikeObject
16+
List of field names.
17+
18+
Returns
19+
-------
20+
out: Array<Object>
21+
Output array.
22+
23+
Examples
24+
--------
25+
> var x = [ [ 1, 2 ], [ 3, 4 ] ];
26+
> var f = [ 'x', 'y' ];
27+
> var out = {{alias}}( x, f )
28+
[ { 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 } ]
29+
30+
See Also
31+
--------
32+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
* Property key.
27+
*/
28+
type PropertyKey = string | number | symbol;
29+
30+
/**
31+
* Converts each nested array to an object.
32+
*
33+
*
34+
* ## Notes
35+
*
36+
* - The function assumes that all nested arrays have the same length.
37+
* - The number of provided array labels should equal the length of each nested array.
38+
*
39+
* @param arr - input array
40+
* @param fields - list of field names
41+
* @returns output array
42+
*
43+
* @example
44+
* var x = [ [ 1, 2 ], [ 3, 4 ] ];
45+
* var fields = [ 'x', 'y' ];
46+
*
47+
* var out = nested2objects( x, fields );
48+
* // returns [ { 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 } ]
49+
*/
50+
declare function nested2objects<T = unknown, U extends PropertyKey = PropertyKey>( arr: ArrayLike<Collection<T> | AccessorArrayLike<T>>, fields: Collection<U> | AccessorArrayLike<U> ): Array<Record<U, T>>;
51+
52+
53+
// EXPORTS //
54+
55+
export = nested2objects;

0 commit comments

Comments
 (0)