Skip to content

Commit 4a602fc

Browse files
authored
Merge branch 'stdlib-js:develop' into mskunary5d
2 parents 34c25dc + f1fa458 commit 4a602fc

File tree

212 files changed

+26776
-491
lines changed

Some content is hidden

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

212 files changed

+26776
-491
lines changed

.github/workflows/slash_commands.yml

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ on:
2929
# Workflow jobs:
3030
jobs:
3131

32-
# Add a new job for adding the initial reaction
32+
# Define a job for adding an initial reaction:
3333
add_initial_reaction:
3434

35+
# Define a display name:
36+
name: 'Add initial reaction'
37+
3538
# Define the type of virtual host machine:
3639
runs-on: ubuntu-latest
3740

@@ -40,7 +43,21 @@ jobs:
4043

4144
# Define the job's steps:
4245
steps:
43-
# Add initial reaction to the comment
46+
# Add "bot: In progress" label to the issue / PR:
47+
- name: 'Add in-progress label'
48+
# Pin action to full length commit SHA
49+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
50+
with:
51+
github-token: ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}
52+
script: |
53+
github.rest.issues.addLabels({
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
issue_number: context.issue.number,
57+
labels: ['bot: In Progress']
58+
})
59+
60+
# Add initial reaction to comment with slash command:
4461
- name: 'Add initial reaction'
4562
run: |
4663
COMMENT="${{ github.event.comment.body }}"
@@ -67,6 +84,12 @@ jobs:
6784
# Define a job for checking for required files:
6885
check_files:
6986

87+
# Define a display name:
88+
name: 'Check for required files'
89+
90+
# Ensure initial reaction job has completed before running this job:
91+
needs: [ add_initial_reaction ]
92+
7093
# Define the conditions under which the job should run:
7194
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib check-files')
7295

@@ -81,6 +104,9 @@ jobs:
81104
# Define a job for updating copyright header years:
82105
update_copyright_years:
83106

107+
# Define a display name:
108+
name: 'Update copyright header years'
109+
84110
# Define the conditions under which the job should run:
85111
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib update-copyright-years')
86112

@@ -97,6 +123,12 @@ jobs:
97123
# Define a job for auto-fixing lint errors:
98124
fix_lint_errors:
99125

126+
# Define a display name:
127+
name: 'Auto-fix lint errors'
128+
129+
# Ensure initial reaction job has completed before running this job:
130+
needs: [ add_initial_reaction ]
131+
100132
# Define the conditions under which the job should run:
101133
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib lint-autofix')
102134

@@ -113,6 +145,12 @@ jobs:
113145
# Define a job for merging develop branch:
114146
merge_develop:
115147

148+
# Define a display name:
149+
name: 'Merge changes from develop branch into this PR'
150+
151+
# Ensure initial reaction job has completed before running this job:
152+
needs: [ add_initial_reaction ]
153+
116154
# Define the conditions under which the job should run:
117155
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib merge')
118156

@@ -129,6 +167,12 @@ jobs:
129167
# Define a job for rebasing on develop branch:
130168
rebase_develop:
131169

170+
# Define a display name:
171+
name: 'Rebase this PR on top of develop branch'
172+
173+
# Ensure initial reaction job has completed before running this job:
174+
needs: [ add_initial_reaction ]
175+
132176
# Define the conditions under which the job should run:
133177
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib rebase')
134178

@@ -146,11 +190,14 @@ jobs:
146190
help:
147191

148192
# Define a display name:
149-
name: 'Help'
193+
name: 'Print a list of available slash commands'
150194

151195
# Define the type of virtual host machine:
152196
runs-on: ubuntu-latest
153197

198+
# Ensure initial reaction job has completed before running this job:
199+
needs: [ add_initial_reaction ]
200+
154201
# Define the conditions under which the job should run:
155202
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib help')
156203

@@ -176,3 +223,42 @@ jobs:
176223
177224
# GitHub token:
178225
token: ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}
226+
227+
# Define a job for removing the in-progress label:
228+
remove_progress_label:
229+
230+
# Define a display name:
231+
name: 'Remove in-progress label'
232+
233+
# Define the type of virtual host machine:
234+
runs-on: ubuntu-latest
235+
236+
# Ensure all previous jobs have completed before running this job:
237+
needs: [ add_initial_reaction, check_files, update_copyright_years, fix_lint_errors, merge_develop, rebase_develop, help ]
238+
239+
# Define the conditions under which the job should run:
240+
if: |
241+
always() &&
242+
github.event.issue.pull_request &&
243+
startsWith(github.event.comment.body, '/stdlib')
244+
245+
# Define the job's steps:
246+
steps:
247+
- name: Remove in-progress label
248+
# Run the step regardless of the outcome of previous steps:
249+
if: always()
250+
# Pin action to full length commit SHA
251+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
252+
with:
253+
github-token: ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}
254+
script: |
255+
try {
256+
await github.rest.issues.removeLabel({
257+
owner: context.repo.owner,
258+
repo: context.repo.repo,
259+
issue_number: context.issue.number,
260+
name: 'bot: In Progress'
261+
})
262+
} catch (error) {
263+
console.log( 'Error removing label:', error );
264+
}

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,54 @@ v = arr.at( -100 );
338338
// returns undefined
339339
```
340340

341+
<a name="method-every"></a>
342+
343+
#### TypedArrayFE.prototype.every( predicate\[, thisArg] )
344+
345+
Tests whether all the elements in an array pass a test implemented by a predicate function.
346+
347+
```javascript
348+
function isNegative( v ) {
349+
return v < 0;
350+
}
351+
352+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
353+
354+
var arr = new Float64ArrayFE( 'little-endian', [ -1.0, -2.0, -3.0, -4.0 ] );
355+
356+
var bool = arr.every( isNegative );
357+
// returns true
358+
```
359+
360+
The invoked function is provided three arguments:
361+
362+
- **value**: current array element.
363+
- **index**: current array element index.
364+
- **arr**: the array on which this method was called.
365+
366+
To set the function execution context, provide a `thisArg`.
367+
368+
```javascript
369+
function isPositive( v, i ) {
370+
this.count += 1;
371+
return v > 0;
372+
}
373+
374+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
375+
376+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, -3.0 ] );
377+
378+
var context = {
379+
'count': 0
380+
};
381+
382+
var bool = arr.every( isPositive, context );
383+
// returns false
384+
385+
var count = context.count;
386+
// returns 3
387+
```
388+
341389
<a name="method-for-each"></a>
342390

343391
#### TypedArrayFE.prototype.forEach( callbackFn\[, thisArg] )
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 isBoolean = require( '@stdlib/assert/is-boolean' );
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+':every', function benchmark( b ) {
37+
var bool;
38+
var arr;
39+
var i;
40+
41+
arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 2.0, 1.0 ] );
42+
43+
b.tic();
44+
for ( i = 0; i < b.iterations; i++ ) {
45+
bool = arr.every( predicate );
46+
if ( typeof bool !== 'boolean' ) {
47+
b.fail( 'should return a boolean' );
48+
}
49+
}
50+
b.toc();
51+
if ( !isBoolean( bool ) ) {
52+
b.fail( 'should return a boolean' );
53+
}
54+
b.pass( 'benchmark finished' );
55+
b.end();
56+
57+
function predicate( v ) {
58+
return v > 0;
59+
}
60+
});
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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( '@stdlib/array/zero-to' );
26+
var isBoolean = require( '@stdlib/assert/is-boolean' );
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+
* Predicate function.
40+
*
41+
* @private
42+
* @param {boolean} value - array element
43+
* @param {NonNegativeInteger} idx - array element index
44+
* @param {TypedArray} arr - array instance
45+
* @returns {boolean} boolean indicating whether a value passes a test
46+
*/
47+
function predicate( value ) {
48+
return value >= 0;
49+
}
50+
51+
/**
52+
* Creates a benchmark function.
53+
*
54+
* @private
55+
* @param {PositiveInteger} len - array length
56+
* @returns {Function} benchmark function
57+
*/
58+
function createBenchmark( len ) {
59+
var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) );
60+
return benchmark;
61+
62+
/**
63+
* Benchmark function.
64+
*
65+
* @private
66+
* @param {Benchmark} b - benchmark instance
67+
*/
68+
function benchmark( b ) {
69+
var bool;
70+
var i;
71+
72+
b.tic();
73+
for ( i = 0; i < b.iterations; i++ ) {
74+
bool = arr.every( predicate );
75+
if ( typeof bool !== 'boolean' ) {
76+
b.fail( 'should return a boolean' );
77+
}
78+
}
79+
b.toc();
80+
if ( !isBoolean( bool ) ) {
81+
b.fail( 'should return a boolean' );
82+
}
83+
b.pass( 'benchmark finished' );
84+
b.end();
85+
}
86+
}
87+
88+
89+
// MAIN //
90+
91+
/**
92+
* Main execution sequence.
93+
*
94+
* @private
95+
*/
96+
function main() {
97+
var len;
98+
var min;
99+
var max;
100+
var f;
101+
var i;
102+
103+
min = 1; // 10^min
104+
max = 6; // 10^max
105+
106+
for ( i = min; i <= max; i++ ) {
107+
len = pow( 10, i );
108+
f = createBenchmark( len );
109+
bench( pkg+':every:len='+len, f );
110+
}
111+
}
112+
113+
main();

0 commit comments

Comments
 (0)