Skip to content

Commit 872f8b2

Browse files
Merge branch 'develop' of github.com:stdlib-js/stdlib into endian-toSorted
2 parents bb097df + 37e85cf commit 872f8b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2818
-280
lines changed

.github/workflows/lint_changed_files.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ jobs:
257257
- name: 'Setup R'
258258
if: ( success() || failure() ) && steps.check-r-files.outputs.files != ''
259259
# Pin action to full length commit SHA
260-
uses: r-lib/actions/setup-r@e6be4b3706e0f39bc7a4cf4496a5f2c4cb840040 # v2.10.1
260+
uses: r-lib/actions/setup-r@473c68190595b311a74f208fba61a8d8c0d4c247 # v2.11.1
261261
with:
262262
r-version: '3.5.3'
263263

.github/workflows/lint_random_files.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ jobs:
326326
- name: 'Setup R'
327327
if: ( github.event.inputs.r != 'false' ) && ( success() || failure() )
328328
# Pin action to full length commit SHA
329-
uses: r-lib/actions/setup-r@e6be4b3706e0f39bc7a4cf4496a5f2c4cb840040 # v2.10.1
329+
uses: r-lib/actions/setup-r@473c68190595b311a74f208fba61a8d8c0d4c247 # v2.11.1
330330
with:
331331
r-version: '4.3.3'
332332

.github/workflows/windows_test_npm_install.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152
# Install MSYS2:
153153
- name: 'Install MSYS2'
154154
# Pin action to full length commit SHA
155-
uses: msys2/setup-msys2@ddf331adaebd714795f1042345e6ca57bd66cea8 # v2.24.1
155+
uses: msys2/setup-msys2@c52d1fa9c7492275e60fe763540fb601f5f232a1 # v2.25.0
156156
with:
157157
# Set the MSYS system:
158158
msystem: MINGW64

lib/node_modules/@stdlib/array/base/broadcasted-ternary3d/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@stdlib/array/base/broadcasted-ternary3d",
2+
"name": "@stdlib/array/base/broadcasted-ternary3d",
33
"version": "0.0.0",
44
"description": "Apply a ternary callback to elements in three broadcasted input arrays and assign results to elements in a three-dimensional nested output array.",
55
"license": "Apache-2.0",

lib/node_modules/@stdlib/array/base/broadcasted-ternary4d/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@stdlib/array/base/broadcasted-ternary4d",
2+
"name": "@stdlib/array/base/broadcasted-ternary4d",
33
"version": "0.0.0",
44
"description": "Apply a ternary callback to elements in three broadcasted input arrays and assign results to elements in a four-dimensional nested output array.",
55
"license": "Apache-2.0",

lib/node_modules/@stdlib/array/fixed-endian-factory/README.md

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,66 @@ var count = context.count;
451451
// returns 3
452452
```
453453

454+
<a name="method-filter"></a>
455+
456+
#### TypedArrayFE.prototype.filter( predicate\[, thisArg] )
457+
458+
Returns a new array containing the elements of an array which pass a test implemented by a predicate function.
459+
460+
```javascript
461+
function predicate( v ) {
462+
return ( v % 2 === 0 );
463+
}
464+
465+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
466+
467+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] );
468+
469+
var out = arr.filter( predicate );
470+
// returns <Float64ArrayFE>
471+
472+
var len = out.length;
473+
// returns 2
474+
475+
var v = out.get( 0 );
476+
// returns 2.0
477+
478+
v = out.get( 1 );
479+
// return 4.0
480+
```
481+
482+
The `predicate` function is provided three arguments:
483+
484+
- **value**: current array element.
485+
- **index**: current array element index.
486+
- **arr**: the array on which this method was called.
487+
488+
To set the function execution context, provide a `thisArg`.
489+
490+
```javascript
491+
function predicate( v, i ) {
492+
this.count += 1;
493+
return ( v % 2 === 0 );
494+
}
495+
496+
var context = {
497+
'count': 0
498+
};
499+
500+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
501+
502+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] );
503+
504+
var out = arr.filter( predicate, context );
505+
// returns <Float64ArrayFE>
506+
507+
var len = out.length;
508+
// returns 2
509+
510+
var count = context.count;
511+
// returns 4
512+
```
513+
454514
<a name="method-get"></a>
455515

456516
#### TypedArrayFE.prototype.get( i )
@@ -515,6 +575,38 @@ var idx = arr.indexOf( 5.0 );
515575
// returns -1
516576
```
517577

578+
<a name="method-last-index-of"></a>
579+
580+
#### TypedArrayFE.prototype.lastIndexOf( searchElement\[, fromIndex] )
581+
582+
Returns the last index at which a given element can be found in the array.
583+
584+
```javascript
585+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
586+
587+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] );
588+
589+
var idx = arr.lastIndexOf( 2.0 );
590+
// returns 4
591+
592+
idx = arr.lastIndexOf( 2.0, 3 );
593+
// returns 1
594+
595+
idx = arr.lastIndexOf( 2.0, -2 );
596+
// returns 1
597+
```
598+
599+
If `searchElement` is not present in the array, the method returns `-1`.
600+
601+
```javascript
602+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
603+
604+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] );
605+
606+
var idx = arr.lastIndexOf( 5.0 );
607+
// returns -1
608+
```
609+
518610
<a name="method-toSorted"></a>
519611

520612
#### TypedArrayFE.prototype.toSorted( compareFcn )
@@ -609,7 +701,99 @@ var out = arr.map( fcn, context );
609701
var count = context.count;
610702
// returns 3;
611703
```
704+
705+
<a name="method-reduce"></a>
706+
707+
#### TypedArray.prototype.reduce( reducerFn\[, initialValue] )
708+
709+
Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.
710+
711+
```javascript
712+
function reducer( acc, v ) {
713+
return ( acc && v );
714+
}
715+
716+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
717+
718+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 0.0, 1.0 ] );
719+
// returns <Float64ArrayFE>
720+
721+
var out = arr.reduce( reducer );
722+
// returns 0.0
723+
```
724+
725+
The reducer function is provided four arguments:
726+
727+
- **acc**: accumulated result.
728+
- **value**: current array element.
729+
- **index**: current array element index.
730+
- **arr**: the array on which this method was called.
731+
732+
By default, the function initializes the accumulated result to the first element in the array and passes the second array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the first array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument.
733+
734+
```javascript
735+
function reducer( acc, v ) {
736+
if ( v ) {
737+
return acc + 1;
738+
}
739+
return acc;
740+
}
741+
742+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
743+
744+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 0.0, 1.0 ] );
745+
// returns <Float64ArrayFE>
746+
747+
var out = arr.reduce( reducer, 0 );
748+
// returns 2
749+
```
750+
751+
<a name="method-reduce-right"></a>
752+
753+
#### TypedArray.prototype.reduceRight( reducerFn\[, initialValue] )
754+
755+
Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion.
756+
757+
```javascript
758+
function reducer( acc, v ) {
759+
return ( acc && v );
760+
}
761+
762+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
763+
764+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 0.0, 1.0 ] );
765+
// returns <Float64ArrayFE>
766+
767+
var out = arr.reduceRight( reducer );
768+
// returns 0.0
769+
```
770+
771+
The reducer function is provided four arguments:
772+
773+
- **acc**: accumulated result.
774+
- **value**: current array element.
775+
- **index**: current array element index.
776+
- **arr**: the array on which this method was called.
777+
778+
By default, the function initializes the accumulated result to the first element in the array and passes the second array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the first array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument.
779+
780+
```javascript
781+
function reducer( acc, v ) {
782+
if ( v ) {
783+
return acc + 1;
784+
}
785+
return acc;
786+
}
787+
788+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
789+
790+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 0.0, 1.0 ] );
791+
// returns <Float64ArrayFE>
612792

793+
var out = arr.reduceRight( reducer, 0 );
794+
// returns 2
795+
```
796+
613797
<a name="method-set"></a>
614798

615799
#### TypedArrayFE.prototype.set( arr\[, offset] )
@@ -728,6 +912,35 @@ var str = arr.toString();
728912
// returns '1,2,3'
729913
```
730914

915+
<a name="method-join"></a>
916+
917+
#### TypedArrayFE.prototype.join( \[separator] )
918+
919+
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.
920+
921+
```javascript
922+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
923+
924+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] );
925+
926+
var str = arr.join();
927+
// returns '1,2,3'
928+
929+
str = arr.join( ' - ' );
930+
// returns '1 - 2 - 3'
931+
```
932+
933+
If the provided `separator` is not a string, it is coerced to a string.
934+
935+
```javascript
936+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
937+
938+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] );
939+
940+
var str = arr.join( 0 );
941+
// returns '10203'
942+
```
943+
731944
</section>
732945

733946
<!-- /.usage -->
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 pkg = require( './../package.json' ).name;
25+
var factory = require( './../lib' );
26+
27+
28+
// VARIABLES //
29+
30+
var Float64ArrayFE = factory( 'float64' );
31+
32+
33+
// MAIN //
34+
35+
bench( pkg+':filter', function benchmark( b ) {
36+
var out;
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+
out = arr.filter( predicate );
45+
if ( typeof out !== 'object' ) {
46+
b.fail( 'should return an object' );
47+
}
48+
}
49+
b.toc();
50+
if ( !( out instanceof Float64ArrayFE ) ) {
51+
b.fail( 'should return a typed array' );
52+
}
53+
b.pass( 'benchmark finished' );
54+
b.end();
55+
56+
function predicate( v ) {
57+
return v % 2 === 0;
58+
}
59+
});

0 commit comments

Comments
 (0)