Skip to content

Commit c2f7fb5

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

File tree

6 files changed

+496
-2
lines changed

6 files changed

+496
-2
lines changed
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+
# Workflow name:
20+
name: test_published_package
21+
22+
# Workflow triggers:
23+
on:
24+
# Run workflow on a weekly schedule:
25+
schedule:
26+
# * is a special character in YAML so you have to quote this string
27+
- cron: '9 21 * * 3'
28+
29+
# Run workflow upon completion of `publish` workflow run:
30+
workflow_run:
31+
workflows: ["publish"]
32+
types: [completed]
33+
34+
# Allow workflow to be manually run:
35+
workflow_dispatch:
36+
37+
# Workflow jobs:
38+
jobs:
39+
test-published:
40+
# Define a display name:
41+
name: 'Test running examples of published package'
42+
43+
# Define the type of virtual host machine:
44+
runs-on: ubuntu-latest
45+
46+
# Define environment variables:
47+
env:
48+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
49+
50+
# Run workflow job if `publish` workflow run is successful or when the workflow is manually run:
51+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
52+
53+
# Define the job's steps:
54+
steps:
55+
# Checkout the repository:
56+
- name: 'Checkout repository'
57+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
58+
59+
# Install Node.js:
60+
- name: 'Install Node.js'
61+
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
62+
with:
63+
node-version: 20
64+
timeout-minutes: 5
65+
66+
# Create test directory and run examples:
67+
- name: 'Create test directory and run examples'
68+
run: |
69+
cd ..
70+
mkdir test-published
71+
cd test-published
72+
73+
# Copy example file:
74+
cp $GITHUB_WORKSPACE/examples/index.js .
75+
76+
# Create a minimal package.json
77+
echo '{
78+
"name": "test-published",
79+
"version": "1.0.0",
80+
"main": "index.js",
81+
"dependencies": {}
82+
}' > package.json
83+
84+
# Get package name and modify example file:
85+
PACKAGE_NAME=$(jq -r '.name' $GITHUB_WORKSPACE/package.json)
86+
ESCAPED_PACKAGE_NAME=$(echo "$PACKAGE_NAME" | sed 's/[\/&]/\\&/g')
87+
88+
sed -i "s/require( '.\/..\/lib' )/require( '$ESCAPED_PACKAGE_NAME' )/g" index.js
89+
90+
# Extract and install dependencies:
91+
DEPS=$(grep -oP "require\(\s*'([^']+)'\s*\)" index.js | sed "s/require(\s*'//" | sed "s/'\s*)//" | grep -v "^\.")
92+
for dep in $DEPS; do
93+
npm install $dep --save
94+
done
95+
96+
# Run the example:
97+
node index.js
98+
99+
# Send Slack notification if job fails:
100+
- name: 'Send notification to Slack in case of failure'
101+
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
102+
with:
103+
status: ${{ job.status }}
104+
channel: '#npm-ci'
105+
if: failure()

CHANGELOG.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

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

7-
## Unreleased (2024-11-18)
7+
## Unreleased (2024-11-20)
88

99
<section class="packages">
1010

@@ -20,12 +20,25 @@
2020

2121
##### Features
2222

23+
- [`b34732c`](https://github.com/stdlib-js/stdlib/commit/b34732cf655db60fbc798e12952f88c3edb07eaf) - add `at` method to `array/fixed-endian-factory` [(#3184)](https://github.com/stdlib-js/stdlib/pull/3184)
2324
- [`956a462`](https://github.com/stdlib-js/stdlib/commit/956a4624c788689b1bca285856b987ea3aa32eb6) - add `forEach` method
2425

2526
</section>
2627

2728
<!-- /.features -->
2829

30+
<section class="issues">
31+
32+
##### Closed Issues
33+
34+
This release closes the following issue:
35+
36+
[#3135](https://github.com/stdlib-js/stdlib/issues/3135)
37+
38+
</section>
39+
40+
<!-- /.issues -->
41+
2942
</details>
3043

3144
</section>
@@ -36,12 +49,25 @@
3649

3750
<!-- /.packages -->
3851

52+
<section class="issues">
53+
54+
### Closed Issues
55+
56+
This release closes the following issue:
57+
58+
[#3135](https://github.com/stdlib-js/stdlib/issues/3135)
59+
60+
</section>
61+
62+
<!-- /.issues -->
63+
3964
<section class="contributors">
4065

4166
### Contributors
4267

43-
A total of 1 person contributed to this release. Thank you to this contributor:
68+
A total of 2 people contributed to this release. Thank you to the following contributors:
4469

70+
- Aayush Khanna
4571
- Athan Reines
4672

4773
</section>
@@ -54,6 +80,7 @@ A total of 1 person contributed to this release. Thank you to this contributor:
5480

5581
<details>
5682

83+
- [`b34732c`](https://github.com/stdlib-js/stdlib/commit/b34732cf655db60fbc798e12952f88c3edb07eaf) - **feat:** add `at` method to `array/fixed-endian-factory` [(#3184)](https://github.com/stdlib-js/stdlib/pull/3184) _(by Aayush Khanna, Athan Reines)_
5784
- [`956a462`](https://github.com/stdlib-js/stdlib/commit/956a4624c788689b1bca285856b987ea3aa32eb6) - **feat:** add `forEach` method _(by Athan Reines)_
5885
- [`de1ef8b`](https://github.com/stdlib-js/stdlib/commit/de1ef8ba5e2d7dd1363bdf826572456f49b7895c) - **docs:** fix example _(by Athan Reines)_
5986

fixed-endian-factory/README.md

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

309+
<a name="method-at"></a>
310+
311+
#### TypedArrayFE.prototype.at( i )
312+
313+
Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer positions.
314+
315+
```javascript
316+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
317+
318+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] );
319+
320+
var out = arr.at( 0 );
321+
// returns 1.0
322+
323+
out = arr.at( -1 );
324+
// returns 3.0
325+
```
326+
327+
If provided an out-of-bounds index, the method returns `undefined`.
328+
329+
```javascript
330+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
331+
332+
var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] );
333+
334+
var v = arr.at( 100 );
335+
// returns undefined
336+
337+
v = arr.at( -100 );
338+
// returns undefined
339+
```
340+
309341
<a name="method-for-each"></a>
310342

311343
#### TypedArrayFE.prototype.forEach( callbackFn\[, thisArg] )
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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 isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
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+'::nonnegative_indices:at:endianness=little-endian', function benchmark( b ) {
37+
var arr;
38+
var N;
39+
var v;
40+
var i;
41+
42+
arr = [];
43+
for ( i = 0; i < 10; i++ ) {
44+
arr.push( i );
45+
}
46+
arr = new Float64ArrayFE( 'little-endian', arr );
47+
N = arr.length;
48+
49+
b.tic();
50+
for ( i = 0; i < b.iterations; i++ ) {
51+
v = arr.at( i % N );
52+
if ( typeof v !== 'number' ) {
53+
b.fail( 'should return a number' );
54+
}
55+
}
56+
b.toc();
57+
if ( !isNumber( v ) ) {
58+
b.fail( 'should return a number' );
59+
}
60+
b.pass( 'benchmark finished' );
61+
b.end();
62+
});
63+
64+
bench( pkg+'::negative_indices:at:endianness=little-endian', function benchmark( b ) {
65+
var arr;
66+
var N;
67+
var v;
68+
var i;
69+
70+
arr = [];
71+
for ( i = 0; i < 10; i++ ) {
72+
arr.push( i );
73+
}
74+
arr = new Float64ArrayFE( 'little-endian', arr );
75+
N = arr.length;
76+
77+
b.tic();
78+
for ( i = 0; i < b.iterations; i++ ) {
79+
v = arr.at( -( i % N ) - 1 );
80+
if ( typeof v !== 'number' ) {
81+
b.fail( 'should return a number' );
82+
}
83+
}
84+
b.toc();
85+
if ( !isNumber( v ) ) {
86+
b.fail( 'should return a number' );
87+
}
88+
b.pass( 'benchmark finished' );
89+
b.end();
90+
});
91+
92+
bench( pkg+'::nonnegative_indices:at:endianness=big-endian', function benchmark( b ) {
93+
var arr;
94+
var N;
95+
var v;
96+
var i;
97+
98+
arr = [];
99+
for ( i = 0; i < 1000; i++ ) {
100+
arr.push( i );
101+
}
102+
arr = new Float64ArrayFE( 'big-endian', arr );
103+
N = arr.length;
104+
105+
b.tic();
106+
for ( i = 0; i < b.iterations; i++ ) {
107+
v = arr.at( i % N );
108+
if ( typeof v !== 'number' ) {
109+
b.fail( 'should return a number' );
110+
}
111+
}
112+
b.toc();
113+
if ( !isNumber( v ) ) {
114+
b.fail( 'should return a number' );
115+
}
116+
b.pass( 'benchmark finished' );
117+
b.end();
118+
});
119+
120+
bench( pkg+'::negative_indices:at:endianness=big-endian', function benchmark( b ) {
121+
var arr;
122+
var N;
123+
var v;
124+
var i;
125+
126+
arr = [];
127+
for ( i = 0; i < 1000; i++ ) {
128+
arr.push( i );
129+
}
130+
arr = new Float64ArrayFE( 'big-endian', arr );
131+
N = arr.length;
132+
133+
b.tic();
134+
for ( i = 0; i < b.iterations; i++ ) {
135+
v = arr.at( -( i % N ) - 1 );
136+
if ( typeof v !== 'number' ) {
137+
b.fail( 'should return a number' );
138+
}
139+
}
140+
b.toc();
141+
if ( !isNumber( v ) ) {
142+
b.fail( 'should return a number' );
143+
}
144+
b.pass( 'benchmark finished' );
145+
b.end();
146+
});

0 commit comments

Comments
 (0)