Skip to content

Commit b851dd7

Browse files
committed
Auto-generated commit
1 parent 1fab79a commit b851dd7

File tree

24 files changed

+1720
-1
lines changed

24 files changed

+1720
-1
lines changed

CHANGELOG.md

Lines changed: 9 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-27)
7+
## Unreleased (2025-07-28)
88

99
<section class="features">
1010

1111
### Features
1212

13+
- [`0482e74`](https://github.com/stdlib-js/stdlib/commit/0482e7449c3d3d59fd0f89f1352cb90e59127756) - add `entries2views` to namespace
14+
- [`7e5f17b`](https://github.com/stdlib-js/stdlib/commit/7e5f17bf1d04ec84b0c137454a467ebee1370cf0) - add `array/base/entries2views`
15+
- [`62be202`](https://github.com/stdlib-js/stdlib/commit/62be202d080ca6b785ae018c95570242cbbf5873) - add `entries2objects` to namespace
16+
- [`f3d7a2f`](https://github.com/stdlib-js/stdlib/commit/f3d7a2fbe39b5aa81ed02f702bdd86103a2fd31b) - add `array/base/entries2objects`
1317
- [`cd23042`](https://github.com/stdlib-js/stdlib/commit/cd23042ad42089fb6b69783060bd67004d879ebe) - add `zip2views` to namespace
1418
- [`4a651c7`](https://github.com/stdlib-js/stdlib/commit/4a651c7b6d1ea9a814ac420a91c0d94de3956917) - add `array/base/zip2views`
1519
- [`302966e`](https://github.com/stdlib-js/stdlib/commit/302966e9b30769c05537f07169c2bda2fbee83f1) - add `zip` to namespace
@@ -227,6 +231,10 @@ A total of 32 issues were closed in this release:
227231

228232
<details>
229233

234+
- [`0482e74`](https://github.com/stdlib-js/stdlib/commit/0482e7449c3d3d59fd0f89f1352cb90e59127756) - **feat:** add `entries2views` to namespace _(by Athan Reines)_
235+
- [`7e5f17b`](https://github.com/stdlib-js/stdlib/commit/7e5f17bf1d04ec84b0c137454a467ebee1370cf0) - **feat:** add `array/base/entries2views` _(by Athan Reines)_
236+
- [`62be202`](https://github.com/stdlib-js/stdlib/commit/62be202d080ca6b785ae018c95570242cbbf5873) - **feat:** add `entries2objects` to namespace _(by Athan Reines)_
237+
- [`f3d7a2f`](https://github.com/stdlib-js/stdlib/commit/f3d7a2fbe39b5aa81ed02f702bdd86103a2fd31b) - **feat:** add `array/base/entries2objects` _(by Athan Reines)_
230238
- [`c95312a`](https://github.com/stdlib-js/stdlib/commit/c95312a79a73fb3424d20e2aa76a869304baa4d2) - **test:** add tests _(by Athan Reines)_
231239
- [`1d9b865`](https://github.com/stdlib-js/stdlib/commit/1d9b865020ea004692013ee403cbcc4580d9bbab) - **test:** add mutation tests _(by Athan Reines)_
232240
- [`53948cc`](https://github.com/stdlib-js/stdlib/commit/53948cc063bbf85d538b84ae678c1dc5117f864b) - **docs:** fix missing variable declaration _(by Athan Reines)_

base/entries2objects/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+
# entries2objects
22+
23+
> Convert array entries to an array of objects.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var entries2objects = require( '@stdlib/array/base/entries2objects' );
31+
```
32+
33+
#### entries2objects( arr, fields )
34+
35+
Converts array entries to an array of objects.
36+
37+
```javascript
38+
var x = [ 1, 2 ];
39+
40+
var fields = [ 'x', 'y' ];
41+
42+
var out = entries2objects( x, fields );
43+
// returns [ { 'x': 0, 'y': 1 }, { 'x': 1, 'y': 2 } ]
44+
```
45+
46+
The function supports the following parameters:
47+
48+
- **arr**: input array.
49+
- **fields**: list of field names.
50+
51+
</section>
52+
53+
<!-- /.usage -->
54+
55+
<section class="notes">
56+
57+
- The list of field names should be a two-element array where the first element corresponds to the field name of input array element index and the second element corresponds to the field name of the input array element value.
58+
59+
</section>
60+
61+
<!-- /.notes -->
62+
63+
<section class="examples">
64+
65+
## Examples
66+
67+
<!-- eslint no-undef: "error" -->
68+
69+
```javascript
70+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
71+
var entries2objects = require( '@stdlib/array/base/entries2objects' );
72+
73+
var x = discreteUniform( 10, -100, 100 );
74+
var fields = [ 'x', 'y' ];
75+
76+
var out = entries2objects( x, fields );
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: 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 zeroTo = require( './../../../base/zero-to' );
26+
var pkg = require( './../package.json' ).name;
27+
var entries2objects = require( './../lib' );
28+
29+
30+
// MAIN //
31+
32+
bench( pkg+':len=100', function benchmark( b ) {
33+
var labels;
34+
var x;
35+
var i;
36+
var v;
37+
38+
labels = [ 'x', 'y' ];
39+
x = zeroTo( 10 );
40+
41+
b.tic();
42+
for ( i = 0; i < b.iterations; i++ ) {
43+
v = entries2objects( x, labels );
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+
});
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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 isArray = require( '@stdlib/assert/is-array' );
27+
var pkg = require( './../package.json' ).name;
28+
var entries2objects = 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 labels = [ 'x', 'y' ];
42+
var x = zeroTo( len );
43+
return benchmark;
44+
45+
/**
46+
* Benchmark function.
47+
*
48+
* @private
49+
* @param {Benchmark} b - benchmark instance
50+
*/
51+
function benchmark( b ) {
52+
var v;
53+
var i;
54+
55+
b.tic();
56+
for ( i = 0; i < b.iterations; i++ ) {
57+
v = entries2objects( x, labels );
58+
if ( typeof v !== 'object' ) {
59+
b.fail( 'should return an array' );
60+
}
61+
}
62+
b.toc();
63+
if ( !isArray( v ) ) {
64+
b.fail( 'should return an array' );
65+
}
66+
b.pass( 'benchmark finished' );
67+
b.end();
68+
}
69+
}
70+
71+
72+
// MAIN //
73+
74+
/**
75+
* Main execution sequence.
76+
*
77+
* @private
78+
*/
79+
function main() {
80+
var len;
81+
var min;
82+
var max;
83+
var f;
84+
var i;
85+
86+
min = 1; // 10^min
87+
max = 6; // 10^max
88+
89+
for ( i = min; i <= max; i++ ) {
90+
len = pow( 10, i );
91+
f = createBenchmark( len );
92+
bench( pkg+':len='+len, f );
93+
}
94+
}
95+
96+
main();

base/entries2objects/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 array entries to an array of objects.
4+
5+
The list of field names should be a two-element array where the first
6+
element corresponds to the field name of input array element index and the
7+
second element corresponds to the field name of the input array element
8+
value.
9+
10+
Parameters
11+
----------
12+
arr: ArrayLikeObject
13+
Input array.
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 ];
26+
> var f = [ 'x', 'y' ];
27+
> var out = {{alias}}( x, f )
28+
[ { 'x': 0, 'y': 1 }, { 'x': 1, 'y': 2 } ]
29+
30+
See Also
31+
--------
32+
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+
* Converts array entries to an array of objects.
32+
*
33+
* ## Notes
34+
*
35+
* - The list of field names should be a two-element array where the first element corresponds to the field name of input array element index and the second element corresponds to the field name of the input array element value.
36+
*
37+
* @param arr - input array
38+
* @param fields - list of field names
39+
* @returns output array
40+
*
41+
* @example
42+
* var x = [ 1, 2, 3 ];
43+
* var fields = [ 'x', 'y' ];
44+
*
45+
* var out = entries2objects( x, fields );
46+
* // returns [ { 'x': 0, 'y': 1 }, { 'x': 1, 'y': 2 }, { 'x': 2, 'y': 3 } ]
47+
*/
48+
declare function entries2objects<T = unknown, U extends PropertyKey = PropertyKey>( arr: Collection<T> | AccessorArrayLike<T>, fields: Collection<U> | AccessorArrayLike<U> ): Array<Record<U, T>>;
49+
50+
51+
// EXPORTS //
52+
53+
export = entries2objects;

0 commit comments

Comments
 (0)