Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Nov 18, 2024
1 parent d334ed3 commit 991fb75
Show file tree
Hide file tree
Showing 9 changed files with 531 additions and 9 deletions.
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,71 @@

> Package changelog.

<section class="release" id="unreleased">

## Unreleased (2024-11-18)

<section class="packages">

### Packages

<section class="package" id="array-fixed-endian-factory-unreleased">

#### [@stdlib/array/fixed-endian-factory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/fixed-endian-factory)

<details>

<section class="features">

##### Features

- [`956a462`](https://github.com/stdlib-js/stdlib/commit/956a4624c788689b1bca285856b987ea3aa32eb6) - add `forEach` method

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

</section>

<!-- /.packages -->

<section class="contributors">

### Contributors

A total of 1 person contributed to this release. Thank you to this contributor:

- Athan Reines

</section>

<!-- /.contributors -->

<section class="commits">

### Commits

<details>

- [`956a462`](https://github.com/stdlib-js/stdlib/commit/956a4624c788689b1bca285856b987ea3aa32eb6) - **feat:** add `forEach` method _(by Athan Reines)_
- [`de1ef8b`](https://github.com/stdlib-js/stdlib/commit/de1ef8ba5e2d7dd1363bdf826572456f49b7895c) - **docs:** fix example _(by Athan Reines)_

</details>

</section>

<!-- /.commits -->

</section>

<!-- /.release -->

<section class="release" id="v0.3.3">

## 0.3.3 (2024-11-05)
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Mohammad Kaif <[email protected]>
Momtchil Momtchev <[email protected]>
Muhammad Haris <[email protected]>
Naresh Jagadeesan <[email protected]>
Neeraj Pathak <[email protected]>
NightKnight <[email protected]>
Nithin Katta <[email protected]>
Nourhan Hasan <[email protected]>
Expand All @@ -69,6 +70,7 @@ Prajwal Kulkarni <[email protected]>
Pranav Goswami <[email protected]>
Praneki <[email protected]>
Pratik <[email protected]>
Pratyush Kumar Chouhan <[email protected]>
Priyansh <[email protected]>
Pushpendra Chandravanshi <[email protected]>
RISHAV <[email protected]>
Expand All @@ -79,6 +81,7 @@ Ridam Garg <[email protected]>
Robert Gislason <[email protected]>
Roman Stetsyk <[email protected]>
Rutam <[email protected]>
Ruthwik Chikoti <[email protected]>
Ryan Seal <[email protected]>
Sai Srikar Dumpeti <[email protected]>
SarthakPaandey <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
[npm-image]: http://img.shields.io/npm/v/@stdlib/array.svg
[npm-url]: https://npmjs.org/package/@stdlib/array

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

[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array/main.svg
[coverage-url]: https://codecov.io/github/stdlib-js/array?branch=main
Expand Down
9 changes: 2 additions & 7 deletions bool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ Invokes a function once for each array element.

```javascript
function log( v, i ) {
console.log( '%s: %s', i, v.toString() );
console.log( '%s: %s', i.toString(), v.toString() );
}

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

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

arr.forEach( fcn, context );
/* =>
0: 1 + 1i
1: 2 + 2i
2: 3 + 3i
*/

var count = context.count;
// returns 3
Expand Down
59 changes: 59 additions & 0 deletions fixed-endian-factory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,65 @@ var v = arr.get( 0 );
// returns 1.0
```

<a name="method-for-each"></a>

#### TypedArrayFE.prototype.forEach( callbackFn\[, thisArg] )

Invokes a function once for each array element.

```javascript
function log( v, i ) {
console.log( '%s: %s', i.toString(), v.toString() );
}

var Float64ArrayFE = fixedEndianFactory( 'float64' );

var arr = new Float64ArrayFE( 'little-endian', 3 );

arr.set( 1.5, 0 );
arr.set( 2.5, 1 );
arr.set( 3.5, 2 );

arr.forEach( log );
/* =>
0: 1.5
1: 2.5
2: 3.5
*/
```

The invoked function is provided three arguments:

- **value**: current array element.
- **index**: current array element index.
- **arr**: the array on which this method was called.

To set the function execution context, provide a `thisArg`.

```javascript
function fcn( v, i ) {
this.count += 1;
console.log( '%s: %s', i.toString(), v.toString() );
}

var Float64ArrayFE = fixedEndianFactory( 'float64' );

var arr = new Float64ArrayFE( 'little-endian', 3 );

var context = {
'count': 0
};

arr.set( 1.0, 0 );
arr.set( 2.0, 1 );
arr.set( 3.0, 2 );

arr.forEach( fcn, context );

var count = context.count;
// returns 3
```

<a name="method-get"></a>

#### TypedArrayFE.prototype.get( i )
Expand Down
61 changes: 61 additions & 0 deletions fixed-endian-factory/benchmark/benchmark.for_each.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var factory = require( './../lib' );


// VARIABLES //

var Float64ArrayFE = factory( 'float64' );


// MAIN //

bench( pkg+':forEach', function benchmark( b ) {
var arr;
var i;

arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 2.0, 1.0 ] );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr.forEach( check );
if ( arr.length !== 4 ) {
b.fail( 'should not change an array length' );
}
}
b.toc();
if ( arr.length !== 4 ) {
b.fail( 'should not change an array length' );
}
b.pass( 'benchmark finished' );
b.end();

function check( v ) {
if ( isnan( v ) ) {
b.fail( 'should not return NaN' );
}
}
});
105 changes: 105 additions & 0 deletions fixed-endian-factory/benchmark/benchmark.for_each.length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var pow = require( '@stdlib/math/base/special/pow' );
var zeroTo = require( './../../zero-to' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var factory = require( './../lib' );


// VARIABLES //

var Float64ArrayFE = factory( 'float64' );


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) );
return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
arr.forEach( callback );
if ( arr.length !== len ) {
b.fail( 'should not change an array length' );
}
}
b.toc();
if ( arr.length !== len ) {
b.fail( 'should not change an array length' );
}
b.pass( 'benchmark finished' );
b.end();

function callback( value ) {
if ( isnan( value ) ) {
throw new Error( 'something went wrong' );
}
}
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = pow( 10, i );
f = createBenchmark( len );
bench( pkg+':forEach:len='+len, f );
}
}

main();
Loading

0 comments on commit 991fb75

Please sign in to comment.