Skip to content

Commit 991fb75

Browse files
committed
Auto-generated commit
1 parent d334ed3 commit 991fb75

File tree

9 files changed

+531
-9
lines changed

9 files changed

+531
-9
lines changed

CHANGELOG.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,71 @@
22

33
> Package changelog.
44
5+
<section class="release" id="unreleased">
6+
7+
## Unreleased (2024-11-18)
8+
9+
<section class="packages">
10+
11+
### Packages
12+
13+
<section class="package" id="array-fixed-endian-factory-unreleased">
14+
15+
#### [@stdlib/array/fixed-endian-factory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/fixed-endian-factory)
16+
17+
<details>
18+
19+
<section class="features">
20+
21+
##### Features
22+
23+
- [`956a462`](https://github.com/stdlib-js/stdlib/commit/956a4624c788689b1bca285856b987ea3aa32eb6) - add `forEach` method
24+
25+
</section>
26+
27+
<!-- /.features -->
28+
29+
</details>
30+
31+
</section>
32+
33+
<!-- /.package -->
34+
35+
</section>
36+
37+
<!-- /.packages -->
38+
39+
<section class="contributors">
40+
41+
### Contributors
42+
43+
A total of 1 person contributed to this release. Thank you to this contributor:
44+
45+
- Athan Reines
46+
47+
</section>
48+
49+
<!-- /.contributors -->
50+
51+
<section class="commits">
52+
53+
### Commits
54+
55+
<details>
56+
57+
- [`956a462`](https://github.com/stdlib-js/stdlib/commit/956a4624c788689b1bca285856b987ea3aa32eb6) - **feat:** add `forEach` method _(by Athan Reines)_
58+
- [`de1ef8b`](https://github.com/stdlib-js/stdlib/commit/de1ef8ba5e2d7dd1363bdf826572456f49b7895c) - **docs:** fix example _(by Athan Reines)_
59+
60+
</details>
61+
62+
</section>
63+
64+
<!-- /.commits -->
65+
66+
</section>
67+
68+
<!-- /.release -->
69+
570
<section class="release" id="v0.3.3">
671

772
## 0.3.3 (2024-11-05)

CONTRIBUTORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Mohammad Kaif <[email protected]>
5959
Momtchil Momtchev <[email protected]>
6060
Muhammad Haris <[email protected]>
6161
Naresh Jagadeesan <[email protected]>
62+
Neeraj Pathak <[email protected]>
6263
NightKnight <[email protected]>
6364
Nithin Katta <[email protected]>
6465
Nourhan Hasan <[email protected]>
@@ -69,6 +70,7 @@ Prajwal Kulkarni <[email protected]>
6970
Pranav Goswami <[email protected]>
7071
7172
73+
Pratyush Kumar Chouhan <[email protected]>
7274
7375
Pushpendra Chandravanshi <[email protected]>
7476
@@ -79,6 +81,7 @@ Ridam Garg <[email protected]>
7981
Robert Gislason <[email protected]>
8082
Roman Stetsyk <[email protected]>
8183
84+
Ruthwik Chikoti <[email protected]>
8285
Ryan Seal <[email protected]>
8386
Sai Srikar Dumpeti <[email protected]>
8487
SarthakPaandey <[email protected]>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
322322
[npm-image]: http://img.shields.io/npm/v/@stdlib/array.svg
323323
[npm-url]: https://npmjs.org/package/@stdlib/array
324324

325-
[test-image]: https://github.com/stdlib-js/array/actions/workflows/test.yml/badge.svg?branch=v0.3.3
326-
[test-url]: https://github.com/stdlib-js/array/actions/workflows/test.yml?query=branch:v0.3.3
325+
[test-image]: https://github.com/stdlib-js/array/actions/workflows/test.yml/badge.svg?branch=main
326+
[test-url]: https://github.com/stdlib-js/array/actions/workflows/test.yml?query=branch:main
327327

328328
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array/main.svg
329329
[coverage-url]: https://codecov.io/github/stdlib-js/array?branch=main

bool/README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ Invokes a function once for each array element.
869869

870870
```javascript
871871
function log( v, i ) {
872-
console.log( '%s: %s', i, v.toString() );
872+
console.log( '%s: %s', i.toString(), v.toString() );
873873
}
874874

875875
var arr = new BooleanArray( 3 );
@@ -897,7 +897,7 @@ To set the function execution context, provide a `thisArg`.
897897
```javascript
898898
function fcn( v, i ) {
899899
this.count += 1;
900-
console.log( '%s: %s', i, v.toString() );
900+
console.log( '%s: %s', i.toString(), v.toString() );
901901
}
902902

903903
var arr = new BooleanArray( 3 );
@@ -911,11 +911,6 @@ arr.set( false, 1 );
911911
arr.set( true, 2 );
912912

913913
arr.forEach( fcn, context );
914-
/* =>
915-
0: 1 + 1i
916-
1: 2 + 2i
917-
2: 3 + 3i
918-
*/
919914

920915
var count = context.count;
921916
// returns 3

fixed-endian-factory/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,65 @@ var v = arr.get( 0 );
306306
// returns 1.0
307307
```
308308

309+
<a name="method-for-each"></a>
310+
311+
#### TypedArrayFE.prototype.forEach( callbackFn\[, thisArg] )
312+
313+
Invokes a function once for each array element.
314+
315+
```javascript
316+
function log( v, i ) {
317+
console.log( '%s: %s', i.toString(), v.toString() );
318+
}
319+
320+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
321+
322+
var arr = new Float64ArrayFE( 'little-endian', 3 );
323+
324+
arr.set( 1.5, 0 );
325+
arr.set( 2.5, 1 );
326+
arr.set( 3.5, 2 );
327+
328+
arr.forEach( log );
329+
/* =>
330+
0: 1.5
331+
1: 2.5
332+
2: 3.5
333+
*/
334+
```
335+
336+
The invoked function is provided three arguments:
337+
338+
- **value**: current array element.
339+
- **index**: current array element index.
340+
- **arr**: the array on which this method was called.
341+
342+
To set the function execution context, provide a `thisArg`.
343+
344+
```javascript
345+
function fcn( v, i ) {
346+
this.count += 1;
347+
console.log( '%s: %s', i.toString(), v.toString() );
348+
}
349+
350+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
351+
352+
var arr = new Float64ArrayFE( 'little-endian', 3 );
353+
354+
var context = {
355+
'count': 0
356+
};
357+
358+
arr.set( 1.0, 0 );
359+
arr.set( 2.0, 1 );
360+
arr.set( 3.0, 2 );
361+
362+
arr.forEach( fcn, context );
363+
364+
var count = context.count;
365+
// returns 3
366+
```
367+
309368
<a name="method-get"></a>
310369

311370
#### TypedArrayFE.prototype.get( i )
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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 isnan = require( '@stdlib/math/base/assert/is-nan' );
25+
var pkg = require( './../package.json' ).name;
26+
var factory = require( './../lib' );
27+
28+
29+
// VARIABLES //
30+
31+
var Float64ArrayFE = factory( 'float64' );
32+
33+
34+
// MAIN //
35+
36+
bench( pkg+':forEach', function benchmark( b ) {
37+
var arr;
38+
var i;
39+
40+
arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 2.0, 1.0 ] );
41+
42+
b.tic();
43+
for ( i = 0; i < b.iterations; i++ ) {
44+
arr.forEach( check );
45+
if ( arr.length !== 4 ) {
46+
b.fail( 'should not change an array length' );
47+
}
48+
}
49+
b.toc();
50+
if ( arr.length !== 4 ) {
51+
b.fail( 'should not change an array length' );
52+
}
53+
b.pass( 'benchmark finished' );
54+
b.end();
55+
56+
function check( v ) {
57+
if ( isnan( v ) ) {
58+
b.fail( 'should not return NaN' );
59+
}
60+
}
61+
});
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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( './../../zero-to' );
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var pkg = require( './../package.json' ).name;
28+
var factory = require( './../lib' );
29+
30+
31+
// VARIABLES //
32+
33+
var Float64ArrayFE = factory( 'float64' );
34+
35+
36+
// FUNCTIONS //
37+
38+
/**
39+
* Creates a benchmark function.
40+
*
41+
* @private
42+
* @param {PositiveInteger} len - array length
43+
* @returns {Function} benchmark function
44+
*/
45+
function createBenchmark( len ) {
46+
var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) );
47+
return benchmark;
48+
49+
/**
50+
* Benchmark function.
51+
*
52+
* @private
53+
* @param {Benchmark} b - benchmark instance
54+
*/
55+
function benchmark( b ) {
56+
var i;
57+
58+
b.tic();
59+
for ( i = 0; i < b.iterations; i++ ) {
60+
arr.forEach( callback );
61+
if ( arr.length !== len ) {
62+
b.fail( 'should not change an array length' );
63+
}
64+
}
65+
b.toc();
66+
if ( arr.length !== len ) {
67+
b.fail( 'should not change an array length' );
68+
}
69+
b.pass( 'benchmark finished' );
70+
b.end();
71+
72+
function callback( value ) {
73+
if ( isnan( value ) ) {
74+
throw new Error( 'something went wrong' );
75+
}
76+
}
77+
}
78+
}
79+
80+
81+
// MAIN //
82+
83+
/**
84+
* Main execution sequence.
85+
*
86+
* @private
87+
*/
88+
function main() {
89+
var len;
90+
var min;
91+
var max;
92+
var f;
93+
var i;
94+
95+
min = 1; // 10^min
96+
max = 6; // 10^max
97+
98+
for ( i = min; i <= max; i++ ) {
99+
len = pow( 10, i );
100+
f = createBenchmark( len );
101+
bench( pkg+':forEach:len='+len, f );
102+
}
103+
}
104+
105+
main();

0 commit comments

Comments
 (0)