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 Dec 3, 2024
1 parent eaad8f7 commit 3a51051
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 197 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

## Unreleased (2024-12-02)
## Unreleased (2024-12-03)

<section class="packages">

Expand Down Expand Up @@ -591,6 +591,8 @@ A total of 8 people contributed to this release. Thank you to the following cont

<details>

- [`e5d32c5`](https://github.com/stdlib-js/stdlib/commit/e5d32c53f8f552fae4d672c8750619a59ce078ac) - **chore:** minor clean-up _(by Philipp Burckhardt)_
- [`9798530`](https://github.com/stdlib-js/stdlib/commit/97985302871b99c45462d43479e246c4549c3991) - **chore:** minor clean-up _(by Philipp Burckhardt)_
- [`a0ba090`](https://github.com/stdlib-js/stdlib/commit/a0ba090515dfdfe617e1179ddb7581db24fec44b) - **feat:** add `with` method to `array/fixed-endian-factory` [(#3291)](https://github.com/stdlib-js/stdlib/pull/3291) _(by Aayush Khanna, Philipp Burckhardt)_
- [`d24969e`](https://github.com/stdlib-js/stdlib/commit/d24969e35be1cfbff2e0d62d740c451e476ee444) - **chore:** update package meta data [(#3303)](https://github.com/stdlib-js/stdlib/pull/3303) _(by stdlib-bot, Athan Reines)_
- [`1242bbf`](https://github.com/stdlib-js/stdlib/commit/1242bbf3e43a142f8d0bd4a66aece5baa33c03fe) - **feat:** add `filter` method to `array/fixed-endian-factory` [(#3278)](https://github.com/stdlib-js/stdlib/pull/3278) _(by Aayush Khanna, Philipp Burckhardt)_
Expand Down
121 changes: 59 additions & 62 deletions fixed-endian-factory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,35 +390,35 @@ var count = context.count;
// returns 3
```

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

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

Invokes a function once for each array element.
Returns a new array containing the elements of an array which pass a test implemented by a predicate function.

```javascript
function log( v, i ) {
console.log( '%s: %s', i.toString(), v.toString() );
function predicate( v ) {
return ( v % 2 === 0 );
}

var Float64ArrayFE = fixedEndianFactory( 'float64' );

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

var out = arr.filter( predicate );
// returns <Float64ArrayFE>

arr.set( 1.5, 0 );
arr.set( 2.5, 1 );
arr.set( 3.5, 2 );
var len = out.length;
// returns 2

arr.forEach( log );
/* =>
0: 1.5
1: 2.5
2: 3.5
*/
var v = out.get( 0 );
// returns 2.0

v = out.get( 1 );
// return 4.0
```

The invoked function is provided three arguments:
The `predicate` function is provided three arguments:

- **value**: current array element.
- **index**: current array element index.
Expand All @@ -427,59 +427,58 @@ The invoked function is provided three arguments:
To set the function execution context, provide a `thisArg`.

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

var Float64ArrayFE = fixedEndianFactory( 'float64' );

var arr = new Float64ArrayFE( 'little-endian', 3 );
// returns <Float64ArrayFE>

var context = {
'count': 0
};

arr.set( 1.0, 0 );
arr.set( 2.0, 1 );
arr.set( 3.0, 2 );
var Float64ArrayFE = fixedEndianFactory( 'float64' );

arr.forEach( fcn, context );
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] );

var out = arr.filter( predicate, context );
// returns <Float64ArrayFE>

var len = out.length;
// returns 2

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

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

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

Returns a new array containing the elements of an array which pass a test implemented by a predicate function.
Invokes a function once for each array element.

```javascript
function predicate( v ) {
return ( v % 2 === 0 );
function log( v, i ) {
console.log( '%s: %s', i.toString(), v.toString() );
}

var Float64ArrayFE = fixedEndianFactory( 'float64' );

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

var out = arr.filter( predicate );
var arr = new Float64ArrayFE( 'little-endian', 3 );
// returns <Float64ArrayFE>

var len = out.length;
// returns 2

var v = out.get( 0 );
// returns 2.0
arr.set( 1.5, 0 );
arr.set( 2.5, 1 );
arr.set( 3.5, 2 );

v = out.get( 1 );
// return 4.0
arr.forEach( log );
/* =>
0: 1.5
1: 2.5
2: 3.5
*/
```

The `predicate` function is provided three arguments:
The invoked function is provided three arguments:

- **value**: current array element.
- **index**: current array element index.
Expand All @@ -488,27 +487,28 @@ The `predicate` function is provided three arguments:
To set the function execution context, provide a `thisArg`.

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

var Float64ArrayFE = fixedEndianFactory( 'float64' );

var arr = new Float64ArrayFE( 'little-endian', 3 );
// returns <Float64ArrayFE>

var context = {
'count': 0
};

var Float64ArrayFE = fixedEndianFactory( 'float64' );

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

var out = arr.filter( predicate, context );
// returns <Float64ArrayFE>
arr.set( 1.0, 0 );
arr.set( 2.0, 1 );
arr.set( 3.0, 2 );

var len = out.length;
// returns 2
arr.forEach( fcn, context );

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

<a name="method-get"></a>
Expand Down Expand Up @@ -883,7 +883,7 @@ var str = arr.toString();

#### TypedArrayFE.prototype.join( \[separator] )

Serializes the array elements into a string, with elements separated by the specified `separator`. If no `separator` is provided, a comma (`,`) is used as the default.
Returns a new string by concatenating all array elements.

```javascript
var Float64ArrayFE = fixedEndianFactory( 'float64' );
Expand All @@ -892,20 +892,17 @@ var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] );

var str = arr.join();
// returns '1,2,3'

str = arr.join( ' - ' );
// returns '1 - 2 - 3'
```

If the provided `separator` is not a string, it is coerced to a string.
By default, the method separates serialized array elements with a comma. To use an alternative separator, provide a `separator` string.

```javascript
var Float64ArrayFE = fixedEndianFactory( 'float64' );

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

var str = arr.join( 0 );
// returns '10203'
var str = arr.join( ' - ' );
// returns '1 - 2 - 3'
```

<a name="method-with"></a>
Expand Down
3 changes: 1 addition & 2 deletions fixed-endian-factory/benchmark/benchmark.join.length.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ var Float64ArrayFE = factory( 'float64' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var arr;
arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) );
var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) );
return benchmark;

/**
Expand Down
Loading

0 comments on commit 3a51051

Please sign in to comment.