From b6e797284e957b89849984513284943f6392f306 Mon Sep 17 00:00:00 2001 From: Divit Date: Wed, 5 Aug 2026 08:39:30 +0000 Subject: [PATCH 001/114] chore: clean up get method benchmark --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/benchmark/benchmark.get.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.get.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.get.js index bee09657497b..def833746eb2 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.get.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.get.js @@ -36,8 +36,7 @@ bench( format( '%s:get', pkg ), function benchmark( b ) { var v; var i; - arr = zeroTo( 10, 'generic' ); - arr = new Uint64Array( arr ); + arr = new Uint64Array( zeroTo( 10, 'generic' ) ); N = arr.length; b.tic(); From dc46acabdae544b7328c60b82bb82a6efab65ab7 Mon Sep 17 00:00:00 2001 From: Divit Date: Wed, 5 Aug 2026 08:48:06 +0000 Subject: [PATCH 002/114] feat: add method copywithin --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index 684cb8e4b9bd..846250a8e16c 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -597,6 +597,46 @@ setReadOnlyAccessor( Uint64Array.prototype, 'byteOffset', function get() { */ setReadOnly( Uint64Array.prototype, 'BYTES_PER_ELEMENT', Uint64Array.BYTES_PER_ELEMENT ); +/** +* Copies a sequence of elements within the array to the position starting at `target`. +* +* @name copyWithin +* @memberof Uint64Array.prototype +* @type {Function} +* @param {integer} target - index at which to start copying elements +* @param {integer} start - source index at which to copy elements from +* @param {integer} [end] - source index at which to stop copying elements from +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @returns {Uint64Array} modified array +* +* @example +* var Uint64 = require( '@stdlib/number/uint64/ctor' ); +* +* var arr = new Uint64Array( 4 ); +* +* // Set the array elements: +* arr.set( 1, 0 ); +* arr.set( 2, 1 ); +* arr.set( 3, 2 ); +* arr.set( 4, 3 ); +* +* // Copy the first two elements to the last two elements: +* arr.copyWithin( 2, 0, 2 ); +* // arr => [ 1n, 2n, 1n, 2n ] +*/ +setReadOnly( Uint64Array.prototype, 'copyWithin', function copyWithin( target, start ) { + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + // FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled + if ( arguments.length === 2 ) { + this._buffer.copyWithin( target*2, start*2 ); + } else { + this._buffer.copyWithin( target*2, start*2, arguments[2]*2 ); + } + return this; +}); + /** * Returns an iterator for iterating over array key-value pairs. * From f7af12e39f6379d47579a087e9a12d47b772ed1c Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 10 Aug 2026 13:14:05 +0000 Subject: [PATCH 003/114] test: add test for copywithin --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/test/test.copy_within.js | 257 ++++++++++++++++++ 1 file changed, 257 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.copy_within.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.copy_within.js b/lib/node_modules/@stdlib/array/uint64/test/test.copy_within.js new file mode 100644 index 000000000000..d1d4ce4b4918 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.copy_within.js @@ -0,0 +1,257 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var Uint64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `copyWithin` method for copying a sequence of array elements within a 64-bit unsigned integer array', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'copyWithin' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.copyWithin ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.copyWithin.call( value, 3, 0 ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance (end)', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.copyWithin.call( value, 3, 0, 5 ); + }; + } +}); + +tape( 'the method copies a sequence of elements within an array', function test( t ) { + var arr; + + arr = new Uint64Array( [ 0, 1, 2, 3, 4 ] ); + + arr.copyWithin( 0, 3 ); + + // Overwritten: + t.strictEqual( isEqual( arr.get( 0 ), new Uint64( 3 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 1 ), new Uint64( 4 ) ), true, 'returns expected value' ); + + // Remain the same: + t.strictEqual( isEqual( arr.get( 2 ), new Uint64( 2 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 3 ), new Uint64( 3 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 4 ), new Uint64( 4 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (negative target)', function test( t ) { + var arr; + + arr = new Uint64Array( [ 0, 1, 2, 3, 4 ] ); + + arr.copyWithin( -arr.length, 3 ); + + // Overwritten: + t.strictEqual( isEqual( arr.get( 0 ), new Uint64( 3 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 1 ), new Uint64( 4 ) ), true, 'returns expected value' ); + + // Remain the same: + t.strictEqual( isEqual( arr.get( 2 ), new Uint64( 2 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 3 ), new Uint64( 3 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 4 ), new Uint64( 4 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (negative start)', function test( t ) { + var arr; + + arr = new Uint64Array( [ 0, 1, 2, 3, 4 ] ); + + arr.copyWithin( 0, -2 ); + + // Overwritten: + t.strictEqual( isEqual( arr.get( 0 ), new Uint64( 3 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 1 ), new Uint64( 4 ) ), true, 'returns expected value' ); + + // Remain the same: + t.strictEqual( isEqual( arr.get( 2 ), new Uint64( 2 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 3 ), new Uint64( 3 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 4 ), new Uint64( 4 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (end=length)', function test( t ) { + var arr; + + arr = new Uint64Array( [ 0, 1, 2, 3, 4 ] ); + + arr.copyWithin( 0, 3, arr.length ); + + // Overwritten: + t.strictEqual( isEqual( arr.get( 0 ), new Uint64( 3 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 1 ), new Uint64( 4 ) ), true, 'returns expected value' ); + + // Remain the same: + t.strictEqual( isEqual( arr.get( 2 ), new Uint64( 2 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 3 ), new Uint64( 3 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 4 ), new Uint64( 4 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (non-inclusive end)', function test( t ) { + var arr; + + arr = new Uint64Array( [ 0, 1, 2, 3, 4 ] ); + + arr.copyWithin( 2, 0, 2 ); + + // Remain the same: + t.strictEqual( isEqual( arr.get( 0 ), new Uint64( 0 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 1 ), new Uint64( 1 ) ), true, 'returns expected value' ); + + // Overwritten: + t.strictEqual( isEqual( arr.get( 2 ), new Uint64( 0 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 3 ), new Uint64( 1 ) ), true, 'returns expected value' ); + + // Remain the same: + t.strictEqual( isEqual( arr.get( 4 ), new Uint64( 4 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (negative end)', function test( t ) { + var arr; + + arr = new Uint64Array( [ 0, 1, 2, 3, 4 ] ); + + arr.copyWithin( 2, 0, -3 ); + + // Remain the same: + t.strictEqual( isEqual( arr.get( 0 ), new Uint64( 0 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 1 ), new Uint64( 1 ) ), true, 'returns expected value' ); + + // Overwritten: + t.strictEqual( isEqual( arr.get( 2 ), new Uint64( 0 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 3 ), new Uint64( 1 ) ), true, 'returns expected value' ); + + // Remain the same: + t.strictEqual( isEqual( arr.get( 4 ), new Uint64( 4 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (target >= length)', function test( t ) { + var arr; + + arr = new Uint64Array( [ 0, 1, 2, 3, 4 ] ); + + arr.copyWithin( arr.length, 3 ); + + // Remain the same: + t.strictEqual( isEqual( arr.get( 0 ), new Uint64( 0 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 1 ), new Uint64( 1 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 2 ), new Uint64( 2 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 3 ), new Uint64( 3 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 4 ), new Uint64( 4 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method copies a sequence of elements within an array (target > start)', function test( t ) { + var arr; + + arr = new Uint64Array( [ 0, 1, 2, 3, 4 ] ); + + arr.copyWithin( 2, 0 ); + + // Remain the same: + t.strictEqual( isEqual( arr.get( 0 ), new Uint64( 0 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 1 ), new Uint64( 1 ) ), true, 'returns expected value' ); + + // Overwritten: + t.strictEqual( isEqual( arr.get( 2 ), new Uint64( 0 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 3 ), new Uint64( 1 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( arr.get( 4 ), new Uint64( 2 ) ), true, 'returns expected value' ); + + t.end(); +}); From 8b86e230f23125bf5cec8850d81934b2e427da1e Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 10 Aug 2026 14:47:02 +0000 Subject: [PATCH 004/114] bench: add benchmark for copywithin --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../uint64/benchmark/benchmark.copy_within.js | 53 ++++++++++ .../benchmark/benchmark.copy_within.length.js | 96 +++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.js new file mode 100644 index 000000000000..82553a9d87a5 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:copyWithin', pkg ), function benchmark( b ) { + var arr; + var v; + var i; + + arr = new Uint64Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = i % 128; + arr[ 0 ] = v; + arr = arr.copyWithin( 1, 0 ); + if ( arr[ 0 ] !== v ) { + b.fail( 'unexpected result' ); + } + } + b.toc(); + if ( arr[ 0 ] !== arr[ 0 ] ) { + b.fail( 'should not be NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.length.js new file mode 100644 index 000000000000..756c2f8e5b1d --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.length.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr = new Uint64Array( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = i % 128; + arr[ 0 ] = v; + arr = arr.copyWithin( 1, 0 ); + if ( arr[ 0 ] !== v ) { + b.fail( 'unexpected result' ); + } + } + b.toc(); + if ( arr[ 0 ] !== arr[ 0 ] ) { + b.fail( 'should not be NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:copyWithin:len=%d', pkg, len ), f ); + } +} + +main(); From 99d6449b208c163cdd304737f9e1b0a924662da7 Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 10 Aug 2026 17:10:59 +0000 Subject: [PATCH 005/114] docs: add type definition for copywithin --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../array/uint64/docs/types/index.d.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 78b11c503625..728aec94c08f 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -426,6 +426,31 @@ declare class Uint64Array implements Uint64ArrayInterface { */ at( i: number ): Uint64 | void; + /** + * Copies a sequence of elements within the array to the position starting at `target`. + * + * @param target - index at which to start copying elements + * @param start - source index at which to copy elements from + * @param end - source index at which to stop copying elements from + * @returns modified array + * + * @example + * var Uint64 = require( '@stdlib/number/uint64/ctor' ); + * + * var arr = new Uint64Array( 4 ); + * + * // Set the array elements: + * arr.set( 1, 0 ); + * arr.set( 2, 1 ); + * arr.set( 3, 2 ); + * arr.set( 4, 3 ); + * + * // Copy the first two elements to the last two elements: + * arr.copyWithin( 2, 0, 2 ); + * // arr => [ 1n, 2n, 1n, 2n ] + */ + copyWithin( target: number, start: number, end?: number ): Uint64Array; + /** * Returns an iterator for iterating over array key-value pairs. * From 707235f34b90e12d366daca4a17c3ce5533ab11c Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 10 Aug 2026 17:48:24 +0000 Subject: [PATCH 006/114] docs: add repl text for copywithin --- .../@stdlib/array/uint64/docs/repl.txt | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index c737fc5bf588..46eb50230df5 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -252,6 +252,36 @@ [ 2n ] +{{alias}}.prototype.copyWithin( target, start[, end] ) + Copies a sequence of elements within the array starting at `start` and + ending at `end` (non-inclusive) to the position starting at `target`. + + Parameters + ---------- + target: integer + Target start index position. + + start: integer + Source start index position. + + end: integer (optional) + Source end index position. Default: out.length. + + Returns + ------- + out: Uint64Array + Modified array. + + Examples + -------- + > var arr = new {{alias}}( [ 1, 2, 3, 4 ] ) + [ 1n, 2n, 3n, 4n ] + > arr.copyWithin( 0, 2 ) + [ 3n, 4n, 3n, 4n ] + > var z = arr.get( 0 ) + [ 3n ] + + {{alias}}.prototype.entries() Returns an iterator for iterating over array key-value pairs. From 6f6be3b895b8d58e50a6a5f15105fd9378c3b12a Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 10 Aug 2026 17:56:52 +0000 Subject: [PATCH 007/114] docs: add readme for copywithin --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/README.md | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index 02da19409141..c05a92aac48d 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -278,6 +278,109 @@ u = arr.at( -100 ); // returns undefined ``` + + +#### Uint64Array.prototype.copyWithin( target, start\[, end] ) + +Copies a sequence of elements within the array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. + +```javascript +var Uint64 = require( '@stdlib/number/uint64/ctor' ); + +var arr = new Uint64Array( 4 ); + +// Set the array elements: +arr.set( 1, 0 ); +arr.set( 2, 1 ); +arr.set( 3, 2 ); +arr.set( 4, 3 ); + +// Get the first array element: +var z = arr.get( 0 ); +// returns [ 1n ] + +// Get the second array element: +z = arr.get( 1 ); +// returns [ 2n ] + +// Copy the last two elements to the first two elements: +arr.copyWithin( 0, 2 ); + +// Get the first array element: +z = arr.get( 0 ); +// returns [ 3n ] + +// Get the second array element: +z = arr.get( 1 ); +// returns [ 4n ] +``` + +By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument. + +```javascript +var Uint64 = require( '@stdlib/number/uint64/ctor' ); + +var arr = new Uint64Array( 4 ); + +// Set the array elements: +arr.set( 1, 0 ); +arr.set( 2, 1 ); +arr.set( 3, 2 ); +arr.set( 4, 3 ); + +// Get the third array element: +var z = arr.get( 2 ); +// returns [ 3n ] + +// Get the last array element: +z = arr.get( 3 ); +// returns [ 4n ] + +// Copy the first two elements to the last two elements: +arr.copyWithin( 2, 0, 2 ); + +// Get the third array element: +z = arr.get( 2 ); +// returns [ 1n ] + +// Get the last array element: +z = arr.get( 3 ); +// returns [ 2n ] +``` + +When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example: + +```javascript +var Uint64 = require( '@stdlib/number/uint64/ctor' ); + +var arr = new Uint64Array( 4 ); + +// Set the array elements: +arr.set( 1, 0 ); +arr.set( 2, 1 ); +arr.set( 3, 2 ); +arr.set( 4, 3 ); + +// Get the third array element: +var z = arr.get( 2 ); +// returns [ 3n ] + +// Get the last array element: +z = arr.get( 3 ); +// returns [ 4n ] + +// Copy the first two elements to the last two elements using negative indices: +arr.copyWithin( -2, -4, -2 ); + +// Get the third array element: +z = arr.get( 2 ); +// returns [ 1n ] + +// Get the last array element: +z = arr.get( 3 ); +// returns [ 2n ] +``` + #### Uint64Array.prototype.entries() From 07045e00ece9bc6f1ef98263f5d28d1fba9366db Mon Sep 17 00:00:00 2001 From: Divit Date: Tue, 11 Aug 2026 16:55:40 +0000 Subject: [PATCH 008/114] fix: fix repl file lint error --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/array/uint64/docs/repl.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index 46eb50230df5..8098f50dba68 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -274,8 +274,7 @@ Examples -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4 ] ) - [ 1n, 2n, 3n, 4n ] + > var arr = new {{alias}}( [ 1, 2, 3, 4 ] ); > arr.copyWithin( 0, 2 ) [ 3n, 4n, 3n, 4n ] > var z = arr.get( 0 ) From ff6f5885147772ff95c7e1f5c9de586ccec6e6a3 Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 06:11:23 +0000 Subject: [PATCH 009/114] chore: update exmaples --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/array/uint64/README.md | 8 +------- .../@stdlib/array/uint64/docs/types/index.d.ts | 8 +------- lib/node_modules/@stdlib/array/uint64/lib/main.js | 8 +------- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index c05a92aac48d..eb6a2ed4f384 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -353,13 +353,7 @@ When a `target`, `start`, and/or `end` index is negative, the respective index i ```javascript var Uint64 = require( '@stdlib/number/uint64/ctor' ); -var arr = new Uint64Array( 4 ); - -// Set the array elements: -arr.set( 1, 0 ); -arr.set( 2, 1 ); -arr.set( 3, 2 ); -arr.set( 4, 3 ); +var arr = new Uint64Array( [ 1, 2, 3, 4 ] ); // Get the third array element: var z = arr.get( 2 ); diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 728aec94c08f..0643dba70b4a 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -437,13 +437,7 @@ declare class Uint64Array implements Uint64ArrayInterface { * @example * var Uint64 = require( '@stdlib/number/uint64/ctor' ); * - * var arr = new Uint64Array( 4 ); - * - * // Set the array elements: - * arr.set( 1, 0 ); - * arr.set( 2, 1 ); - * arr.set( 3, 2 ); - * arr.set( 4, 3 ); + * var arr = new Uint64Array( [ 1, 2, 3, 4 ] ); * * // Copy the first two elements to the last two elements: * arr.copyWithin( 2, 0, 2 ); diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index 846250a8e16c..5b0b4eb7125a 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -612,13 +612,7 @@ setReadOnly( Uint64Array.prototype, 'BYTES_PER_ELEMENT', Uint64Array.BYTES_PER_E * @example * var Uint64 = require( '@stdlib/number/uint64/ctor' ); * -* var arr = new Uint64Array( 4 ); -* -* // Set the array elements: -* arr.set( 1, 0 ); -* arr.set( 2, 1 ); -* arr.set( 3, 2 ); -* arr.set( 4, 3 ); +* var arr = new Uint64Array( [ 1, 2, 3, 4 ] ); * * // Copy the first two elements to the last two elements: * arr.copyWithin( 2, 0, 2 ); From 59a7ce67491097e095cae4e3986191edd8a3cc11 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Thu, 24 Sep 2026 04:30:54 +0000 Subject: [PATCH 010/114] bench: improve benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../uint64/benchmark/benchmark.copy_within.js | 18 +++++++++--------- .../benchmark/benchmark.copy_within.length.js | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.js index 82553a9d87a5..d416f14ae33a 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.js @@ -21,6 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var isUint64Array = require( '@stdlib/assert/is-uint64array' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -30,23 +31,22 @@ var Uint64Array = require( './../lib' ); bench( format( '%s:copyWithin', pkg ), function benchmark( b ) { var arr; - var v; + var out; var i; - arr = new Uint64Array( 2 ); + arr = new Uint64Array( 10 ); + // Benchmark worst case scenario (i.e., copying all but one element to an overlapping region)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); + out = arr.copyWithin( 1, 0 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); } } b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); + if ( !isUint64Array( out ) ) { + b.fail( 'should return a Uint64Array' ); } b.pass( 'benchmark finished' ); b.end(); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.length.js index 756c2f8e5b1d..80678f6ca5d2 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.copy_within.length.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var pow = require( '@stdlib/math/base/special/pow' ); +var isUint64Array = require( '@stdlib/assert/is-uint64array' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -47,21 +48,20 @@ function createBenchmark( len ) { * @param {Benchmark} b - benchmark instance */ function benchmark( b ) { - var v; + var out; var i; + // Benchmark worst case scenario (i.e., copying all but one element to an overlapping region)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); + out = arr.copyWithin( 1, 0 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); } } b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); + if ( !isUint64Array( out ) ) { + b.fail( 'should return a Uint64Array' ); } b.pass( 'benchmark finished' ); b.end(); From 60fba4027ef82b6ce2f7268b828286c2cd8ffd8f Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 10 Aug 2026 18:19:49 +0000 Subject: [PATCH 011/114] feat: add implementation for every --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index 5b0b4eb7125a..e39148a36adc 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -736,6 +736,53 @@ setReadOnly( Uint64Array.prototype, 'entries', function entries() { } }); +/** +* Tests whether all elements in an array pass a test implemented by a predicate function. +* +* @name every +* @memberof Uint64Array.prototype +* @type {Function} +* @param {Function} predicate - test function +* @param {*} [thisArg] - predicate function execution context +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @throws {TypeError} first argument must be a function +* @returns {boolean} boolean indicating whether all elements pass a test +* +* @example +* var isEven = require( '@stdlib/assert/is-even' ); +* var Number = require( '@stdlib/number/ctor' ); +* +* function predicate( v ) { +* return ( isEven( Number( v ) ) ); +* } +* +* var arr = new Uint64Array( 3 ); +* +* arr.set( 2, 0 ); +* arr.set( 4, 1 ); +* arr.set( 6, 2 ); +* +* var bool = arr.every( predicate ); +* // returns true +*/ +setReadOnly( Uint64Array.prototype, 'every', function every( predicate, thisArg ) { + var buf; + var i; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + buf = this._buffer; + for ( i = 0; i < this._length; i++ ) { + if ( !predicate.call( thisArg, getUint64( buf, i ), i, this ) ) { + return false; + } + } + return true; +}); + /** * Returns an array element. * From 37a53840f3761250620697ebba24c8c85f428043 Mon Sep 17 00:00:00 2001 From: Divit Date: Tue, 11 Aug 2026 05:34:05 +0000 Subject: [PATCH 012/114] test: add tests for every --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/test/test.every.js | 175 ++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.every.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.every.js b/lib/node_modules/@stdlib/array/uint64/test/test.every.js new file mode 100644 index 000000000000..f7ba72ec53ac --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.every.js @@ -0,0 +1,175 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isEven = require( '@stdlib/assert/is-even' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Number = require( '@stdlib/number/ctor' ); +var Uint64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is an `every` method for returning boolean indicating whether all elements pass a test', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'every' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.every ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.every.call( value, predicate ); + }; + } + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.every( value ); + }; + } +}); + +tape( 'the method returns `true` if operating on an empty 64-bit unsigned integer array', function test( t ) { + var bool; + var arr; + + arr = new Uint64Array(); + bool = arr.every( predicate ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns `true` if all elements pass a test', function test( t ) { + var bool; + var arr; + + arr = new Uint64Array( [ 2, 2, 2, 2 ] ); + bool = arr.every( predicate ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { + var bool; + var arr; + + arr = new Uint64Array( [ 2, 4, 5, 7 ] ); + bool = arr.every( predicate ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var bool; + var ctx; + var arr; + + ctx = { + 'count': 0 + }; + arr = new Uint64Array( [ 2, 4, 6 ] ); + bool = arr.every( predicate, ctx ); + + t.strictEqual( bool, true, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( isEven( Number( v ) ) ); + } +}); From 51cb9decbd8218a46f4d7c10b0b7ed929cb92924 Mon Sep 17 00:00:00 2001 From: Divit Date: Tue, 11 Aug 2026 05:43:40 +0000 Subject: [PATCH 013/114] bench: add benchmarks for every method --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/benchmark/benchmark.every.js | 84 ++++++++++++++ .../benchmark/benchmark.every.length.js | 108 ++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.js new file mode 100644 index 000000000000..927946017bb3 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.js @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var isEven = require( '@stdlib/assert/is-even' ); +var Number = require( '@stdlib/number/ctor' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:every', pkg ), function benchmark( b ) { + var bool; + var arr; + var i; + + arr = new Uint64Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.every( predicate ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +bench( format( '%s::this_context:every', pkg ), function benchmark( b ) { + var bool; + var arr; + var i; + + arr = new Uint64Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.every( predicate, {} ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.length.js new file mode 100644 index 000000000000..3a10c110342c --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.length.js @@ -0,0 +1,108 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var isEven = require( '@stdlib/assert/is-even' ); +var Number = require( '@stdlib/number/ctor' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a boolean indicating whether an array element passes a test. +* +* @private +* @param {*} value - value to test +* @returns {boolean} boolean indicating whether an array element passes a test +*/ +function predicate( value ) { + return ( isEven( Number( value ) ) ); +} + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr = new Uint64Array( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var bool; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.every( predicate ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:every:len=%d', pkg, len ), f ); + } +} + +main(); From 7234b5cadbaaaaa648eca93e5db7c8537bd43586 Mon Sep 17 00:00:00 2001 From: Divit Date: Tue, 11 Aug 2026 05:51:06 +0000 Subject: [PATCH 014/114] docs: add type definition for every method --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../array/uint64/docs/types/index.d.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 0643dba70b4a..454068d66311 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -473,6 +473,32 @@ declare class Uint64Array implements Uint64ArrayInterface { */ entries(): TypedIterator<[number, Uint64]>; + /** + * Tests whether all elements in an array pass a test implemented by a predicate function. + * + * @param predicate - test function + * @param thisArg - execution context + * @returns boolean indicating whether all elements pass a test + * + * @example + * var isEven = require( '@stdlib/assert/is-even' ); + * var Number = require( '@stdlib/number/ctor' ); + * + * function predicate( v ) { + * return ( isEven( Number( v ) ) ); + * } + * + * var arr = new Uint64Array( 3 ); + * + * arr.set( 2, 0 ); + * arr.set( 4, 1 ); + * arr.set( 6, 2 ); + * + * var bool = arr.every( predicate ); + * // returns true + */ + every( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; + /** * Returns an array element. * From 4a950593c3f694066eb8474b17293733af7aa1f3 Mon Sep 17 00:00:00 2001 From: Divit Date: Tue, 11 Aug 2026 06:02:15 +0000 Subject: [PATCH 015/114] docs: add repl text for every method --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/docs/repl.txt | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index 8098f50dba68..a72e82e2cce4 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -304,6 +304,39 @@ true +{{alias}}.prototype.every( predicate[, thisArg] ) + Returns a boolean indicating whether all elements in the array pass a test. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. If a predicate function + returns a truthy value, an array element passes; otherwise, an array + element fails. + + thisArg: any (optional) + Execution context. + + Returns + ------- + bool: boolean + Boolean indicating whether all elements pass the test. + + Examples + -------- + > function predicate( v ) {return({{alias:@stdlib/assert/is-uint64}}(v));}; + > var arr = new {{alias}}( [ 2, 4, 6 ] ) + + > var bool = arr.every( predicate ) + true + + {{alias}}.prototype.get( i ) Returns an array element located at integer position (index) `i`. From 401a6ab6aae8763c64e713d63714c5ade865c6fa Mon Sep 17 00:00:00 2001 From: Divit Date: Tue, 11 Aug 2026 06:08:26 +0000 Subject: [PATCH 016/114] docs: add readme for every method --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/README.md | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index eb6a2ed4f384..7ad0324d9496 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -406,6 +406,64 @@ The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the - **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished. - **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object. + + +#### Uint64Array.prototype.every( predicate\[, thisArg] ) + +Returns a boolean indicating whether all elements pass a test. + +```javascript +var isEven = require( '@stdlib/assert/is-even' ); +var Number = require( '@stdlib/number/ctor' ); + +function predicate( v ) { + return ( isEven( Number( v ) ) ); +} + +var arr = new Uint64Array( 3 ); + +// Set the first three elements: +arr.set( 2, 0 ); +arr.set( 4, 1 ); +arr.set( 6, 2 ); + +// Check whether all elements pass a test: +var bool = arr.every( predicate ); +// returns true +``` + +The `predicate` 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 predicate( v, i ) { + this.count += 1; + return ( i >= 0 ); +} + +var arr = new Uint64Array( 3 ); + +var context = { + 'count': 0 +}; + +// Set the first three elements: +arr.set( 2, 0 ); +arr.set( 4, 1 ); +arr.set( 6, 2 ); + +var bool = arr.every( predicate, context ); +// returns true + +var count = context.count; +// returns 3 +``` + #### Uint64Array.prototype.get( i ) From 7511d36d8b1e6fbda0bf5da450a608ad56b3796c Mon Sep 17 00:00:00 2001 From: Divit Date: Thu, 13 Aug 2026 05:18:26 +0000 Subject: [PATCH 017/114] refactor: use isPrimitive --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/array/uint64/README.md | 2 +- .../@stdlib/array/uint64/benchmark/benchmark.every.js | 2 +- .../@stdlib/array/uint64/benchmark/benchmark.every.length.js | 2 +- lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts | 2 +- lib/node_modules/@stdlib/array/uint64/lib/main.js | 2 +- lib/node_modules/@stdlib/array/uint64/test/test.every.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index 7ad0324d9496..52d6a977c9ae 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -413,7 +413,7 @@ The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the Returns a boolean indicating whether all elements pass a test. ```javascript -var isEven = require( '@stdlib/assert/is-even' ); +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; var Number = require( '@stdlib/number/ctor' ); function predicate( v ) { diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.js index 927946017bb3..abe5a01b96be 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.js @@ -23,7 +23,7 @@ var bench = require( '@stdlib/bench' ); var format = require( '@stdlib/string/format' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isEven = require( '@stdlib/assert/is-even' ); +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; var Number = require( '@stdlib/number/ctor' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.length.js index 3a10c110342c..631980201152 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.length.js @@ -23,7 +23,7 @@ var bench = require( '@stdlib/bench' ); var format = require( '@stdlib/string/format' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isEven = require( '@stdlib/assert/is-even' ); +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; var Number = require( '@stdlib/number/ctor' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 454068d66311..8c3bf2b65502 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -481,7 +481,7 @@ declare class Uint64Array implements Uint64ArrayInterface { * @returns boolean indicating whether all elements pass a test * * @example - * var isEven = require( '@stdlib/assert/is-even' ); + * var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; * var Number = require( '@stdlib/number/ctor' ); * * function predicate( v ) { diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index e39148a36adc..dd2625e94d4d 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -749,7 +749,7 @@ setReadOnly( Uint64Array.prototype, 'entries', function entries() { * @returns {boolean} boolean indicating whether all elements pass a test * * @example -* var isEven = require( '@stdlib/assert/is-even' ); +* var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; * var Number = require( '@stdlib/number/ctor' ); * * function predicate( v ) { diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.every.js b/lib/node_modules/@stdlib/array/uint64/test/test.every.js index f7ba72ec53ac..27db5e4914d3 100644 --- a/lib/node_modules/@stdlib/array/uint64/test/test.every.js +++ b/lib/node_modules/@stdlib/array/uint64/test/test.every.js @@ -22,7 +22,7 @@ var tape = require( 'tape' ); var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isEven = require( '@stdlib/assert/is-even' ); +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; var isFunction = require( '@stdlib/assert/is-function' ); var Number = require( '@stdlib/number/ctor' ); var Uint64Array = require( './../lib' ); From 69bb36513ba8026f99a2ea06e70fc06e757d7e39 Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 06:07:12 +0000 Subject: [PATCH 018/114] chore: update exmaples --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/array/uint64/README.md | 14 ++------------ .../@stdlib/array/uint64/docs/types/index.d.ts | 6 +----- lib/node_modules/@stdlib/array/uint64/lib/main.js | 6 +----- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index 52d6a977c9ae..f9cd4e80e1e2 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -420,12 +420,7 @@ function predicate( v ) { return ( isEven( Number( v ) ) ); } -var arr = new Uint64Array( 3 ); - -// Set the first three elements: -arr.set( 2, 0 ); -arr.set( 4, 1 ); -arr.set( 6, 2 ); +var arr = new Uint64Array( [ 2, 4, 6 ] ); // Check whether all elements pass a test: var bool = arr.every( predicate ); @@ -446,17 +441,12 @@ function predicate( v, i ) { return ( i >= 0 ); } -var arr = new Uint64Array( 3 ); +var arr = new Uint64Array( [ 2, 4, 6 ] ); var context = { 'count': 0 }; -// Set the first three elements: -arr.set( 2, 0 ); -arr.set( 4, 1 ); -arr.set( 6, 2 ); - var bool = arr.every( predicate, context ); // returns true diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 8c3bf2b65502..ee7b2c419fea 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -488,11 +488,7 @@ declare class Uint64Array implements Uint64ArrayInterface { * return ( isEven( Number( v ) ) ); * } * - * var arr = new Uint64Array( 3 ); - * - * arr.set( 2, 0 ); - * arr.set( 4, 1 ); - * arr.set( 6, 2 ); + * var arr = new Uint64Array( [ 2, 4, 6 ] ); * * var bool = arr.every( predicate ); * // returns true diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index dd2625e94d4d..2890a2f566fa 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -756,11 +756,7 @@ setReadOnly( Uint64Array.prototype, 'entries', function entries() { * return ( isEven( Number( v ) ) ); * } * -* var arr = new Uint64Array( 3 ); -* -* arr.set( 2, 0 ); -* arr.set( 4, 1 ); -* arr.set( 6, 2 ); +* var arr = new Uint64Array( [ 2, 4, 6 ] ); * * var bool = arr.every( predicate ); * // returns true From 081e315dc9a6046a8bbc2f876077e87eee9cd5a6 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Thu, 24 Sep 2026 04:36:56 +0000 Subject: [PATCH 019/114] bench: improve benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/benchmark/benchmark.every.js | 15 ++++++++------- .../uint64/benchmark/benchmark.every.length.js | 16 ++++++++-------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.js index abe5a01b96be..83b65c06db2d 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.js @@ -21,10 +21,9 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var format = require( '@stdlib/string/format' ); +var isUint64 = require( '@stdlib/assert/is-uint64' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; -var Number = require( '@stdlib/number/ctor' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -36,8 +35,9 @@ bench( format( '%s:every', pkg ), function benchmark( b ) { var arr; var i; - arr = new Uint64Array( 2 ); + arr = new Uint64Array( 10 ); + // Benchmark worst case scenario (i.e., the predicate passes for every element, so the method cannot exit early)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { bool = arr.every( predicate ); @@ -53,7 +53,7 @@ bench( format( '%s:every', pkg ), function benchmark( b ) { b.end(); function predicate( v ) { - return ( isEven( Number( v ) ) ); + return isUint64( v ); } }); @@ -62,8 +62,9 @@ bench( format( '%s::this_context:every', pkg ), function benchmark( b ) { var arr; var i; - arr = new Uint64Array( 2 ); + arr = new Uint64Array( 10 ); + // Benchmark worst case scenario (i.e., the predicate passes for every element, so the method cannot exit early)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { bool = arr.every( predicate, {} ); @@ -79,6 +80,6 @@ bench( format( '%s::this_context:every', pkg ), function benchmark( b ) { b.end(); function predicate( v ) { - return ( isEven( Number( v ) ) ); + return isUint64( v ); } }); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.length.js index 631980201152..a6a74e1f5649 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.every.length.js @@ -21,11 +21,10 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var format = require( '@stdlib/string/format' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; -var Number = require( '@stdlib/number/ctor' ); var pow = require( '@stdlib/math/base/special/pow' ); +var isUint64 = require( '@stdlib/assert/is-uint64' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -33,14 +32,14 @@ var Uint64Array = require( './../lib' ); // FUNCTIONS // /** -* Returns a boolean indicating whether an array element passes a test. +* Predicate function. * * @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test +* @param {Uint64} value - array element +* @returns {boolean} boolean indicating whether a value passes a test */ function predicate( value ) { - return ( isEven( Number( value ) ) ); + return isUint64( value ); } /** @@ -64,6 +63,7 @@ function createBenchmark( len ) { var bool; var i; + // Benchmark worst case scenario (i.e., the predicate passes for every element, so the method cannot exit early)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { bool = arr.every( predicate ); From 39b26b8f77eccee0f81179f79b4b2336bec84062 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Fri, 23 Oct 2026 05:14:51 +0000 Subject: [PATCH 020/114] chore: add every in fill --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index 2890a2f566fa..0fd30068f472 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -779,6 +779,89 @@ setReadOnly( Uint64Array.prototype, 'every', function every( predicate, thisArg return true; }); +/** +* Returns a modified typed array filled with a fill value. +* +* @name fill +* @memberof Uint64Array.prototype +* @type {Function} +* @param {Uint64|bigint|number} value - fill value +* @param {integer} [start=0] - starting index (inclusive) +* @param {integer} [end] - ending index (exclusive) +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @throws {TypeError} first argument must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer +* @throws {TypeError} second argument must be an integer +* @throws {TypeError} third argument must be an integer +* @returns {Uint64Array} modified array +* +* @example +* var arr = new Uint64Array( 3 ); +* +* arr.fill( 1, 1 ); +* +* var z = arr.get( 1 ); +* // returns [ 1n ] +* +* z = arr.get( 2 ); +* // returns [ 1n ] +*/ +setReadOnly( Uint64Array.prototype, 'fill', function fill( value, start, end ) { + var words; + var buf; + var len; + var idx; + var val; + var i; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + try { + val = new Uint64( value ); + } catch ( err ) { // eslint-disable-line no-unused-vars + throw new TypeError( format( 'invalid argument. First argument must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', value ) ); + } + buf = this._buffer; + len = this._length; + if ( arguments.length > 1 ) { + if ( !isInteger( start ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) ); + } + if ( start < 0 ) { + start += len; + if ( start < 0 ) { + start = 0; + } + } + if ( arguments.length > 2 ) { + if ( !isInteger( end ) ) { + throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) ); + } + if ( end < 0 ) { + end += len; + if ( end < 0 ) { + end = 0; + } + } + if ( end > len ) { + end = len; + } + } else { + end = len; + } + } else { + start = 0; + end = len; + } + words = [ 0, 0 ]; + toWords( val, words, 1, 0 ); + for ( i = start; i < end; i++ ) { + idx = 2*i; + buf[ idx+indices.HIGH ] = words[ 0 ]; + buf[ idx+indices.LOW ] = words[ 1 ]; + } + return this; +}); + /** * Returns an array element. * From d699f54135fe8574e25218dd2bb6788e5ff11260 Mon Sep 17 00:00:00 2001 From: Divit Date: Tue, 11 Aug 2026 18:12:57 +0000 Subject: [PATCH 021/114] chore: add uint64 convertion check --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/array/uint64/lib/main.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index 0fd30068f472..46f2a60bfb06 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -810,15 +810,16 @@ setReadOnly( Uint64Array.prototype, 'fill', function fill( value, start, end ) { var buf; var len; var idx; - var val; var i; if ( !isUint64Array( this ) ) { throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); } - try { - val = new Uint64( value ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. First argument must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', value ) ); + if ( !isUint64( value ) ) { + try { + value = new Uint64( value ); + } catch ( err ) { // eslint-disable-line no-unused-vars + throw new TypeError( format( 'invalid argument. First argument must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', value ) ); + } } buf = this._buffer; len = this._length; @@ -853,7 +854,7 @@ setReadOnly( Uint64Array.prototype, 'fill', function fill( value, start, end ) { end = len; } words = [ 0, 0 ]; - toWords( val, words, 1, 0 ); + toWords( value, words, 1, 0 ); for ( i = start; i < end; i++ ) { idx = 2*i; buf[ idx+indices.HIGH ] = words[ 0 ]; From 22b49b1f295e909d5f634dde1dc800c1e5f6090c Mon Sep 17 00:00:00 2001 From: Divit Date: Wed, 12 Aug 2026 17:10:48 +0000 Subject: [PATCH 022/114] chore: checkpoint --- .../@stdlib/array/uint64/test/test.fill.js | 282 ++++++++++++++++++ 1 file changed, 282 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.fill.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.fill.js b/lib/node_modules/@stdlib/array/uint64/test/test.fill.js new file mode 100644 index 000000000000..7f8701cc2d63 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.fill.js @@ -0,0 +1,282 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var Uint64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `fill` method', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'fill' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.fill ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.fill.call( value, new Uint64( 1 ) ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a nonnegative integer, nonnegative bigint, 64-bit unsigned integer', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + -5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.fill( value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.fill( new Uint64( 1 ), value ); + }; + } +}); + +tape( 'the method throws an error if provided a third argument which is not an integer', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.fill( new Uint64( 1 ), 0, value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty 64-bit unsigned integer array', function test( t ) { + var arr; + var out; + + arr = new Uint64Array(); + out = arr.fill( new Uint64( 1 ) ); + + t.strictEqual( out instanceof Uint64Array, true, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length', function test( t ) { + var arr; + var out; + + arr = new Uint64Array( 10 ); + out = arr.fill( new Uint64( 1 ) ); + + t.strictEqual( out, arr, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { + var expected; + var arr; + + arr = new Uint64Array( 3 ); + expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + arr.fill( new Uint64( 1 ) ); + + t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +// tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { +// var expected; +// var arr; + +// arr = new Uint64Array( 3 ); +// expected = new Float64Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] ); + +// arr.fill( new Uint64( 1.0, 1.0 ), 1 ); + +// t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); +// t.end(); +// }); + +// tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive)', function test( t ) { +// var expected; +// var arr; + +// arr = new Uint64Array( 3 ); +// expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ] ); + +// arr.fill( new Uint64( 1.0, 1.0 ), 0, 2 ); + +// t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); +// t.end(); +// }); + +// tape( 'the method supports negative indices', function test( t ) { +// var expected; +// var arr; + +// arr = new Uint64Array( 3 ); +// expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ] ); + +// arr.fill( new Uint64( 1.0, 1.0 ), -3, -1 ); + +// t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); +// t.end(); +// }); + +// tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { +// var expected; +// var arr; + +// arr = new Uint64Array( 3 ); +// expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + +// arr.fill( new Uint64( 1.0, 1.0 ), -10 ); + +// t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); +// t.end(); +// }); + +// tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive)', function test( t ) { +// var expected; +// var arr; + +// arr = new Uint64Array( 3 ); +// expected = new Float64Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] ); + +// arr.fill( new Uint64( 1.0, 1.0 ), 1, 10 ); + +// t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); +// t.end(); +// }); + +// tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array', function test( t ) { +// var expected; +// var arr; + +// arr = new Uint64Array( 3 ); +// expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// arr.fill( new Uint64( 1.0, 1.0 ), 2, 1 ); + +// t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); +// t.end(); +// }); From 90a1aceb4b452ac0c53a400917eb1c0b060bbd40 Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 05:42:20 +0000 Subject: [PATCH 023/114] chore: update exmaples --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/array/uint64/lib/main.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index 46f2a60bfb06..e64b62e0a20b 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -796,14 +796,10 @@ setReadOnly( Uint64Array.prototype, 'every', function every( predicate, thisArg * * @example * var arr = new Uint64Array( 3 ); +* // returns [ 0n , 0n, 0n ] * -* arr.fill( 1, 1 ); -* -* var z = arr.get( 1 ); -* // returns [ 1n ] -* -* z = arr.get( 2 ); -* // returns [ 1n ] +* arr = arr.fill( 1, 1 ); +* // returns [ 0n, 1n, 1n ] */ setReadOnly( Uint64Array.prototype, 'fill', function fill( value, start, end ) { var words; From e9b6b3055c1e75ae779a582d29a95462e6b5846f Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 05:45:21 +0000 Subject: [PATCH 024/114] bench: add benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/benchmark/benchmark.fill.js | 59 ++++++++++ .../uint64/benchmark/benchmark.fill.length.js | 103 ++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.fill.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.fill.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.fill.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.fill.js new file mode 100644 index 000000000000..57906323120c --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.fill.js @@ -0,0 +1,59 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var isUint64Array = require( '@stdlib/assert/is-uint64array' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:fill', pkg ), function benchmark( b ) { + var values; + var arr; + var out; + var i; + + values = [ + new Uint64( 1 ), + new Uint64( 2 ), + new Uint64( 3 ) + ]; + arr = new Uint64Array( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.fill( values[ i%values.length ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isUint64Array( out ) ) { + b.fail( 'should return a Uint64Array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.fill.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.fill.length.js new file mode 100644 index 000000000000..ca8e0eefc600 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.fill.length.js @@ -0,0 +1,103 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var isUint64Array = require( '@stdlib/assert/is-uint64array' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr = new Uint64Array( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var values; + var out; + var i; + + values = [ + new Uint64( 1 ), + new Uint64( 2 ), + new Uint64( 3 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.fill( values[ i%values.length ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isUint64Array( out ) ) { + b.fail( 'should return a Uint64Array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:fill:len=%d', pkg, len ), f ); + } +} + +main(); From b88cc4b334ba5092685d53419c8fd1c8ec806391 Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 05:48:42 +0000 Subject: [PATCH 025/114] docs: adds type definition --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/docs/types/index.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index ee7b2c419fea..359c5ad4911f 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -495,6 +495,23 @@ declare class Uint64Array implements Uint64ArrayInterface { */ every( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; + /** + * Returns a modified typed array filled with a fill value. + * + * @param value - fill value + * @param start - starting index (inclusive) + * @param end - ending index (exclusive) + * @returns modified typed array + * + * @example + * var arr = new Uint64Array( 3 ); + * // returns [ 0n , 0n, 0n ] + * + * arr = arr.fill( 1, 1 ); + * // returns [ 0n, 1n, 1n ] + */ + fill( value: Uint, start?: number, end?: number ): Uint64Array; + /** * Returns an array element. * From 322b285e8a9400f51bf2caa0efbe6c5e116fb30e Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 05:52:05 +0000 Subject: [PATCH 026/114] docs: adds repl text --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/docs/repl.txt | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index a72e82e2cce4..d8034916b333 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -337,6 +337,34 @@ true +{{alias}}.prototype.fill( value[, start[, end]] ) + Returns a modified typed array filled with a fill value. + + Parameters + ---------- + value: Uint64 + Fill value. + + start: integer (optional) + Start index. If less than zero, the start index is resolved relative to + the last array element. Default: 0. + + end: integer (optional) + End index (non-inclusive). If less than zero, the end index is resolved + relative to the last array element. Default: out.length. + + Returns + ------- + out: Uint64Array + Modified array. + + Examples + -------- + > var arr = new {{alias}}( 3 ); + > arr.fill( 1 ) + [ 1n, 1n, 1n ] + + {{alias}}.prototype.get( i ) Returns an array element located at integer position (index) `i`. From 854dcf052717849c579eef8259358c85df7280be Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 06:03:07 +0000 Subject: [PATCH 027/114] docs: adds readme --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/README.md | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index f9cd4e80e1e2..f7405bfe0f4f 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -454,6 +454,62 @@ var count = context.count; // returns 3 ``` + + +#### Uint64Array.prototype.fill( value\[, start\[, end]] ) + +Returns a modified typed array filled with a fill value. + +```javascript +var Uint64 = require( '@stdlib/number/uint64/ctor' ); + +var arr = new Uint64Array( 3 ); + +// Set all elements to the same value: +arr.fill( new Uint64( 1 ) ); + +var u = arr.get( 0 ); +// returns [ 1n ] + +u = arr.get( 2 ); +// returns [ 1n ] + +// Fill all elements starting from the second element: +arr.fill( new Uint64( 2 ), 1 ); + +u = arr.get( 1 ); +// returns [ 2n ] + +u = arr.get( 2 ); +// returns [ 2n ] + +// Fill all elements from first element until the second-to-last element: +arr.fill( new Uint64( 3 ), 0, 2 ); + +u = arr.get( 0 ); +// returns [ 3n ] + +u = arr.get( 1 ); +// returns [ 3n ] +``` + +When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element. + +```javascript +var Uint64 = require( '@stdlib/number/uint64/ctor' ); + +var arr = new Uint64Array( 3 ); + +// Set all array elements, except the last element, to the same value: +arr.fill( new Uint64( 1 ), 0, -1 ); + +var u = arr.get( 0 ); +// returns [ 1n ] + +u = arr.get( arr.length - 1 ); +// returns [ 0n ] +``` + #### Uint64Array.prototype.get( i ) From 268eeb05e660b4dbf1671915f94abc7f53eead04 Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 06:45:24 +0000 Subject: [PATCH 028/114] feat: adds implementation for filter method --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index e64b62e0a20b..e49dab631f04 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -859,6 +859,56 @@ setReadOnly( Uint64Array.prototype, 'fill', function fill( value, start, end ) { return this; }); +/** +* Returns a new array containing the elements of an array which pass a test implemented by a predicate function. +* +* @name filter +* @memberof Uint64Array.prototype +* @type {Function} +* @param {Function} predicate - test function +* @param {*} [thisArg] - predicate function execution context +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @throws {TypeError} first argument must be a function +* @returns {Uint64Array} 64-bit unsigned integer array +* +* @example +* var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +* var Number = require( '@stdlib/number/ctor' ); +* +* function predicate( v ) { +* return ( isEven( Number( v ) ) ); +* } +* +* var arr = new Uint64Array( [ 1, 2, 3, 4, 5, 6 ] ); +* +* var out = arr.filter( predicate ); +* // returns [ 2n, 4n, 6n ] +* +* var len = out.length; +* // returns 3 +*/ +setReadOnly( Uint64Array.prototype, 'filter', function filter( predicate, thisArg ) { + var buf; + var out; + var i; + var u; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + buf = this._buffer; + out = []; + for ( i = 0; i < this._length; i++ ) { + u = getUint64( buf, i ); + if ( predicate.call( thisArg, u, i, this ) ) { + out.push( u ); + } + } + return new this.constructor( out ); +}); + /** * Returns an array element. * From 2b2a2285e704ad5af92b271569c5780cc36924e5 Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 07:56:34 +0000 Subject: [PATCH 029/114] docs: add tupe definition --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../array/uint64/docs/types/index.d.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 359c5ad4911f..9d4df0da78f0 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -512,6 +512,31 @@ declare class Uint64Array implements Uint64ArrayInterface { */ fill( value: Uint, start?: number, end?: number ): Uint64Array; + /** + * Returns a new array containing the elements of an array which pass a test implemented by a predicate function. + * + * @param predicate - test function + * @param thisArg - execution context + * @returns new array containing elements which pass a test implemented by a predicate function + * + * @example + * var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; + * var Number = require( '@stdlib/number/ctor' ); + * + * function predicate( v ) { + * return ( isEven( Number( v ) ) ); + * } + * + * var arr = new Uint64Array( [ 1, 2, 3, 4, 5, 6 ] ); + * + * var out = arr.filter( predicate ); + * // returns [ 2n, 4n, 6n ] + * + * var len = out.length; + * // returns 3 + */ + filter( predicate: Predicate, thisArg?: ThisParameterType> ): Uint64Array; + /** * Returns an array element. * From 877c3b70817de9ff20fae66bbc31d8abfd2785ae Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 08:01:12 +0000 Subject: [PATCH 030/114] docs: add repl text --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/docs/repl.txt | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index d8034916b333..3ae4898135a9 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -365,6 +365,43 @@ [ 1n, 1n, 1n ] +{{alias}}.prototype.filter( predicate[, thisArg] ) + Returns a new array containing the elements of an array which pass a test + implemented by a predicate function. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + The returned array has the same data type as the host array. + + Parameters + ---------- + predicate: Function + Predicate function which filters array elements. If a predicate function + returns a truthy value, an array element is included in the output + array; otherwise, an array element is not included in the output array. + + thisArg: any (optional) + Execution context. + + Returns + ------- + out: Uint64Array + A new typed array. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/assert/is-even}}( {{alias:@stdlib/number/ctor}}( v ) ) ); }; + > var arr = new {{alias}}( [ 1, 2, 3, 4, 5, 6 ] ); + > var out = arr.filter( predicate ) + returns [ 2n, 4n, 6n ] + > var len = out.length + 3 + + {{alias}}.prototype.get( i ) Returns an array element located at integer position (index) `i`. From 06e265535f611db5a1016aa38965b8a0ab4a100c Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 08:12:57 +0000 Subject: [PATCH 031/114] bench: add benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../uint64/benchmark/benchmark.filter.js | 57 +++++++++ .../benchmark/benchmark.filter.length.js | 113 ++++++++++++++++++ 2 files changed, 170 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.js new file mode 100644 index 000000000000..25f2b3281f6c --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.js @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var isUint64 = require( '@stdlib/assert/is-uint64' ); +var isUint64Array = require( '@stdlib/assert/is-uint64array' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:filter', pkg ), function benchmark( b ) { + var out; + var arr; + var i; + + arr = new Uint64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.filter( predicate ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isUint64Array( out ) ) { + b.fail( 'should return a Uint64Array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isUint64( v ); + } +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.length.js new file mode 100644 index 000000000000..e0c47c0bb1cd --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.length.js @@ -0,0 +1,113 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var Number = require( '@stdlib/number/ctor' ); +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var isUint64Array = require( '@stdlib/assert/is-uint64array' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Predicate function. +* +* @private +* @param {Uint64} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Uint64Array} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate( value ) { + return ( isEven( Number( value ) ) ); +} + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr; + + arr = new Uint64Array( len ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.filter( predicate ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isUint64Array( out ) ) { + b.fail( 'should return a Uint64Array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:filter:len=%d', pkg, len ), f ); + } +} + +main(); From db2e90812efe660e61e1557ab6e350a67ee40bcc Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 08:19:50 +0000 Subject: [PATCH 032/114] docs: add readme --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/README.md | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index f7405bfe0f4f..bfed2261daa8 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -510,6 +510,62 @@ u = arr.get( arr.length - 1 ); // returns [ 0n ] ``` + + +#### Uint64Array.prototype.filter( predicate\[, thisArg] ) + +Returns a new array containing the elements of an array which pass a test implemented by a predicate function. + +```javascript +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); + +function predicate( v ) { + return ( isEven( Number( v ) ) ); +} + +var arr = new Uint64Array( [ 1, 2, 3, 4, 5, 6 ] ); + +var out = arr.filter( predicate ); +// returns [ 2n, 4n, 6n ] + +var len = out.length; +// returns 3 +``` + +The `predicate` 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 +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); + +function predicate( v, i ) { + this.count += 1; + return ( i >= 0 && isEven( Number( v ) ) ); +} + +var arr = new Uint64Array( [ 1, 2, 3, 4, 5, 6 ] ); + +var context = { + 'count': 0 +}; + +var out = arr.filter( predicate, context ); +// returns [ 2n, 4n, 6n ] + +var len = out.length; +// returns 3 + +var count = context.count; +// returns 6 +``` + #### Uint64Array.prototype.get( i ) From a3e71e00a7c1cfdd114b160ca6a9a3127e0f2a98 Mon Sep 17 00:00:00 2001 From: Divit Date: Wed, 9 Sep 2026 16:43:35 +0000 Subject: [PATCH 033/114] bench: update benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../uint64/benchmark/benchmark.filter.js | 37 ++++++++++++++++--- .../benchmark/benchmark.filter.length.js | 9 ++--- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.js index 25f2b3281f6c..bc32b39f0777 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.js @@ -21,9 +21,10 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var format = require( '@stdlib/string/format' ); -var isUint64 = require( '@stdlib/assert/is-uint64' ); +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; var isUint64Array = require( '@stdlib/assert/is-uint64array' ); +var Number = require( '@stdlib/number/ctor' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -31,11 +32,11 @@ var Uint64Array = require( './../lib' ); // MAIN // bench( format( '%s:filter', pkg ), function benchmark( b ) { - var out; var arr; + var out; var i; - arr = new Uint64Array( [ 1, 2, 3, 4, 5, 6 ] ); + arr = new Uint64Array( 2 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -52,6 +53,32 @@ bench( format( '%s:filter', pkg ), function benchmark( b ) { b.end(); function predicate( v ) { - return isUint64( v ); + return ( isEven( Number( v ) ) ); + } +}); + +bench( format( '%s::this_context:filter', pkg ), function benchmark( b ) { + var arr; + var out; + var i; + + arr = new Uint64Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.filter( predicate, {} ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isUint64Array( out ) ) { + b.fail( 'should return a Uint64Array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return ( isEven( Number( v ) ) ); } }); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.length.js index e0c47c0bb1cd..bcc4255d4ba3 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.length.js @@ -21,11 +21,11 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var format = require( '@stdlib/string/format' ); -var Number = require( '@stdlib/number/ctor' ); var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; var isUint64Array = require( '@stdlib/assert/is-uint64array' ); var pow = require( '@stdlib/math/base/special/pow' ); +var Number = require( '@stdlib/number/ctor' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -53,10 +53,7 @@ function predicate( value ) { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var arr; - - arr = new Uint64Array( len ); - + var arr = new Uint64Array( len ); return benchmark; /** From b46aaa6fb92205e6cbd8b6d2265af4569f9f16dd Mon Sep 17 00:00:00 2001 From: Divit Date: Wed, 9 Sep 2026 17:25:24 +0000 Subject: [PATCH 034/114] fix: add isPrimitive --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/array/uint64/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index 3ae4898135a9..6a0467fcbbdf 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -394,7 +394,7 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/assert/is-even}}( {{alias:@stdlib/number/ctor}}( v ) ) ); }; + > function predicate( v ) { return ( {{alias:@stdlib/assert/is-even}}.isPrimitive( {{alias:@stdlib/number/ctor}}( v ) ) ); }; > var arr = new {{alias}}( [ 1, 2, 3, 4, 5, 6 ] ); > var out = arr.filter( predicate ) returns [ 2n, 4n, 6n ] From 9c881e9b9898638bb4b29dd288418daf8cd466e0 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Thu, 24 Sep 2026 16:00:31 +0000 Subject: [PATCH 035/114] bench: improve benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/benchmark/benchmark.filter.js | 13 +++++++------ .../uint64/benchmark/benchmark.filter.length.js | 10 ++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.js index bc32b39f0777..6487efa741e1 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.js @@ -21,9 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var isUint64 = require( '@stdlib/assert/is-uint64' ); var isUint64Array = require( '@stdlib/assert/is-uint64array' ); -var Number = require( '@stdlib/number/ctor' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -36,8 +35,9 @@ bench( format( '%s:filter', pkg ), function benchmark( b ) { var out; var i; - arr = new Uint64Array( 2 ); + arr = new Uint64Array( 10 ); + // Benchmark worst case scenario (i.e., the predicate passes for every element, so every element is copied to the output array)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.filter( predicate ); @@ -53,7 +53,7 @@ bench( format( '%s:filter', pkg ), function benchmark( b ) { b.end(); function predicate( v ) { - return ( isEven( Number( v ) ) ); + return isUint64( v ); } }); @@ -62,8 +62,9 @@ bench( format( '%s::this_context:filter', pkg ), function benchmark( b ) { var out; var i; - arr = new Uint64Array( 2 ); + arr = new Uint64Array( 10 ); + // Benchmark worst case scenario (i.e., the predicate passes for every element, so every element is copied to the output array)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.filter( predicate, {} ); @@ -79,6 +80,6 @@ bench( format( '%s::this_context:filter', pkg ), function benchmark( b ) { b.end(); function predicate( v ) { - return ( isEven( Number( v ) ) ); + return isUint64( v ); } }); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.length.js index bcc4255d4ba3..b68f095a3051 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.filter.length.js @@ -21,10 +21,9 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; -var isUint64Array = require( '@stdlib/assert/is-uint64array' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Number = require( '@stdlib/number/ctor' ); +var isUint64 = require( '@stdlib/assert/is-uint64' ); +var isUint64Array = require( '@stdlib/assert/is-uint64array' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -37,12 +36,10 @@ var Uint64Array = require( './../lib' ); * * @private * @param {Uint64} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Uint64Array} arr - array instance * @returns {boolean} boolean indicating whether a value passes a test */ function predicate( value ) { - return ( isEven( Number( value ) ) ); + return isUint64( value ); } /** @@ -66,6 +63,7 @@ function createBenchmark( len ) { var out; var i; + // Benchmark worst case scenario (i.e., the predicate passes for every element, so every element is copied to the output array)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.filter( predicate ); From 047fd40c08c5cde0b2ca4aa609955a35a165f574 Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 16:16:30 +0000 Subject: [PATCH 036/114] feat: add implementation for find --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index e49dab631f04..92453620ec79 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -909,6 +909,50 @@ setReadOnly( Uint64Array.prototype, 'filter', function filter( predicate, thisAr return new this.constructor( out ); }); +/** +* Returns the first element in an array for which a predicate function returns a truthy value. +* +* @name find +* @memberof Uint64Array.prototype +* @type {Function} +* @param {Function} predicate - test function +* @param {*} [thisArg] - predicate function execution context +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @throws {TypeError} first argument must be a function +* @returns {(Uint64|void)} array element or undefined +* +* @example +* var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +* var Number = require( '@stdlib/number/ctor' ); +* +* function predicate( v ) { +* return ( isEven( Number( v ) ) ); +* } +* +* var arr = new Uint64Array( [ 1, 3, 4, 6 ] ); +* +* var u = arr.find( predicate ); +* // returns [ 4n ] +*/ +setReadOnly( Uint64Array.prototype, 'find', function find( predicate, thisArg ) { + var buf; + var i; + var u; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + buf = this._buffer; + for ( i = 0; i < this._length; i++ ) { + u = getUint64( buf, i ); + if ( predicate.call( thisArg, u, i, this ) ) { + return u; + } + } +}); + /** * Returns an array element. * From 8b8f14b25b4404e77f1da00e245431a0a6348d7f Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 16:44:06 +0000 Subject: [PATCH 037/114] test: adds test for find --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/test/test.find.js | 177 ++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.find.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.find.js b/lib/node_modules/@stdlib/array/uint64/test/test.find.js new file mode 100644 index 000000000000..0e486138edbc --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.find.js @@ -0,0 +1,177 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var isFunction = require( '@stdlib/assert/is-function' ); +var Number = require( '@stdlib/number/ctor' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var Uint64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `find` method', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'find' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.find ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.find.call( value, predicate ); + }; + } + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.find( value ); + }; + } +}); + +tape( 'the method returns `undefined` if operating on an empty 64-bit unsigned integer array', function test( t ) { + var arr; + var u; + + arr = new Uint64Array(); + u = arr.find( predicate ); + + t.strictEqual( u, void 0, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns the first element which passes a test', function test( t ) { + var arr; + var u; + + arr = new Uint64Array( [ 1, 3, 4, 5 ] ); + u = arr.find( predicate ); + + t.strictEqual( isEqual( u, new Uint64( 4 ) ), true, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { + var arr; + var u; + + arr = new Uint64Array( [ 1, 3, 5, 7, 9 ] ); + u = arr.find( predicate ); + + t.strictEqual( u, void 0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var ctx; + var arr; + var u; + + ctx = { + 'count': 0 + }; + arr = new Uint64Array( [ 1, 3, 4, 5 ] ); + u = arr.find( predicate, ctx ); + + t.strictEqual( isEqual( u, new Uint64( 4 ) ), true, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( isEven( Number( v ) ) ); + } +}); From cf0d4bf942cd5b7813b9732660a3292b06ecdd05 Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 16:47:18 +0000 Subject: [PATCH 038/114] test: adds type definition --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../array/uint64/docs/types/index.d.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 9d4df0da78f0..6cff5270d1b1 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -537,6 +537,28 @@ declare class Uint64Array implements Uint64ArrayInterface { */ filter( predicate: Predicate, thisArg?: ThisParameterType> ): Uint64Array; + /** + * Returns the first element in an array for which a predicate function returns a truthy value. + * + * @param predicate - test function + * @param thisArg - execution context + * @returns array element or undefined + * + * @example + * var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; + * var Number = require( '@stdlib/number/ctor' ); + * + * function predicate( v ) { + * return ( isEven( Number( v ) ) ); + * } + * + * var arr = new Uint64Array( [ 1, 3, 4, 6 ] ); + * + * var u = arr.find( predicate ); + * // returns [ 4n ] + */ + find( predicate: Predicate, thisArg?: ThisParameterType> ): Uint64 | void; + /** * Returns an array element. * From a48adaf93ffa969114ec8980d48b397c4f94e1e0 Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 16:51:43 +0000 Subject: [PATCH 039/114] test: adds repl text --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/docs/repl.txt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index 6a0467fcbbdf..138c5a333e78 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -402,6 +402,40 @@ 3 +{{alias}}.prototype.find( predicate[, thisArg] ) + Returns the first element in an array for which a predicate function + returns a truthy value. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If a predicate function never returns a truthy value, the method returns + `undefined`. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. + + thisArg: any (optional) + Execution context. + + Returns + ------- + out: Uint64|void + Array element or `undefined`. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/assert/is-even}}( {{alias:@stdlib/number/ctor}}( v ) ) ); }; + > var arr = new {{alias}}( [ 1, 3, 4, 5 ] ); + > var u = arr.find( predicate ) + [ 4n ] + + {{alias}}.prototype.get( i ) Returns an array element located at integer position (index) `i`. From ada3420e908433c7d7566c39c23d53b75db3475d Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 17:02:08 +0000 Subject: [PATCH 040/114] test: add benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/benchmark/benchmark.find.js | 56 ++++++++ .../uint64/benchmark/benchmark.find.length.js | 120 ++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.js new file mode 100644 index 000000000000..8abb445c51c1 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isUint64 = require( '@stdlib/assert/is-uint64' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:find', pkg ), function benchmark( b ) { + var arr; + var u; + var i; + + arr = new Uint64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + u = arr.find( predicate ); + if ( typeof u !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isUint64( u ) ) { + b.fail( 'should return a 64-bit unsigned integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isUint64( v ); + } +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.length.js new file mode 100644 index 000000000000..a5f5cc3afe6c --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.length.js @@ -0,0 +1,120 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var isUint64 = require( '@stdlib/assert/is-uint64' ); +var Number = require( '@stdlib/number/ctor' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Predicate function. +* +* @private +* @param {Uint64} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Uint64Array} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate( value ) { + return ( isEven( Number( value ) ) ); +} + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr; + var i; + + arr = []; + for ( i = 0; i < len-1; i++ ) { + arr.push( new Uint64( i ) ); + } + arr.push( new Uint64( len-1 ) ); + arr = new Uint64Array( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var u; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + u = arr.find( predicate ); + if ( typeof u !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isUint64( u ) ) { + b.fail( 'should return a 64-bit unsigned integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:find:len=%d', pkg, len ), f ); + } +} + +main(); From 52f5a38dc1d47ddc617664a9a1e475d60e2dfce9 Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 17:06:45 +0000 Subject: [PATCH 041/114] docs: add readme --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/README.md | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index bfed2261daa8..b6cd637b482f 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -566,6 +566,56 @@ var count = context.count; // returns 6 ``` + + +#### Uint64Array.prototype.find( predicate\[, thisArg] ) + +Returns the first element in an array for which a predicate function returns a truthy value. + +```javascript +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); + +function predicate( v ) { + return ( isEven( Number( v ) ) ); +} + +var arr = new Uint64Array( [ 1, 3, 4, 5 ] ); + +var u = arr.find( predicate ); +// returns [ 4n ] +``` + +The `predicate` 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 +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); + +function predicate( v, i ) { + this.count += 1; + return ( i >= 0 && isEven( Number( v ) ) ); +} + +var arr = new Uint64Array( [ 1, 3, 4, 5 ] ); + +var context = { + 'count': 0 +}; + +var u = arr.find( predicate, context ); +// returns [ 4n] + +var count = context.count; +// returns 3 +``` + #### Uint64Array.prototype.get( i ) From 896874a696f9f61b9fb7b39c1f610786c17966fa Mon Sep 17 00:00:00 2001 From: Divit Date: Wed, 9 Sep 2026 17:17:53 +0000 Subject: [PATCH 042/114] bench: update benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/benchmark/benchmark.find.js | 47 +++++++++++++++---- .../uint64/benchmark/benchmark.find.length.js | 34 +++++--------- 2 files changed, 50 insertions(+), 31 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.js index 8abb445c51c1..33d170f94cd0 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.js @@ -21,7 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var isUint64 = require( '@stdlib/assert/is-uint64' ); +var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -31,26 +32,54 @@ var Uint64Array = require( './../lib' ); bench( format( '%s:find', pkg ), function benchmark( b ) { var arr; - var u; + var out; var i; - arr = new Uint64Array( [ 1, 2, 3, 4, 5, 6 ] ); + arr = new Uint64Array( 2 ); + // Benchmark worst case scenario... b.tic(); for ( i = 0; i < b.iterations; i++ ) { - u = arr.find( predicate ); - if ( typeof u !== 'object' ) { - b.fail( 'should return an object' ); + out = arr.find( predicate ); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); } } b.toc(); - if ( !isUint64( u ) ) { - b.fail( 'should return a 64-bit unsigned integer' ); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); } b.pass( 'benchmark finished' ); b.end(); function predicate( v ) { - return isUint64( v ); + return ( isOdd( Number( v ) ) ); + } +}); + +bench( format( '%s::this_context:find', pkg ), function benchmark( b ) { + var arr; + var out; + var i; + + arr = new Uint64Array( 2 ); + + // Benchmark worst case scenario... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.find( predicate, {} ); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return ( isOdd( Number( v ) ) ); } }); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.length.js index a5f5cc3afe6c..1ec2a0a4018a 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.length.js @@ -21,12 +21,10 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var format = require( '@stdlib/string/format' ); -var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; -var isUint64 = require( '@stdlib/assert/is-uint64' ); -var Number = require( '@stdlib/number/ctor' ); +var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; var pow = require( '@stdlib/math/base/special/pow' ); -var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var Number = require( '@stdlib/number/ctor' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -43,7 +41,7 @@ var Uint64Array = require( './../lib' ); * @returns {boolean} boolean indicating whether a value passes a test */ function predicate( value ) { - return ( isEven( Number( value ) ) ); + return ( isOdd( Number( value ) ) ); } /** @@ -54,16 +52,7 @@ function predicate( value ) { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( new Uint64( i ) ); - } - arr.push( new Uint64( len-1 ) ); - arr = new Uint64Array( arr ); - + var arr = new Uint64Array( len ); return benchmark; /** @@ -73,19 +62,20 @@ function createBenchmark( len ) { * @param {Benchmark} b - benchmark instance */ function benchmark( b ) { - var u; + var out; var i; + // Benchmark worst case scenario... b.tic(); for ( i = 0; i < b.iterations; i++ ) { - u = arr.find( predicate ); - if ( typeof u !== 'object' ) { - b.fail( 'should return an object' ); + out = arr.find( predicate ); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); } } b.toc(); - if ( !isUint64( u ) ) { - b.fail( 'should return a 64-bit unsigned integer' ); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); } b.pass( 'benchmark finished' ); b.end(); From 3ae8cd4fe288d30db6a7c3629c3f6d8558e279ac Mon Sep 17 00:00:00 2001 From: Divit Date: Wed, 9 Sep 2026 17:22:37 +0000 Subject: [PATCH 043/114] fix: add isPrimitive --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/array/uint64/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index 138c5a333e78..dce2a1dcf775 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -430,7 +430,7 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/assert/is-even}}( {{alias:@stdlib/number/ctor}}( v ) ) ); }; + > function predicate( v ) { return ( {{alias:@stdlib/assert/is-even}}.isPrimitive( {{alias:@stdlib/number/ctor}}( v ) ) ); }; > var arr = new {{alias}}( [ 1, 3, 4, 5 ] ); > var u = arr.find( predicate ) [ 4n ] From bc846cfcc847cea4f5f779f6d83e9ac6725885c7 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Thu, 24 Sep 2026 16:33:45 +0000 Subject: [PATCH 044/114] bench: improve benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/benchmark/benchmark.find.js | 26 ++++++++++++------- .../uint64/benchmark/benchmark.find.length.js | 15 ++++++----- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.js index 33d170f94cd0..bba78e6b242a 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.js @@ -21,8 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; -var Number = require( '@stdlib/number/ctor' ); +var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -33,11 +33,14 @@ var Uint64Array = require( './../lib' ); bench( format( '%s:find', pkg ), function benchmark( b ) { var arr; var out; + var v; var i; - arr = new Uint64Array( 2 ); + arr = new Uint64Array( 10 ); - // Benchmark worst case scenario... + v = new Uint64( 1 ); + + // Benchmark worst case scenario (i.e., the predicate never passes, so the method must visit every element)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.find( predicate ); @@ -52,19 +55,22 @@ bench( format( '%s:find', pkg ), function benchmark( b ) { b.pass( 'benchmark finished' ); b.end(); - function predicate( v ) { - return ( isOdd( Number( v ) ) ); + function predicate( u ) { + return isEqual( u, v ); } }); bench( format( '%s::this_context:find', pkg ), function benchmark( b ) { var arr; var out; + var v; var i; - arr = new Uint64Array( 2 ); + arr = new Uint64Array( 10 ); + + v = new Uint64( 1 ); - // Benchmark worst case scenario... + // Benchmark worst case scenario (i.e., the predicate never passes, so the method must visit every element)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.find( predicate, {} ); @@ -79,7 +85,7 @@ bench( format( '%s::this_context:find', pkg ), function benchmark( b ) { b.pass( 'benchmark finished' ); b.end(); - function predicate( v ) { - return ( isOdd( Number( v ) ) ); + function predicate( u ) { + return isEqual( u, v ); } }); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.length.js index 1ec2a0a4018a..2b865eff3136 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find.length.js @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; var pow = require( '@stdlib/math/base/special/pow' ); -var Number = require( '@stdlib/number/ctor' ); +var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); +// VARIABLES // + +var SEARCH_VALUE = new Uint64( 1 ); + + // FUNCTIONS // /** @@ -36,12 +41,10 @@ var Uint64Array = require( './../lib' ); * * @private * @param {Uint64} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Uint64Array} arr - array instance * @returns {boolean} boolean indicating whether a value passes a test */ function predicate( value ) { - return ( isOdd( Number( value ) ) ); + return isEqual( value, SEARCH_VALUE ); } /** @@ -65,7 +68,7 @@ function createBenchmark( len ) { var out; var i; - // Benchmark worst case scenario... + // Benchmark worst case scenario (i.e., the predicate never passes, so the method must visit every element)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.find( predicate ); From 1be63ab558d62d1452c61676380253ddcc01d44e Mon Sep 17 00:00:00 2001 From: Divit Date: Sat, 15 Aug 2026 16:53:35 +0000 Subject: [PATCH 045/114] feat: adds implementation for findIndex --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index 92453620ec79..c39fa8323716 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -953,6 +953,51 @@ setReadOnly( Uint64Array.prototype, 'find', function find( predicate, thisArg ) } }); +/** +* Returns the index of the first element in an array for which a predicate function returns a truthy value. +* +* @name findIndex +* @memberof Uint64Array.prototype +* @type {Function} +* @param {Function} predicate - test function +* @param {*} [thisArg] - predicate function execution context +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @throws {TypeError} first argument must be a function +* @returns {integer} index or -1 +* +* @example +* var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +* var Number = require( '@stdlib/number/ctor' ); +* +* function predicate( v ) { +* return ( isEven( Number( v ) ) ); +* } +* +* var arr = new Uint64Array( [ 1, 3, 4, 6 ] ); +* +* var idx = arr.findIndex( predicate ); +* // returns 2 +*/ +setReadOnly( Uint64Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) { + var buf; + var i; + var u; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + buf = this._buffer; + for ( i = 0; i < this._length; i++ ) { + u = getUint64( buf, i ); + if ( predicate.call( thisArg, u, i, this ) ) { + return i; + } + } + return -1; +}); + /** * Returns an array element. * From 8fc3e880ff2096c244d562bedcb230a1dd09e36c Mon Sep 17 00:00:00 2001 From: Divit Date: Sat, 15 Aug 2026 17:04:31 +0000 Subject: [PATCH 046/114] test: adds test for findIndex --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/test/test.find_index.js | 175 ++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.find_index.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.find_index.js b/lib/node_modules/@stdlib/array/uint64/test/test.find_index.js new file mode 100644 index 000000000000..134622ec12d7 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.find_index.js @@ -0,0 +1,175 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var isFunction = require( '@stdlib/assert/is-function' ); +var Number = require( '@stdlib/number/ctor' ); +var Uint64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `findIndex` method', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'findIndex' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.findIndex ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.findIndex.call( value, predicate ); + }; + } + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.findIndex( value ); + }; + } +}); + +tape( 'the method returns `-1` if operating on an empty 64-bit unsigned integer array', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array(); + idx = arr.findIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns the index of the first element which passes a test', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 3, 4, 6 ] ); + idx = arr.findIndex( predicate ); + + t.strictEqual( idx, 2, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +tape( 'the method returns `-1` if all elements fail a test', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 3, 5, 7 ] ); + idx = arr.findIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var ctx; + var arr; + var idx; + + ctx = { + 'count': 0 + }; + arr = new Uint64Array( [ 1, 3, 4, 6 ] ); + idx = arr.findIndex( predicate, ctx ); + + t.strictEqual( idx, 2, 'returns expected value' ); + t.strictEqual( ctx.count, 3, 'returns expected value' ); + + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( isEven( Number( v ) ) ); + } +}); From bedf1663065bfeac23a9ca928b6b89f87aaf44d0 Mon Sep 17 00:00:00 2001 From: Divit Date: Sat, 15 Aug 2026 17:07:57 +0000 Subject: [PATCH 047/114] docs: adds type definition for findIndex --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../array/uint64/docs/types/index.d.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 6cff5270d1b1..683e60c3ab24 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -559,6 +559,28 @@ declare class Uint64Array implements Uint64ArrayInterface { */ find( predicate: Predicate, thisArg?: ThisParameterType> ): Uint64 | void; + /** + * Returns the index of the first element in an array for which a predicate function returns a truthy value. + * + * @param predicate - test function + * @param thisArg - execution context + * @returns index or -1 + * + * @example + * var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; + * var Number = require( '@stdlib/number/ctor' ); + * + * function predicate( v ) { + * return ( isEven( Number( v ) ) ); + * } + * + * var arr = new Uint64Array( [ 1, 3, 4, 6 ] ); + * + * var idx = arr.findIndex( predicate ); + * // returns 2 + */ + findIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; + /** * Returns an array element. * From 49a6fd3769439bfd542d7c6697790530d3b530f1 Mon Sep 17 00:00:00 2001 From: Divit Date: Sat, 15 Aug 2026 17:13:34 +0000 Subject: [PATCH 048/114] docs: adds repl text for findIndex --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/docs/repl.txt | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index dce2a1dcf775..de0cdacc0ecc 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -436,6 +436,41 @@ [ 4n ] +{{alias}}.prototype.findIndex( predicate[, thisArg] ) + Returns the index of the first element in an array for which a predicate + function returns a truthy value. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If a predicate function never returns a truthy value, the method returns + `-1`. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. + + thisArg: any (optional) + Execution context. + + Returns + ------- + out: integer + Array index or `-1`. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/assert/is-even}}( {{alias:@stdlib/number/ctor}}( v ) ) ); }; + > var arr = new {{alias}}( [ 1, 3, 4, 6 ] ) + [ 1n, 3n, 4n, 6n ] + > var idx = arr.findIndex( predicate ) + 2 + + {{alias}}.prototype.get( i ) Returns an array element located at integer position (index) `i`. From 3b4ba1f829523561baa90d89fc16e4c770323cb5 Mon Sep 17 00:00:00 2001 From: Divit Date: Sat, 15 Aug 2026 17:24:26 +0000 Subject: [PATCH 049/114] bench: add benchmarks for findIndex --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../uint64/benchmark/benchmark.find_index.js | 57 +++++++++ .../benchmark/benchmark.find_index.length.js | 113 ++++++++++++++++++ 2 files changed, 170 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.js new file mode 100644 index 000000000000..ba8c4bfea2f6 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.js @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var isUint64 = require( '@stdlib/assert/is-uint64' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:findIndex', pkg ), function benchmark( b ) { + var arr; + var idx; + var i; + + arr = new Uint64Array( [ 1, 2, 3, 4, 5, 6 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.findIndex( predicate ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isUint64( v ); + } +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js new file mode 100644 index 000000000000..410d3bf06d81 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js @@ -0,0 +1,113 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2023 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 format = require( '@stdlib/string/format' ); +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Predicate function. +* +* @private +* @param {Uint64} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Uint64Array} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate( value ) { + return ( isEven( Number( value ) ) ); +} + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr; + + arr = new Uint64Array( len ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var idx; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + idx = arr.findIndex( predicate ); + if ( typeof idx !== 'number' ) { + b.fail( 'should return an integer' ); + } + } + b.toc(); + if ( !isInteger( idx ) ) { + b.fail( 'should return an integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:findIndex:len=%d', pkg, len ), f ); + } +} + +main(); From d9ad8f4f1ffd68c95a6b6b483006d57c3e719f2a Mon Sep 17 00:00:00 2001 From: Divit Date: Sat, 15 Aug 2026 17:28:38 +0000 Subject: [PATCH 050/114] docs: adds readme for findIndex --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/README.md | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index b6cd637b482f..491de10a21be 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -616,6 +616,56 @@ var count = context.count; // returns 3 ``` + + +#### Uint64Array.prototype.findIndex( predicate\[, thisArg] ) + +Returns the index of the first element in an array for which a predicate function returns a truthy value. + +```javascript +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); + +function predicate( v ) { + return ( isEven( Number( v ) ) ); +} + +var arr = new Uint64Array( [ 1, 3, 4, 6 ] ); + +var idx = arr.findIndex( predicate ); +// returns 2 +``` + +The `predicate` 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 +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); + +function predicate( v, i ) { + this.count += 1; + return ( i >= 0 && isEven( Number( v ) ) ); +} + +var arr = new Uint64Array( [ 1, 3, 5, 7 ] ); + +var context = { + 'count': 0 +}; + +var idx = arr.findIndex( predicate, context ); +// returns -1 + +var count = context.count; +// returns 4 +``` + #### Uint64Array.prototype.get( i ) From cbe88165bcfaeb5dde61012eac8b2678224f3645 Mon Sep 17 00:00:00 2001 From: Divit Date: Sat, 15 Aug 2026 17:30:47 +0000 Subject: [PATCH 051/114] fix: update copy right years --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/benchmark/benchmark.find_index.length.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js index 410d3bf06d81..699d43d0765d 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* Copyright (c) 2026 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. From da58a04c9bc63784e73726b8519de00d2a7d0187 Mon Sep 17 00:00:00 2001 From: Divit Date: Wed, 9 Sep 2026 17:06:23 +0000 Subject: [PATCH 052/114] bench: update benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../uint64/benchmark/benchmark.find_index.js | 48 +++++++++++++++---- .../benchmark/benchmark.find_index.length.js | 27 +++++------ 2 files changed, 50 insertions(+), 25 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.js index ba8c4bfea2f6..c0259aa629ab 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.js @@ -21,9 +21,9 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); var format = require( '@stdlib/string/format' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var isUint64 = require( '@stdlib/assert/is-uint64' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -32,26 +32,54 @@ var Uint64Array = require( './../lib' ); bench( format( '%s:findIndex', pkg ), function benchmark( b ) { var arr; - var idx; + var out; var i; - arr = new Uint64Array( [ 1, 2, 3, 4, 5, 6 ] ); + arr = new Uint64Array( 2 ); + // Benchmark worst case scenario... b.tic(); for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); + out = arr.findIndex( predicate ); + if ( out !== -1 ) { + b.fail( 'should return -1' ); } } b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); + if ( out !== -1 ) { + b.fail( 'should return -1' ); } b.pass( 'benchmark finished' ); b.end(); function predicate( v ) { - return isUint64( v ); + return ( isOdd( Number( v ) ) ); + } +}); + +bench( format( '%s::this_context:findIndex', pkg ), function benchmark( b ) { + var arr; + var out; + var i; + + arr = new Uint64Array( 2 ); + + // Benchmark worst case scenario... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.findIndex( predicate, {} ); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + } + b.toc(); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return ( isOdd( Number( v ) ) ); } }); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js index 699d43d0765d..1fd8460c264b 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js @@ -21,11 +21,10 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var format = require( '@stdlib/string/format' ); -var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var Number = require( '@stdlib/number/ctor' ); +var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; var pow = require( '@stdlib/math/base/special/pow' ); +var Number = require( '@stdlib/number/ctor' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -42,7 +41,7 @@ var Uint64Array = require( './../lib' ); * @returns {boolean} boolean indicating whether a value passes a test */ function predicate( value ) { - return ( isEven( Number( value ) ) ); + return ( isOdd( Number( value ) ) ); } /** @@ -53,10 +52,7 @@ function predicate( value ) { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var arr; - - arr = new Uint64Array( len ); - + var arr = new Uint64Array( len ); return benchmark; /** @@ -66,19 +62,20 @@ function createBenchmark( len ) { * @param {Benchmark} b - benchmark instance */ function benchmark( b ) { - var idx; + var out; var i; + // Benchmark worst case scenario... b.tic(); for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); + out = arr.findIndex( predicate ); + if ( out !== -1 ) { + b.fail( 'should return -1' ); } } b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); + if ( out !== -1 ) { + b.fail( 'should return -1' ); } b.pass( 'benchmark finished' ); b.end(); From 749aeadae0b28d1d25b37b7026add225771725e9 Mon Sep 17 00:00:00 2001 From: Divit Date: Wed, 9 Sep 2026 17:24:28 +0000 Subject: [PATCH 053/114] fix: add isPrimitive --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/array/uint64/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index de0cdacc0ecc..e227305d14f8 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -464,7 +464,7 @@ Examples -------- - > function predicate( v ) { return ( {{alias:@stdlib/assert/is-even}}( {{alias:@stdlib/number/ctor}}( v ) ) ); }; + > function predicate( v ) { return ( {{alias:@stdlib/assert/is-even}}.isPrimitive( {{alias:@stdlib/number/ctor}}( v ) ) ); }; > var arr = new {{alias}}( [ 1, 3, 4, 6 ] ) [ 1n, 3n, 4n, 6n ] > var idx = arr.findIndex( predicate ) From 98136ccb9ceeaf74270d3b87df9359baf069a321 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Thu, 24 Sep 2026 16:36:29 +0000 Subject: [PATCH 054/114] bench: improve benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../uint64/benchmark/benchmark.find_index.js | 26 ++++++++++++------- .../benchmark/benchmark.find_index.length.js | 15 ++++++----- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.js index c0259aa629ab..c96ab5efbe29 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.js @@ -21,8 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; -var Number = require( '@stdlib/number/ctor' ); +var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -33,11 +33,14 @@ var Uint64Array = require( './../lib' ); bench( format( '%s:findIndex', pkg ), function benchmark( b ) { var arr; var out; + var v; var i; - arr = new Uint64Array( 2 ); + arr = new Uint64Array( 10 ); - // Benchmark worst case scenario... + v = new Uint64( 1 ); + + // Benchmark worst case scenario (i.e., the predicate never passes, so the method must visit every element)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.findIndex( predicate ); @@ -52,19 +55,22 @@ bench( format( '%s:findIndex', pkg ), function benchmark( b ) { b.pass( 'benchmark finished' ); b.end(); - function predicate( v ) { - return ( isOdd( Number( v ) ) ); + function predicate( u ) { + return isEqual( u, v ); } }); bench( format( '%s::this_context:findIndex', pkg ), function benchmark( b ) { var arr; var out; + var v; var i; - arr = new Uint64Array( 2 ); + arr = new Uint64Array( 10 ); + + v = new Uint64( 1 ); - // Benchmark worst case scenario... + // Benchmark worst case scenario (i.e., the predicate never passes, so the method must visit every element)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.findIndex( predicate, {} ); @@ -79,7 +85,7 @@ bench( format( '%s::this_context:findIndex', pkg ), function benchmark( b ) { b.pass( 'benchmark finished' ); b.end(); - function predicate( v ) { - return ( isOdd( Number( v ) ) ); + function predicate( u ) { + return isEqual( u, v ); } }); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js index 1fd8460c264b..bc0299d5f6be 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_index.length.js @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; var pow = require( '@stdlib/math/base/special/pow' ); -var Number = require( '@stdlib/number/ctor' ); +var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); +// VARIABLES // + +var SEARCH_VALUE = new Uint64( 1 ); + + // FUNCTIONS // /** @@ -36,12 +41,10 @@ var Uint64Array = require( './../lib' ); * * @private * @param {Uint64} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Uint64Array} arr - array instance * @returns {boolean} boolean indicating whether a value passes a test */ function predicate( value ) { - return ( isOdd( Number( value ) ) ); + return isEqual( value, SEARCH_VALUE ); } /** @@ -65,7 +68,7 @@ function createBenchmark( len ) { var out; var i; - // Benchmark worst case scenario... + // Benchmark worst case scenario (i.e., the predicate never passes, so the method must visit every element)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.findIndex( predicate ); From 184aeb12de8e97aedc52e916c917f555acb958a8 Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 7 Sep 2026 17:15:34 +0000 Subject: [PATCH 055/114] feat: add implementation for findlast --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index c39fa8323716..c4990ea303b8 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -998,6 +998,50 @@ setReadOnly( Uint64Array.prototype, 'findIndex', function findIndex( predicate, return -1; }); +/** +* Returns the last element in an array for which a predicate function returns a truthy value. +* +* @name findLast +* @memberof Uint64Array.prototype +* @type {Function} +* @param {Function} predicate - test function +* @param {*} [thisArg] - predicate function execution context +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @throws {TypeError} first argument must be a function +* @returns {(Uint64|void)} array element or undefined +* +* @example +* var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +* var Number = require( '@stdlib/number/ctor' ); +* +* function predicate( v ) { +* return ( isEven( Number( v ) ) ); +* } +* +* var arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); +* +* var u = arr.findLast( predicate ); +* // returns [ 4n ] +*/ +setReadOnly( Uint64Array.prototype, 'findLast', function findLast( predicate, thisArg ) { + var buf; + var u; + var i; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + buf = this._buffer; + for ( i = this._length-1; i >= 0; i-- ) { + u = getUint64( buf, i ); + if ( predicate.call( thisArg, u, i, this ) ) { + return u; + } + } +}); + /** * Returns an array element. * From 82ff29fe1d8578e0d050f46c3cd51b78bc94b8d1 Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 7 Sep 2026 17:35:06 +0000 Subject: [PATCH 056/114] test: add test for findlast --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/test/test.find_last.js | 177 ++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.find_last.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.find_last.js b/lib/node_modules/@stdlib/array/uint64/test/test.find_last.js new file mode 100644 index 000000000000..7209e2411ddc --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.find_last.js @@ -0,0 +1,177 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var isFunction = require( '@stdlib/assert/is-function' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var Number = require( '@stdlib/number/ctor' ); +var Uint64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `findLast` method', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'findLast' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.findLast ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.findLast.call( value, predicate ); + }; + } + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.findLast( value ); + }; + } +}); + +tape( 'the method returns `undefined` if operating on an empty 64-bit unsigned integer array', function test( t ) { + var arr; + var u; + + arr = new Uint64Array(); + u = arr.findLast( predicate ); + + t.strictEqual( u, void 0, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns the last element which passes a test', function test( t ) { + var arr; + var u; + + arr = new Uint64Array( [ 1, 2, 3, 4 ] ); + u = arr.findLast( predicate ); + + t.strictEqual( isEqual( u, new Uint64( 4 ) ), true, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { + var arr; + var u; + + arr = new Uint64Array( [ 1, 3, 5 ] ); + u = arr.findLast( predicate ); + + t.strictEqual( u, void 0, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var ctx; + var arr; + var u; + + ctx = { + 'count': 0 + }; + arr = new Uint64Array( [ 1, 2, 3 ] ); + u = arr.findLast( predicate, ctx ); + + t.strictEqual( isEqual( u, new Uint64( 2 ) ), true, 'returns expected value' ); + t.strictEqual( ctx.count, 2, 'returns expected value' ); + + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( isEven( Number( v ) ) ); + } +}); From 69ceb81a3cfa370c0c9077b48a2eb3d8b3d61475 Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 7 Sep 2026 17:43:48 +0000 Subject: [PATCH 057/114] test: add test for findlast --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/test/test.find_last.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.find_last.js b/lib/node_modules/@stdlib/array/uint64/test/test.find_last.js index 7209e2411ddc..3960b34d107f 100644 --- a/lib/node_modules/@stdlib/array/uint64/test/test.find_last.js +++ b/lib/node_modules/@stdlib/array/uint64/test/test.find_last.js @@ -128,7 +128,7 @@ tape( 'the method returns the last element which passes a test', function test( var arr; var u; - arr = new Uint64Array( [ 1, 2, 3, 4 ] ); + arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); u = arr.findLast( predicate ); t.strictEqual( isEqual( u, new Uint64( 4 ) ), true, 'returns expected value' ); @@ -162,10 +162,10 @@ tape( 'the method supports providing an execution context', function test( t ) { ctx = { 'count': 0 }; - arr = new Uint64Array( [ 1, 2, 3 ] ); + arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); u = arr.findLast( predicate, ctx ); - t.strictEqual( isEqual( u, new Uint64( 2 ) ), true, 'returns expected value' ); + t.strictEqual( isEqual( u, new Uint64( 4 ) ), true, 'returns expected value' ); t.strictEqual( ctx.count, 2, 'returns expected value' ); t.end(); From 26a690fc3405738b9cf76fc76d8f0a3f90421686 Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 7 Sep 2026 17:46:40 +0000 Subject: [PATCH 058/114] docs: add docs for findlast --- .../@stdlib/array/uint64/docs/repl.txt | 35 +++++++++++++++++++ .../array/uint64/docs/types/index.d.ts | 22 ++++++++++++ 2 files changed, 57 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index e227305d14f8..6e2aae3655a9 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -471,6 +471,41 @@ 2 +{{alias}}.prototype.findLast( predicate[, thisArg] ) + Returns the last element in an array for which a predicate function returns + a truthy value. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If a predicate function never returns a truthy value, the method returns + `undefined`. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. + + thisArg: any (optional) + Execution context. + + Returns + ------- + out: Uint64|void + Array element or `undefined`. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/assert/is-even}}.isPrimitive( {{alias:@stdlib/number/ctor}}( v ) ) ); }; + > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ) + [ 1n, 2n, 3n, 4n, 5n ] + > var u = arr.findLast( predicate ) + [ 4n ] + + {{alias}}.prototype.get( i ) Returns an array element located at integer position (index) `i`. diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 683e60c3ab24..1e8e080a3bb1 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -581,6 +581,28 @@ declare class Uint64Array implements Uint64ArrayInterface { */ findIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; + /** + * Returns the last element in an array for which a predicate function returns a truthy value. + * + * @param predicate - test function + * @param thisArg - predicate function execution context + * @returns array element or undefined + * + * @example + * var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; + * var Number = require( '@stdlib/number/ctor' ); + * + * function predicate( v ) { + * return ( isEven( Number( v ) ) ); + * } + * + * var arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + * + * var u = arr.findLast( predicate ); + * // returns [ 4n ] + */ + findLast( predicate: Predicate, thisArg?: ThisParameterType> ): Uint64 | void; + /** * Returns an array element. * From 9e7f3d9439af0b9e5f2dc44c319a47184d80f9bd Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 7 Sep 2026 17:57:35 +0000 Subject: [PATCH 059/114] bench: add benchmakrs for findlast --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../uint64/benchmark/benchmark.find_last.js | 58 +++++++++ .../benchmark/benchmark.find_last.length.js | 114 ++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.js new file mode 100644 index 000000000000..c8ff795c2f59 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.js @@ -0,0 +1,58 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var isUint64 = require( '@stdlib/assert/is-uint64' ); +var Number = require( '@stdlib/number/ctor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:findLast', pkg ), function benchmark( b ) { + var arr; + var u; + var i; + + arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + u = arr.findLast( predicate ); + if ( typeof u !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isUint64( u ) ) { + b.fail( 'should return a 64-bit unsigned integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.length.js new file mode 100644 index 000000000000..ffb4e8579298 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.length.js @@ -0,0 +1,114 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var isUint64 = require( '@stdlib/assert/is-uint64' ); +var Number = require( '@stdlib/number/ctor' ); +var format = require( '@stdlib/string/format' ); +var zeroTo = require( '@stdlib/array/zero-to' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Predicate function. +* +* @private +* @param {Uint64} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Uint64Array} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test +*/ +function predicate( value ) { + return ( isEven( Number( value ) ) ); +} + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr; + + arr = new Uint64Array( zeroTo( len, 'generic' ) ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var u; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + u = arr.findLast( predicate ); + if ( typeof u !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isUint64( u ) ) { + b.fail( 'should return a 64-bit unsigned integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:findLast:len=%d', pkg, len ), f ); + } +} + +main(); From 7c11a354c2160e2689248efb201418192d904110 Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 7 Sep 2026 18:00:52 +0000 Subject: [PATCH 060/114] docs: add readme for findlast --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/README.md | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index 491de10a21be..0f97d7de24ab 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -666,6 +666,58 @@ var count = context.count; // returns 4 ``` + + +#### Uint64Array.prototype.findLast( predicate\[, thisArg] ) + +Returns the last element in an array for which a `predicate` function returns a truthy value. + +```javascript +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); + +function predicate( v ) { + return ( isEven( Number( v ) ) ); +} + +var arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + +var u = arr.findLast( predicate ); +// returns [ 4n ] +``` + +The `predicate` 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 +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); + +function predicate( v ) { + this.count += 1; + return ( isEven( Number( v ) ) ); +} + +var arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + +var context = { + 'count': 0 +}; + +var u = arr.findLast( predicate, context ); +// returns [ 4n ] + +var count = context.count; +// returns 2 +``` + +If a `predicate` function never returns a truthy value, the method returns `undefined`. + #### Uint64Array.prototype.get( i ) From 8686079caab580422ab4def93b253a3f0e0ebb13 Mon Sep 17 00:00:00 2001 From: Divit Date: Wed, 9 Sep 2026 17:37:12 +0000 Subject: [PATCH 061/114] bench: update benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../uint64/benchmark/benchmark.find_last.js | 47 +++++++++++++++---- .../benchmark/benchmark.find_last.length.js | 24 ++++------ 2 files changed, 47 insertions(+), 24 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.js index c8ff795c2f59..d0b1fb60731f 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.js @@ -21,8 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; -var isUint64 = require( '@stdlib/assert/is-uint64' ); +var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; var Number = require( '@stdlib/number/ctor' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -33,26 +32,54 @@ var Uint64Array = require( './../lib' ); bench( format( '%s:findLast', pkg ), function benchmark( b ) { var arr; - var u; + var out; var i; - arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + arr = new Uint64Array( 2 ); + // Benchmark worst case scenario... b.tic(); for ( i = 0; i < b.iterations; i++ ) { - u = arr.findLast( predicate ); - if ( typeof u !== 'object' ) { - b.fail( 'should return an object' ); + out = arr.findLast( predicate ); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); } } b.toc(); - if ( !isUint64( u ) ) { - b.fail( 'should return a 64-bit unsigned integer' ); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); } b.pass( 'benchmark finished' ); b.end(); function predicate( v ) { - return ( isEven( Number( v ) ) ); + return ( isOdd( Number( v ) ) ); + } +}); + +bench( format( '%s::this_context:findLast', pkg ), function benchmark( b ) { + var arr; + var out; + var i; + + arr = new Uint64Array( 2 ); + + // Benchmark worst case scenario... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.findLast( predicate, {} ); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + } + b.toc(); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return ( isOdd( Number( v ) ) ); } }); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.length.js index ffb4e8579298..5c3060c09c4b 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.length.js @@ -21,12 +21,10 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; var pow = require( '@stdlib/math/base/special/pow' ); -var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; -var isUint64 = require( '@stdlib/assert/is-uint64' ); var Number = require( '@stdlib/number/ctor' ); var format = require( '@stdlib/string/format' ); -var zeroTo = require( '@stdlib/array/zero-to' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -43,7 +41,7 @@ var Uint64Array = require( './../lib' ); * @returns {boolean} boolean indicating whether a value passes a test */ function predicate( value ) { - return ( isEven( Number( value ) ) ); + return ( isOdd( Number( value ) ) ); } /** @@ -54,10 +52,7 @@ function predicate( value ) { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var arr; - - arr = new Uint64Array( zeroTo( len, 'generic' ) ); - + var arr = new Uint64Array( len ); return benchmark; /** @@ -67,19 +62,20 @@ function createBenchmark( len ) { * @param {Benchmark} b - benchmark instance */ function benchmark( b ) { - var u; + var out; var i; + // Benchmark worst case scenario... b.tic(); for ( i = 0; i < b.iterations; i++ ) { - u = arr.findLast( predicate ); - if ( typeof u !== 'object' ) { - b.fail( 'should return an object' ); + out = arr.findLast( predicate ); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); } } b.toc(); - if ( !isUint64( u ) ) { - b.fail( 'should return a 64-bit unsigned integer' ); + if ( typeof out !== 'undefined' ) { + b.fail( 'should return undefined' ); } b.pass( 'benchmark finished' ); b.end(); From ba661f4d688a9264f7477db5817cde2fd2fe98d7 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Thu, 24 Sep 2026 16:55:45 +0000 Subject: [PATCH 062/114] bench: improve benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../uint64/benchmark/benchmark.find_last.js | 26 ++++++++++++------- .../benchmark/benchmark.find_last.length.js | 15 ++++++----- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.js index d0b1fb60731f..87dff9c2b664 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.js @@ -21,8 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; -var Number = require( '@stdlib/number/ctor' ); +var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -33,11 +33,14 @@ var Uint64Array = require( './../lib' ); bench( format( '%s:findLast', pkg ), function benchmark( b ) { var arr; var out; + var v; var i; - arr = new Uint64Array( 2 ); + arr = new Uint64Array( 10 ); - // Benchmark worst case scenario... + v = new Uint64( 1 ); + + // Benchmark worst case scenario (i.e., the predicate never passes, so the method must visit every element)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.findLast( predicate ); @@ -52,19 +55,22 @@ bench( format( '%s:findLast', pkg ), function benchmark( b ) { b.pass( 'benchmark finished' ); b.end(); - function predicate( v ) { - return ( isOdd( Number( v ) ) ); + function predicate( u ) { + return isEqual( u, v ); } }); bench( format( '%s::this_context:findLast', pkg ), function benchmark( b ) { var arr; var out; + var v; var i; - arr = new Uint64Array( 2 ); + arr = new Uint64Array( 10 ); + + v = new Uint64( 1 ); - // Benchmark worst case scenario... + // Benchmark worst case scenario (i.e., the predicate never passes, so the method must visit every element)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.findLast( predicate, {} ); @@ -79,7 +85,7 @@ bench( format( '%s::this_context:findLast', pkg ), function benchmark( b ) { b.pass( 'benchmark finished' ); b.end(); - function predicate( v ) { - return ( isOdd( Number( v ) ) ); + function predicate( u ) { + return isEqual( u, v ); } }); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.length.js index 5c3060c09c4b..9809cfeb1da8 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last.length.js @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; var pow = require( '@stdlib/math/base/special/pow' ); -var Number = require( '@stdlib/number/ctor' ); +var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); +// VARIABLES // + +var SEARCH_VALUE = new Uint64( 1 ); + + // FUNCTIONS // /** @@ -36,12 +41,10 @@ var Uint64Array = require( './../lib' ); * * @private * @param {Uint64} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Uint64Array} arr - array instance * @returns {boolean} boolean indicating whether a value passes a test */ function predicate( value ) { - return ( isOdd( Number( value ) ) ); + return isEqual( value, SEARCH_VALUE ); } /** @@ -65,7 +68,7 @@ function createBenchmark( len ) { var out; var i; - // Benchmark worst case scenario... + // Benchmark worst case scenario (i.e., the predicate never passes, so the method must visit every element)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.findLast( predicate ); From 4ebde67864f809c4167970053a96ed411e9959b6 Mon Sep 17 00:00:00 2001 From: Divit Date: Tue, 8 Sep 2026 03:53:48 +0000 Subject: [PATCH 063/114] feat: add implementation for findlastIndex --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index c4990ea303b8..da2c5246a266 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -1042,6 +1042,51 @@ setReadOnly( Uint64Array.prototype, 'findLast', function findLast( predicate, th } }); +/** +* Returns the index of the last element in an array for which a predicate function returns a truthy value. +* +* @name findLastIndex +* @memberof Uint64Array.prototype +* @type {Function} +* @param {Function} predicate - test function +* @param {*} [thisArg] - predicate function execution context +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @throws {TypeError} first argument must be a function +* @returns {integer} index or -1 +* +* @example +* var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +* var Number = require( '@stdlib/number/ctor' ); +* +* function predicate( v ) { +* return ( isEven( Number( v ) ) ); +* } +* +* var arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); +* +* var idx = arr.findLastIndex( predicate ); +* // returns 3 +*/ +setReadOnly( Uint64Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) { + var buf; + var u; + var i; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + } + buf = this._buffer; + for ( i = this._length-1; i >= 0; i-- ) { + u = getUint64( buf, i ); + if ( predicate.call( thisArg, u, i, this ) ) { + return i; + } + } + return -1; +}); + /** * Returns an array element. * From dce95c9a8d3d36f85dbaad8be27f7fd01865bb7a Mon Sep 17 00:00:00 2001 From: Divit Date: Tue, 8 Sep 2026 03:58:24 +0000 Subject: [PATCH 064/114] test: add test for findlastIndex --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/test/test.find_last_index.js | 175 ++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.find_last_index.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.find_last_index.js b/lib/node_modules/@stdlib/array/uint64/test/test.find_last_index.js new file mode 100644 index 000000000000..21057fc91da7 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.find_last_index.js @@ -0,0 +1,175 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var isFunction = require( '@stdlib/assert/is-function' ); +var Number = require( '@stdlib/number/ctor' ); +var Uint64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `findLastIndex` method', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'findLastIndex' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.findLastIndex ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.findLastIndex.call( value, predicate ); + }; + } + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.findLastIndex( value ); + }; + } +}); + +tape( 'the method returns `-1` if operating on an empty 64-bit unsigned integer array', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array(); + idx = arr.findLastIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns the index of the last element which passes a test', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + idx = arr.findLastIndex( predicate ); + + t.strictEqual( idx, 3, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +tape( 'the method returns `-1` if all elements fail a test', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 3, 5 ] ); + idx = arr.findLastIndex( predicate ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); + + function predicate( v ) { + return ( isEven( Number( v ) ) ); + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var ctx; + var arr; + var idx; + + ctx = { + 'count': 0 + }; + arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + idx = arr.findLastIndex( predicate, ctx ); + + t.strictEqual( idx, 3, 'returns expected value' ); + t.strictEqual( ctx.count, 2, 'returns expected value' ); + + t.end(); + + function predicate( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return ( isEven( Number( v ) ) ); + } +}); From 78f6978fda5a574c4d03da9ca87df1764405970b Mon Sep 17 00:00:00 2001 From: Divit Date: Tue, 8 Sep 2026 04:01:49 +0000 Subject: [PATCH 065/114] feat: add docs for findlastIndex --- .../@stdlib/array/uint64/docs/repl.txt | 35 +++++++++++++++++++ .../array/uint64/docs/types/index.d.ts | 22 ++++++++++++ 2 files changed, 57 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index 6e2aae3655a9..fcb672711bbc 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -506,6 +506,41 @@ [ 4n ] +{{alias}}.prototype.findLastIndex( predicate[, thisArg] ) + Returns the index of the last element in an array for which a predicate + function returns a truthy value. + + A predicate function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If a predicate function never returns a truthy value, the method returns + `-1`. + + Parameters + ---------- + predicate: Function + Predicate function which tests array elements. + + thisArg: any (optional) + Execution context. + + Returns + ------- + out: integer + Index or `-1`. + + Examples + -------- + > function predicate( v ) { return ( {{alias:@stdlib/assert/is-even}}.isPrimitive( {{alias:@stdlib/number/ctor}}( v ) ) ); }; + > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ) + [ 1n, 2n, 3n, 4n, 5n ] + > var idx = arr.findLastIndex( predicate ) + 3 + + {{alias}}.prototype.get( i ) Returns an array element located at integer position (index) `i`. diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 1e8e080a3bb1..d5aa2122938f 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -603,6 +603,28 @@ declare class Uint64Array implements Uint64ArrayInterface { */ findLast( predicate: Predicate, thisArg?: ThisParameterType> ): Uint64 | void; + /** + * Returns the index of the last element in an array for which a predicate function returns a truthy value. + * + * @param predicate - test function + * @param thisArg - predicate function execution context + * @returns index or -1 + * + * @example + * var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; + * var Number = require( '@stdlib/number/ctor' ); + * + * function predicate( v ) { + * return ( isEven( Number( v ) ) ); + * } + * + * var arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + * + * var idx = arr.findLastIndex( predicate ); + * // returns 3 + */ + findLastIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; + /** * Returns an array element. * From 6fdffa575bc07f0e82de1178b9af0f5b6b36de44 Mon Sep 17 00:00:00 2001 From: Divit Date: Tue, 8 Sep 2026 04:16:32 +0000 Subject: [PATCH 066/114] test: add benchmarks for findlastIndex --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../benchmark/benchmark.find_last_index.js | 85 ++++++++++++++ .../benchmark.find_last_index.length.js | 107 ++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.js new file mode 100644 index 000000000000..1bed18cec7f0 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.js @@ -0,0 +1,85 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:findLastIndex', pkg ), function benchmark( b ) { + var out; + var arr; + var i; + + arr = new Uint64Array( 2 ); + + // Benchmark worst case scenario... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.findLastIndex( predicate ); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + } + b.toc(); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isOdd( Number( v ) ); + } +}); + +bench( format( '%s::this_context:findLastIndex', pkg ), function benchmark( b ) { + var out; + var arr; + var i; + + arr = new Uint64Array( 2 ); + + // Benchmark worst case scenario... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.findLastIndex( predicate, {} ); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + } + b.toc(); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function predicate( v ) { + return isOdd( Number( v ) ); + } +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.length.js new file mode 100644 index 000000000000..17fffc7e70ca --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.length.js @@ -0,0 +1,107 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a boolean indicating whether an array element passes a test. +* +* @private +* @param {*} value - value to test +* @returns {boolean} boolean indicating whether an array element passes a test +*/ +function predicate( value ) { + return isOdd( Number( value ) ); +} + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr = new Uint64Array( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.findLastIndex( predicate ); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + } + b.toc(); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:findLastIndex:len=%d', pkg, len ), f ); + } +} + +main(); From ff1250f38c6e4861d8f0a18dceba1636e44ecf3a Mon Sep 17 00:00:00 2001 From: Divit Date: Tue, 8 Sep 2026 04:18:28 +0000 Subject: [PATCH 067/114] docs: add readme for findlastIndex --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/README.md | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index 0f97d7de24ab..01b9af44cfe9 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -718,6 +718,58 @@ var count = context.count; If a `predicate` function never returns a truthy value, the method returns `undefined`. + + +#### Uint64Array.prototype.findLastIndex( predicate\[, thisArg] ) + +Returns the index of the last element in an array for which a `predicate` function returns a truthy value. + +```javascript +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); + +function predicate( v ) { + return ( isEven( Number( v ) ) ); +} + +var arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + +var idx = arr.findLastIndex( predicate ); +// returns 3 +``` + +The `predicate` 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 +var isEven = require( '@stdlib/assert/is-even' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); + +function predicate( v ) { + this.count += 1; + return ( isEven( Number( v ) ) ); +} + +var arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + +var context = { + 'count': 0 +}; + +var idx = arr.findLastIndex( predicate, context ); +// returns 3 + +var count = context.count; +// returns 2 +``` + +If a `predicate` function never returns a truthy value, the method returns `-1`. + #### Uint64Array.prototype.get( i ) From a794d4adaf54ccf654c447a1b20053cc2d36320d Mon Sep 17 00:00:00 2001 From: Divit Date: Wed, 9 Sep 2026 17:40:58 +0000 Subject: [PATCH 068/114] bench: update benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../uint64/benchmark/benchmark.find_last_index.js | 8 ++++---- .../benchmark/benchmark.find_last_index.length.js | 13 ++++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.js index 1bed18cec7f0..830d4768f311 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.js @@ -31,8 +31,8 @@ var Uint64Array = require( './../lib' ); // MAIN // bench( format( '%s:findLastIndex', pkg ), function benchmark( b ) { - var out; var arr; + var out; var i; arr = new Uint64Array( 2 ); @@ -53,13 +53,13 @@ bench( format( '%s:findLastIndex', pkg ), function benchmark( b ) { b.end(); function predicate( v ) { - return isOdd( Number( v ) ); + return ( isOdd( Number( v ) ) ); } }); bench( format( '%s::this_context:findLastIndex', pkg ), function benchmark( b ) { - var out; var arr; + var out; var i; arr = new Uint64Array( 2 ); @@ -80,6 +80,6 @@ bench( format( '%s::this_context:findLastIndex', pkg ), function benchmark( b ) b.end(); function predicate( v ) { - return isOdd( Number( v ) ); + return ( isOdd( Number( v ) ) ); } }); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.length.js index 17fffc7e70ca..3da0817c479f 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.length.js @@ -21,8 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); var Number = require( '@stdlib/number/ctor' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -32,14 +32,16 @@ var Uint64Array = require( './../lib' ); // FUNCTIONS // /** -* Returns a boolean indicating whether an array element passes a test. +* Predicate function. * * @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test +* @param {Uint64} value - array element +* @param {NonNegativeInteger} idx - array element index +* @param {Uint64Array} arr - array instance +* @returns {boolean} boolean indicating whether a value passes a test */ function predicate( value ) { - return isOdd( Number( value ) ); + return ( isOdd( Number( value ) ) ); } /** @@ -63,6 +65,7 @@ function createBenchmark( len ) { var out; var i; + // Benchmark worst case scenario... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.findLastIndex( predicate ); From f6fca546d02a960c81a1996a193e4a00b574af1d Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Thu, 24 Sep 2026 17:31:24 +0000 Subject: [PATCH 069/114] bench: improve benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../benchmark/benchmark.find_last_index.js | 26 ++++++++++++------- .../benchmark.find_last_index.length.js | 15 ++++++----- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.js index 830d4768f311..1f0163dbaddd 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.js @@ -21,8 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; -var Number = require( '@stdlib/number/ctor' ); +var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); @@ -33,11 +33,14 @@ var Uint64Array = require( './../lib' ); bench( format( '%s:findLastIndex', pkg ), function benchmark( b ) { var arr; var out; + var v; var i; - arr = new Uint64Array( 2 ); + arr = new Uint64Array( 10 ); - // Benchmark worst case scenario... + v = new Uint64( 1 ); + + // Benchmark worst case scenario (i.e., the predicate never passes, so the method must visit every element)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.findLastIndex( predicate ); @@ -52,19 +55,22 @@ bench( format( '%s:findLastIndex', pkg ), function benchmark( b ) { b.pass( 'benchmark finished' ); b.end(); - function predicate( v ) { - return ( isOdd( Number( v ) ) ); + function predicate( u ) { + return isEqual( u, v ); } }); bench( format( '%s::this_context:findLastIndex', pkg ), function benchmark( b ) { var arr; var out; + var v; var i; - arr = new Uint64Array( 2 ); + arr = new Uint64Array( 10 ); + + v = new Uint64( 1 ); - // Benchmark worst case scenario... + // Benchmark worst case scenario (i.e., the predicate never passes, so the method must visit every element)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.findLastIndex( predicate, {} ); @@ -79,7 +85,7 @@ bench( format( '%s::this_context:findLastIndex', pkg ), function benchmark( b ) b.pass( 'benchmark finished' ); b.end(); - function predicate( v ) { - return ( isOdd( Number( v ) ) ); + function predicate( u ) { + return isEqual( u, v ); } }); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.length.js index 3da0817c479f..74892273ac8c 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.find_last_index.length.js @@ -21,14 +21,19 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var isOdd = require( '@stdlib/assert/is-odd' ).isPrimitive; var pow = require( '@stdlib/math/base/special/pow' ); -var Number = require( '@stdlib/number/ctor' ); +var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var Uint64Array = require( './../lib' ); +// VARIABLES // + +var SEARCH_VALUE = new Uint64( 1 ); + + // FUNCTIONS // /** @@ -36,12 +41,10 @@ var Uint64Array = require( './../lib' ); * * @private * @param {Uint64} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Uint64Array} arr - array instance * @returns {boolean} boolean indicating whether a value passes a test */ function predicate( value ) { - return ( isOdd( Number( value ) ) ); + return isEqual( value, SEARCH_VALUE ); } /** @@ -65,7 +68,7 @@ function createBenchmark( len ) { var out; var i; - // Benchmark worst case scenario... + // Benchmark worst case scenario (i.e., the predicate never passes, so the method must visit every element)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = arr.findLastIndex( predicate ); From 2410211e49de2c48abc01a68af54bf6a17056942 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Sun, 20 Sep 2026 13:14:50 +0000 Subject: [PATCH 070/114] feat: add forEach method to array/uint64 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index da2c5246a266..918f95bb3869 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -1087,6 +1087,43 @@ setReadOnly( Uint64Array.prototype, 'findLastIndex', function findLastIndex( pre return -1; }); +/** +* Invokes a function once for each array element. +* +* @name forEach +* @memberof Uint64Array.prototype +* @type {Function} +* @param {Function} fcn - function to invoke +* @param {*} [thisArg] - function invocation context +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @throws {TypeError} first argument must be a function +* +* @example +* function log( v, i ) { +* console.log( '%s: %s', i, v.toString() ); +* } +* +* var arr = new Uint64Array( [ 1, 2, 3 ] ); +* +* arr.forEach( log ); +*/ +setReadOnly( Uint64Array.prototype, 'forEach', function forEach( fcn, thisArg ) { + var buf; + var i; + var v; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + if ( !isFunction( fcn ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + } + buf = this._buffer; + for ( i = 0; i < this._length; i++ ) { + v = getUint64( buf, i ); + fcn.call( thisArg, v, i, this ); + } +}); + /** * Returns an array element. * From abd97db636caafb683aed09a7c916ac531700985 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Sun, 20 Sep 2026 13:24:44 +0000 Subject: [PATCH 071/114] test: add test --- .../array/uint64/test/test.for_each.js | 201 ++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.for_each.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.for_each.js b/lib/node_modules/@stdlib/array/uint64/test/test.for_each.js new file mode 100644 index 000000000000..69ac83d3f213 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.for_each.js @@ -0,0 +1,201 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var isUint64 = require( '@stdlib/assert/is-uint64' ); +var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var Uint64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `forEach` method', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'forEach' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.forEach ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.forEach.call( value, fcn ); + }; + } + + function fcn( v ) { + if ( !isUint64( v ) ) { + t.fail( 'should be a 64-bit unsigned integer' ); + } + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.forEach( value ); + }; + } +}); + +tape( 'the method should not invoke a provided callback function if operating on an empty 64-bit unsigned integer array', function test( t ) { + var arr; + + arr = new Uint64Array(); + arr.forEach( fcn ); + + t.end(); + + function fcn() { + t.fail( 'should not be invoked' ); + } +}); + +tape( 'the method returns `undefined`', function test( t ) { + var arr; + var out; + + arr = new Uint64Array( [ 1, 2, 3, 4 ] ); + out = arr.forEach( fcn ); + + t.strictEqual( out, void 0, 'returns expected value' ); + t.end(); + + function fcn( v ) { + if ( !isUint64( v ) ) { + t.fail( 'should be a 64-bit unsigned integer' ); + } + } +}); + +// tape( 'the method invokes a provided function for each element in an array', function test( t ) { // TODO: use isSameUint64Array +// var expected; +// var indices; +// var values; +// var arrays; +// var arr; +// var i; + +// indices = []; +// values = []; +// arrays = []; + +// expected = [ +// new Uint64( 1 ), +// new Uint64( 2 ), +// new Uint64( 3 ), +// new Uint64( 4 ) +// ]; +// arr = new Uint64Array( expected ); +// arr.forEach( fcn ); + +// t.strictEqual( values.length, expected.length, 'returns expected value' ); +// for ( i = 0; i < expected.length; i++ ) { +// t.strictEqual( isUint64( values[ i ] ), true, 'returns expected value' ); +// t.strictEqual( isEqual( values[ i ], expected[ i ] ), true, 'returns expected value' ); +// } +// t.deepEqual( indices, [ 0, 1, 2, 3 ], 'returns expected value' ); +// t.strictEqual( arrays[ 0 ], arr, 'returns expected value' ); +// t.strictEqual( arrays[ 1 ], arr, 'returns expected value' ); +// t.strictEqual( arrays[ 2 ], arr, 'returns expected value' ); +// t.strictEqual( arrays[ 3 ], arr, 'returns expected value' ); + +// t.end(); + +// function fcn( v, i, arr ) { +// values.push( v ); +// indices.push( i ); +// arrays.push( arr ); +// } +// }); + +tape( 'the method supports providing an execution context', function test( t ) { + var ctx; + var arr; + + ctx = { + 'count': 0 + }; + arr = new Uint64Array( [ 1, 2, 3 ] ); + arr.forEach( fcn, ctx ); + + t.strictEqual( ctx.count, 3, 'returns expected value' ); + + t.end(); + + function fcn() { + this.count += 1; // eslint-disable-line no-invalid-this + } +}); From 02971cd45bc630d8037aa313ab41c1b205714a00 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Sun, 20 Sep 2026 13:27:41 +0000 Subject: [PATCH 072/114] bench: add benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../uint64/benchmark/benchmark.for_each.js | 89 +++++++++++++++ .../benchmark/benchmark.for_each.length.js | 107 ++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.js new file mode 100644 index 000000000000..994a74e5d764 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.js @@ -0,0 +1,89 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:forEach', pkg ), function benchmark( b ) { + var count; + var arr; + var N; + var i; + + arr = new Uint64Array( 2 ); + N = arr.length; + + count = 0; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr.forEach( fcn ); + if ( count !== N*(i+1) ) { + b.fail( 'unexpected result' ); + } + } + b.toc(); + if ( count !== N*i ) { + b.fail( 'unexpected result' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function fcn() { + count += 1; + } +}); + +bench( format( '%s::this_context:forEach', pkg ), function benchmark( b ) { + var count; + var arr; + var N; + var i; + + arr = new Uint64Array( 2 ); + N = arr.length; + + count = 0; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr.forEach( fcn, {} ); + if ( count !== N*(i+1) ) { + b.fail( 'unexpected result' ); + } + } + b.toc(); + if ( count !== N*i ) { + b.fail( 'unexpected result' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function fcn() { + count += 1; + } +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.length.js new file mode 100644 index 000000000000..d695ae0fd728 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.length.js @@ -0,0 +1,107 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var count; + var arr; + + arr = new Uint64Array( len ); + count = 0; + + 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( fcn ); + if ( count !== count ) { + b.fail( 'should not be NaN' ); + } + } + b.toc(); + if ( count !== count ) { + b.fail( 'should not be NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } + + /** + * Callback invoked for each tuple element. + * + * @private + */ + function fcn() { + count += 1; + } +} + + +// 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( format( '%s:forEach:len=%d', pkg, len ), f ); + } +} + +main(); From 83a097bc66ef83135211bb6fb8d8af41e6ee53c8 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Sun, 20 Sep 2026 13:31:04 +0000 Subject: [PATCH 073/114] docs: add docs --- .../@stdlib/array/uint64/docs/repl.txt | 28 +++++++++++++++++++ .../array/uint64/docs/types/index.d.ts | 18 ++++++++++++ 2 files changed, 46 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index fcb672711bbc..55309d1b26b9 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -541,6 +541,34 @@ 3 +{{alias}}.prototype.forEach( clbk[, thisArg] ) + Invokes a function once for each array element. + + A callback function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + Parameters + ---------- + clbk: Function + Function to invoke for each array element. + + thisArg: any (optional) + Execution context. + + Examples + -------- + > var str = '%'; + > function clbk( v ) { str += v.toString() + '%'; }; + > var arr = new {{alias}}( [ 1, 2 ] ) + [ 1n, 2n ] + > arr.forEach( clbk ); + > str + '%1%2%' + + {{alias}}.prototype.get( i ) Returns an array element located at integer position (index) `i`. diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index d5aa2122938f..754334900f67 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -625,6 +625,24 @@ declare class Uint64Array implements Uint64ArrayInterface { */ findLastIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; + /** + * Invokes a function once for each array element. + * + * @param fcn - function to invoke + * @param thisArg - execution context + * @returns undefined + * + * @example + * function log( v, i ) { + * console.log( '%s: %s', i, v.toString() ); + * } + * + * var arr = new Uint64Array( [ 1, 2, 3 ] ); + * + * arr.forEach( log ); + */ + forEach( fcn: Callback, thisArg?: ThisParameterType> ): void; + /** * Returns an array element. * From f214998eb88d9cd24861a22176fb9a1437fd58c6 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Sun, 20 Sep 2026 13:31:47 +0000 Subject: [PATCH 074/114] docs: add readme --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/README.md | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index 01b9af44cfe9..74ac1575d037 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -770,6 +770,58 @@ var count = context.count; If a `predicate` function never returns a truthy value, the method returns `-1`. + + +#### Uint64Array.prototype.forEach( callbackFn\[, thisArg] ) + +Invokes a function once for each array element. + +```javascript +function log( v, i ) { + console.log( '%s: %s', i, v.toString() ); +} + +var arr = new Uint64Array( [ 1, 2, 3 ] ); + +arr.forEach( log ); +/* => + 0: 1 + 1: 2 + 2: 3 +*/ +``` + +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, v.toString() ); +} + +var arr = new Uint64Array( [ 1, 2, 3 ] ); + +var context = { + 'count': 0 +}; + +arr.forEach( fcn, context ); +/* => + 0: 1 + 1: 2 + 2: 3 +*/ + +var count = context.count; +// returns 3 +``` + #### Uint64Array.prototype.get( i ) From 129fb46348ec145be03da873c003d704864f1fd4 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Thu, 24 Sep 2026 17:36:59 +0000 Subject: [PATCH 075/114] bench: improve benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/benchmark/benchmark.for_each.js | 6 ++++-- .../uint64/benchmark/benchmark.for_each.length.js | 13 ++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.js index 994a74e5d764..33cb70bb4637 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.js @@ -34,11 +34,12 @@ bench( format( '%s:forEach', pkg ), function benchmark( b ) { var N; var i; - arr = new Uint64Array( 2 ); + arr = new Uint64Array( 10 ); N = arr.length; count = 0; + // Benchmark worst case scenario (i.e., the method cannot exit early, so every element is visited)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { arr.forEach( fcn ); @@ -64,11 +65,12 @@ bench( format( '%s::this_context:forEach', pkg ), function benchmark( b ) { var N; var i; - arr = new Uint64Array( 2 ); + arr = new Uint64Array( 10 ); N = arr.length; count = 0; + // Benchmark worst case scenario (i.e., the method cannot exit early, so every element is visited)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { arr.forEach( fcn, {} ); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.length.js index d695ae0fd728..1ce29f268488 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.for_each.length.js @@ -54,23 +54,26 @@ function createBenchmark( len ) { function benchmark( b ) { var i; + count = 0; + + // Benchmark worst case scenario (i.e., the method cannot exit early, so every element is visited)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); + if ( count !== len*(i+1) ) { + b.fail( 'unexpected result' ); } } b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); + if ( count !== len*i ) { + b.fail( 'unexpected result' ); } b.pass( 'benchmark finished' ); b.end(); } /** - * Callback invoked for each tuple element. + * Callback invoked for each array element. * * @private */ From 9a1fda75823d9d2afdd768a9fe7d3f33d3ea08fa Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Tue, 22 Sep 2026 04:46:55 +0000 Subject: [PATCH 076/114] feat: add includes method to array/uint64 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index 918f95bb3869..fdc9ecccd936 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -1162,6 +1162,73 @@ setReadOnly( Uint64Array.prototype, 'get', function get( idx ) { return getUint64( this._buffer, idx ); }); +/** +* Returns a boolean indicating whether an array includes a provided value. +* +* @name includes +* @memberof Uint64Array.prototype +* @type {Function} +* @param {(Uint64|bigint|number)} searchElement - search element +* @param {integer} [fromIndex=0] - starting index (inclusive) +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @throws {TypeError} first argument must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer +* @throws {TypeError} second argument must be an integer +* @returns {boolean} boolean indicating whether an array includes a provided value +* +* @example +* var Uint64 = require( '@stdlib/number/uint64/ctor' ); +* +* var arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); +* +* var bool = arr.includes( new Uint64( 3 ) ); +* // returns true +* +* bool = arr.includes( 3, 3 ); +* // returns false +* +* bool = arr.includes( 4n, -3 ); +* // returns true +*/ +setReadOnly( Uint64Array.prototype, 'includes', function includes( searchElement, fromIndex ) { + var words; + var buf; + var idx; + var i; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + if ( !isUint64( searchElement ) ) { + try { + searchElement = new Uint64( searchElement ); + } catch ( err ) { // eslint-disable-line no-unused-vars + throw new TypeError( format( 'invalid argument. First argument must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', searchElement ) ); + } + } + if ( arguments.length > 1 ) { + if ( !isIntegerPrimitive( fromIndex ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + } + if ( fromIndex < 0 ) { + fromIndex += this._length; + if ( fromIndex < 0 ) { + fromIndex = 0; + } + } + } else { + fromIndex = 0; + } + words = [ 0, 0 ]; + toWords( searchElement, words, 1, 0 ); + buf = this._buffer; + for ( i = fromIndex; i < this._length; i++ ) { + idx = 2 * i; + if ( words[ 0 ] === buf[ idx+indices.HIGH ] && words[ 1 ] === buf[ idx+indices.LOW ] ) { // eslint-disable-line max-len + return true; + } + } + return false; +}); + /** * Number of array elements. * From f68155f3b054279e9d338603df9c78a34e68af4f Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Tue, 22 Sep 2026 05:07:25 +0000 Subject: [PATCH 077/114] test: add test --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/test/test.includes.js | 241 ++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.includes.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.includes.js b/lib/node_modules/@stdlib/array/uint64/test/test.includes.js new file mode 100644 index 000000000000..15480b476a8f --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.includes.js @@ -0,0 +1,241 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasBigIntSupport = require( '@stdlib/assert/has-bigint-support' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var BigInt = require( '@stdlib/bigint/ctor' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var Uint64Array = require( './../lib' ); + + +// VARIABLES // + +var HAS_BIGINTS = hasBigIntSupport(); +var opts = { + 'skip': !HAS_BIGINTS +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is an `includes` method', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'includes' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.includes ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.includes.call( value, new Uint64( 1 ) ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 3.14, + -5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.includes( value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.includes( new Uint64( 1 ), value ); + }; + } +}); + +tape( 'the method returns `false` if operating on an empty 64-bit unsigned integer array', function test( t ) { + var bool; + var arr; + + arr = new Uint64Array(); + bool = arr.includes( new Uint64( 1 ) ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `false` if a 64-bit unsigned integer is not found', function test( t ) { + var bool; + var arr; + + arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + bool = arr.includes( new Uint64( 6 ) ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `true` if an array contains a specified 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer', opts, function test( t ) { + var bool; + var arr; + + arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + + bool = arr.includes( new Uint64( 1 ) ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( BigInt( 2 ) ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( 3 ); + t.strictEqual( bool, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { + var bool; + var arr; + + arr = new Uint64Array( 10 ); + bool = arr.includes( new Uint64( 0 ), 20 ); + + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index', function test( t ) { + var bool; + var arr; + + arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + + bool = arr.includes( new Uint64( 2 ), 0 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( new Uint64( 2 ), 2 ); + t.strictEqual( bool, false, 'returns expected value' ); + + bool = arr.includes( new Uint64( 3 ), 3 ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (negative)', function test( t ) { + var bool; + var arr; + + arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + + bool = arr.includes( new Uint64( 2 ), -5 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( new Uint64( 3 ), -2 ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { + var bool; + var arr; + + arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + + bool = arr.includes( new Uint64( 2 ), -10 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = arr.includes( new Uint64( 6 ), -10 ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); From 46eff59db39f7014a20d065d998786561e4532e8 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Tue, 22 Sep 2026 05:13:36 +0000 Subject: [PATCH 078/114] docs: add docs --- .../@stdlib/array/uint64/docs/repl.txt | 28 +++++++++++++++++++ .../array/uint64/docs/types/index.d.ts | 25 +++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index 55309d1b26b9..b24cb929a4f7 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -593,6 +593,34 @@ [ 2n ] +{{alias}}.prototype.includes( searchElement[, fromIndex] ) + Returns a boolean indicating whether an array includes a provided value. + + Parameters + ---------- + searchElement: Uint64|number|bigint + Search element. + + fromIndex: integer (optional) + Array index at which to start the search. If provided a negative value, + the method resolves the start index relative to the last array element. + Default: 0. + + Returns + ------- + bool: boolean + Boolean indicating whether an array includes a search element. + + Examples + -------- + > var arr = new {{alias}}( [ 1, 2, 3, 4 ] ) + [ 1n, 2n, 3n, 4n ] + > var bool = arr.includes( new {{alias:@stdlib/number/uint64/ctor}}( 3 ) ) + true + > bool = arr.includes( 3, 3 ) + false + + {{alias}}.prototype.set( v[, i] ) Sets one or more array elements. diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 754334900f67..6b1dca02d3bb 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -666,6 +666,31 @@ declare class Uint64Array implements Uint64ArrayInterface { */ get( i: number ): Uint64 | void; + /** + * Returns a boolean indicating whether an array includes a provided value. + * + * @param searchElement - search element + * @param fromIndex - starting index (inclusive) + * @throws first argument must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer + * @throws second argument must be an integer + * @returns boolean indicating whether an array includes a provided value + * + * @example + * var Uint64 = require( '@stdlib/number/uint64/ctor' ); + * + * var arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + * + * var bool = arr.includes( new Uint64( 3 ) ); + * // returns true + * + * bool = arr.includes( 3, 3 ); + * // returns false + * + * bool = arr.includes( 4n, -3 ); + * // returns true + */ + includes( searchElement: Uint, fromIndex?: number ): boolean; + /** * Sets an array element. * From c4a69523917f713ef1f49498d5f2e754ef2fde18 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Tue, 22 Sep 2026 05:14:36 +0000 Subject: [PATCH 079/114] docs: add readme --- .../@stdlib/array/uint64/README.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index 74ac1575d037..78433ce72f72 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -848,6 +848,27 @@ var u = arr.get( 100 ); // returns undefined ``` + + +#### Uint64Array.prototype.includes( searchElement\[, fromIndex] ) + +Returns a boolean indicating whether an array includes a provided value. + +```javascript +var Uint64 = require( '@stdlib/number/uint64/ctor' ); + +var arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + +var bool = arr.includes( new Uint64( 3 ) ); +// returns true + +bool = arr.includes( 3, 3 ); +// returns false + +bool = arr.includes( 4, -3 ); +// returns true +``` + #### Uint64Array.prototype.set( value\[, i] ) From a36f07cf71c9497faa31cb5757dc52bbe5bb4578 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Tue, 22 Sep 2026 17:22:54 +0000 Subject: [PATCH 080/114] bench: add benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../uint64/benchmark/benchmark.includes.js | 55 +++++++++++ .../benchmark/benchmark.includes.length.js | 98 +++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.js new file mode 100644 index 000000000000..c3cefba90354 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:includes', pkg ), function benchmark( b ) { + var bool; + var arr; + var v; + var i; + + arr = new Uint64Array( 10 ); + + v = 1; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.includes( v ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.length.js new file mode 100644 index 000000000000..fc5dff9cfcc0 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.length.js @@ -0,0 +1,98 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr = new Uint64Array( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var bool; + var v; + var i; + + v = 1; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = arr.includes( v ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:includes:len=%d', pkg, len ), f ); + } +} + +main(); From 60e9c75d353c586a21f5fd99650ade614cdb7ae0 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 23 Sep 2026 05:43:57 +0000 Subject: [PATCH 081/114] test: seperates tests for different input types --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/test/test.includes.js | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.includes.js b/lib/node_modules/@stdlib/array/uint64/test/test.includes.js index 15480b476a8f..2729a86c3980 100644 --- a/lib/node_modules/@stdlib/array/uint64/test/test.includes.js +++ b/lib/node_modules/@stdlib/array/uint64/test/test.includes.js @@ -166,21 +166,42 @@ tape( 'the method returns `false` if a 64-bit unsigned integer is not found', fu t.end(); }); -tape( 'the method returns `true` if an array contains a specified 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer', opts, function test( t ) { +tape( 'the method returns `true` if an array contains a specified 64-bit unsigned integer', function test( t ) { var bool; var arr; - arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + arr = new Uint64Array( [ 1, 2, 3, 2 ] ); + bool = arr.includes( new Uint64( 2 ) ); - bool = arr.includes( new Uint64( 1 ) ); t.strictEqual( bool, true, 'returns expected value' ); + t.end(); +}); - bool = arr.includes( BigInt( 2 ) ); +tape( 'the method supports providing a search element which is a nonnegative integer', function test( t ) { + var bool; + var arr; + + arr = new Uint64Array( [ 1, 2, 3 ] ); + + bool = arr.includes( 2 ); t.strictEqual( bool, true, 'returns expected value' ); - bool = arr.includes( 3 ); + bool = arr.includes( 4 ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports providing a search element which is a bigint', opts, function test( t ) { + var bool; + var arr; + + arr = new Uint64Array( [ 1, 2, 3 ] ); + + bool = arr.includes( BigInt( 2 ) ); t.strictEqual( bool, true, 'returns expected value' ); + bool = arr.includes( BigInt( 4 ) ); + t.strictEqual( bool, false, 'returns expected value' ); t.end(); }); From 4487a5808431a6a949a3db5e8d6d9e44891be22f Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Thu, 24 Sep 2026 17:39:56 +0000 Subject: [PATCH 082/114] bench: improve benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/benchmark/benchmark.includes.js | 5 +---- .../array/uint64/benchmark/benchmark.includes.length.js | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.js index c3cefba90354..95537880b96d 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.js @@ -32,16 +32,13 @@ var Uint64Array = require( './../lib' ); bench( format( '%s:includes', pkg ), function benchmark( b ) { var bool; var arr; - var v; var i; arr = new Uint64Array( 10 ); - v = 1; - b.tic(); for ( i = 0; i < b.iterations; i++ ) { - bool = arr.includes( v ); + bool = arr.includes( i+1 ); if ( typeof bool !== 'boolean' ) { b.fail( 'should return a boolean' ); } diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.length.js index fc5dff9cfcc0..46bde8bee377 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.length.js @@ -49,14 +49,11 @@ function createBenchmark( len ) { */ function benchmark( b ) { var bool; - var v; var i; - v = 1; - b.tic(); for ( i = 0; i < b.iterations; i++ ) { - bool = arr.includes( v ); + bool = arr.includes( i+1 ); if ( typeof bool !== 'boolean' ) { b.fail( 'should return a boolean' ); } From 6c117cb0cb41e92dbf37801b9dfb4289f2c2a6c9 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Thu, 24 Sep 2026 17:44:17 +0000 Subject: [PATCH 083/114] bench: improve benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/benchmark/benchmark.includes.js | 1 + .../@stdlib/array/uint64/benchmark/benchmark.includes.length.js | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.js index 95537880b96d..20895d5c03bd 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.js @@ -36,6 +36,7 @@ bench( format( '%s:includes', pkg ), function benchmark( b ) { arr = new Uint64Array( 10 ); + // Benchmark worst case scenario (i.e., the search element is never present, so the method must scan the entire array)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { bool = arr.includes( i+1 ); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.length.js index 46bde8bee377..8a7ac0278d0c 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.includes.length.js @@ -51,6 +51,7 @@ function createBenchmark( len ) { var bool; var i; + // Benchmark worst case scenario (i.e., the search element is never present, so the method must scan the entire array)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { bool = arr.includes( i+1 ); From 969523dab0ca3a3f885776f14d6d4f43d08d3ff9 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 23 Sep 2026 05:23:01 +0000 Subject: [PATCH 084/114] feat: add indexOf method to array/uint64 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index fdc9ecccd936..1ba87808038d 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -1229,6 +1229,73 @@ setReadOnly( Uint64Array.prototype, 'includes', function includes( searchElement return false; }); +/** +* Returns the first index at which a given element can be found. +* +* @name indexOf +* @memberof Uint64Array.prototype +* @type {Function} +* @param {(Uint64|bigint|number)} searchElement - element to find +* @param {integer} [fromIndex=0] - starting index (inclusive) +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @throws {TypeError} first argument must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer +* @throws {TypeError} second argument must be an integer +* @returns {integer} index or -1 +* +* @example +* var Uint64 = require( '@stdlib/number/uint64/ctor' ); +* +* var arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); +* +* var idx = arr.indexOf( new Uint64( 3 ) ); +* // returns 2 +* +* idx = arr.indexOf( 3, 3 ); +* // returns -1 +* +* idx = arr.indexOf( 4n, -3 ); +* // returns 3 +*/ +setReadOnly( Uint64Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) { + var words; + var buf; + var idx; + var i; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + if ( !isUint64( searchElement ) ) { + try { + searchElement = new Uint64( searchElement ); + } catch ( err ) { // eslint-disable-line no-unused-vars + throw new TypeError( format( 'invalid argument. First argument must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', searchElement ) ); + } + } + if ( arguments.length > 1 ) { + if ( !isIntegerPrimitive( fromIndex ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + } + if ( fromIndex < 0 ) { + fromIndex += this._length; + if ( fromIndex < 0 ) { + fromIndex = 0; + } + } + } else { + fromIndex = 0; + } + words = [ 0, 0 ]; + toWords( searchElement, words, 1, 0 ); + buf = this._buffer; + for ( i = fromIndex; i < this._length; i++ ) { + idx = 2 * i; + if ( words[ 0 ] === buf[ idx+indices.HIGH ] && words[ 1 ] === buf[ idx+indices.LOW ] ) { // eslint-disable-line max-len + return i; + } + } + return -1; +}); + /** * Number of array elements. * From 602beb5a69f5c46ba41c26ad8f422d49298b90a1 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 23 Sep 2026 05:34:11 +0000 Subject: [PATCH 085/114] test: add tests --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/test/test.index_of.js | 265 ++++++++++++++++++ 1 file changed, 265 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.index_of.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.index_of.js b/lib/node_modules/@stdlib/array/uint64/test/test.index_of.js new file mode 100644 index 000000000000..afe13e499310 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.index_of.js @@ -0,0 +1,265 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasBigIntSupport = require( '@stdlib/assert/has-bigint-support' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var BigInt = require( '@stdlib/bigint/ctor' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var Uint64Array = require( './../lib' ); + + +// VARIABLES // + +var HAS_BIGINTS = hasBigIntSupport(); +var opts = { + 'skip': !HAS_BIGINTS +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is an `indexOf` method', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'indexOf' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.indexOf ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.indexOf.call( value, new Uint64( 1 ) ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 3.14, + -5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.indexOf( value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.indexOf( new Uint64( 1 ), value ); + }; + } +}); + +tape( 'the method returns `-1` if operating on an empty 64-bit unsigned integer array', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array(); + idx = arr.indexOf( new Uint64( 1 ) ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `-1` if a 64-bit unsigned integer is not found', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( 10 ); + idx = arr.indexOf( new Uint64( 1 ) ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns the index of the first match if an array contains a specified 64-bit unsigned integer', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 2, 3, 2 ] ); + idx = arr.indexOf( new Uint64( 2 ) ); + + t.strictEqual( idx, 1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports providing a search element which is a nonnegative integer', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 2, 3 ] ); + + idx = arr.indexOf( 2 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.indexOf( 4 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports providing a search element which is a bigint', opts, function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 2, 3 ] ); + + idx = arr.indexOf( BigInt( 2 ) ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.indexOf( BigInt( 4 ) ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( 10 ); + idx = arr.indexOf( new Uint64( 0 ), 20 ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 2, 3, 2 ] ); + + idx = arr.indexOf( new Uint64( 2 ), 0 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.indexOf( new Uint64( 2 ), 2 ); + t.strictEqual( idx, 3, 'returns expected value' ); + + idx = arr.indexOf( new Uint64( 3 ), 3 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (negative)', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 2, 3, 2, 2 ] ); + + idx = arr.indexOf( new Uint64( 2 ), -5 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.indexOf( new Uint64( 2 ), -2 ); + t.strictEqual( idx, 3, 'returns expected value' ); + + idx = arr.indexOf( new Uint64( 4 ), -2 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 2, 3, 2, 2 ] ); + + idx = arr.indexOf( new Uint64( 2 ), -10 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.indexOf( new Uint64( 4 ), -10 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); From 821d61e2fc1b9a01a1f386e4f26541cdb33639ea Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 23 Sep 2026 05:36:27 +0000 Subject: [PATCH 086/114] docs: add docs --- .../@stdlib/array/uint64/docs/repl.txt | 30 +++++++++++++++++++ .../array/uint64/docs/types/index.d.ts | 25 ++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index b24cb929a4f7..662af7fb8be5 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -621,6 +621,36 @@ false +{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) + Returns the first index at which a given element can be found. + + If method does not find a search element, the method returns `-1`. + + Parameters + ---------- + searchElement: Uint64|number|bigint + Search element. + + fromIndex: integer (optional) + Array index at which to start the search. If provided a negative value, + the method resolves the start index relative to the last array element. + Default: 0. + + Returns + ------- + out: integer + Array index or `-1`. + + Examples + -------- + > var arr = new {{alias}}( [ 1, 2, 3, 4 ] ) + [ 1n, 2n, 3n, 4n ] + > var idx = arr.indexOf( new {{alias:@stdlib/number/uint64/ctor}}( 3 ) ) + 2 + > idx = arr.indexOf( 3, 3 ) + -1 + + {{alias}}.prototype.set( v[, i] ) Sets one or more array elements. diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 6b1dca02d3bb..e23336c1d0be 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -691,6 +691,31 @@ declare class Uint64Array implements Uint64ArrayInterface { */ includes( searchElement: Uint, fromIndex?: number ): boolean; + /** + * Returns the first index at which a given element can be found. + * + * @param searchElement - element to find + * @param fromIndex - starting index (inclusive) + * @throws first argument must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer + * @throws second argument must be an integer + * @returns index or -1 + * + * @example + * var Uint64 = require( '@stdlib/number/uint64/ctor' ); + * + * var arr = new Uint64Array( [ 1, 2, 3, 4, 5 ] ); + * + * var idx = arr.indexOf( new Uint64( 3 ) ); + * // returns 2 + * + * idx = arr.indexOf( 3, 3 ); + * // returns -1 + * + * idx = arr.indexOf( 4n, -3 ); + * // returns 3 + */ + indexOf( searchElement: Uint, fromIndex?: number ): number; + /** * Sets an array element. * From d3aaaff88145bad43301de1efdfc6704e92ffd8d Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 23 Sep 2026 05:38:42 +0000 Subject: [PATCH 087/114] docs: add readme --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/README.md | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index 78433ce72f72..8cf1a30c0528 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -869,6 +869,39 @@ bool = arr.includes( 4, -3 ); // returns true ``` + + +#### Uint64Array.prototype.indexOf( searchElement\[, fromIndex] ) + +Returns the first index at which a given element can be found. + +```javascript +var Uint64 = require( '@stdlib/number/uint64/ctor' ); + +var arr = new Uint64Array( [ 1, 2, 3, 4, 2 ] ); + +var idx = arr.indexOf( new Uint64( 3 ) ); +// returns 2 + +idx = arr.indexOf( 2, 2 ); +// returns 4 + +idx = arr.indexOf( 4, -3 ); +// returns 3 +``` + +If `searchElement` is not present in the array, the method returns `-1`. + +```javascript +var arr = new Uint64Array( [ 1, 2 ] ); + +var idx = arr.indexOf( 3 ); +// returns -1 + +idx = arr.indexOf( 1, 1 ); +// returns -1 +``` + #### Uint64Array.prototype.set( value\[, i] ) From 2383369042d6c35a3fb2b27dbe62857b500e6cbd Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 23 Sep 2026 05:39:28 +0000 Subject: [PATCH 088/114] bench: add benchmakrs --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../uint64/benchmark/benchmark.index_of.js | 55 +++++++++++ .../benchmark/benchmark.index_of.length.js | 98 +++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.js new file mode 100644 index 000000000000..4610226f3da7 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:indexOf', pkg ), function benchmark( b ) { + var out; + var arr; + var v; + var i; + + arr = new Uint64Array( 10 ); + + v = 1; + + // Benchmark worst case scenario... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.indexOf( v ); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + } + b.toc(); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.length.js new file mode 100644 index 000000000000..6480bf4b4d1a --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.length.js @@ -0,0 +1,98 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr = new Uint64Array( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var v; + var i; + + v = 1; + + // Benchmark worst case scenario... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.indexOf( v ); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + } + b.toc(); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:indexOf:len=%d', pkg, len ), f ); + } +} + +main(); From 3ee4c49c1dad38d173c75a4ff8fe39239b6c4757 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Thu, 24 Sep 2026 17:48:30 +0000 Subject: [PATCH 089/114] bench: improve benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/benchmark/benchmark.index_of.js | 7 ++----- .../array/uint64/benchmark/benchmark.index_of.length.js | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.js index 4610226f3da7..2dd119ae7614 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.js @@ -31,17 +31,14 @@ var Uint64Array = require( './../lib' ); bench( format( '%s:indexOf', pkg ), function benchmark( b ) { var out; var arr; - var v; var i; arr = new Uint64Array( 10 ); - v = 1; - - // Benchmark worst case scenario... + // Benchmark worst case scenario (i.e., the search element is never present, so the method must scan the entire array)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { - out = arr.indexOf( v ); + out = arr.indexOf( i+1 ); if ( out !== -1 ) { b.fail( 'should return -1' ); } diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.length.js index 6480bf4b4d1a..8eef5b3d97f0 100644 --- a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.length.js +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.index_of.length.js @@ -48,15 +48,12 @@ function createBenchmark( len ) { */ function benchmark( b ) { var out; - var v; var i; - v = 1; - - // Benchmark worst case scenario... + // Benchmark worst case scenario (i.e., the search element is never present, so the method must scan the entire array)... b.tic(); for ( i = 0; i < b.iterations; i++ ) { - out = arr.indexOf( v ); + out = arr.indexOf( i+1 ); if ( out !== -1 ) { b.fail( 'should return -1' ); } From a9bb24b667ffa99ec5ac4f42d59e7c69eeb5be1a Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 30 Sep 2026 05:35:45 +0000 Subject: [PATCH 090/114] feat: add join method to array/uint64 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index 1ba87808038d..a5fe60cd3b2b 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -30,6 +30,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); var isObject = require( '@stdlib/assert/is-object' ); var isFunction = require( '@stdlib/assert/is-function' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var isUint64 = require( '@stdlib/assert/is-uint64' ); var isInteger = require( '@stdlib/math/base/assert/is-integer' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); @@ -1296,6 +1297,48 @@ setReadOnly( Uint64Array.prototype, 'indexOf', function indexOf( searchElement, return -1; }); +/** +* Returns a new string by concatenating all array elements. +* +* @name join +* @memberof Uint64Array.prototype +* @type {Function} +* @param {string} [separator=','] - element separator +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @throws {TypeError} first argument must be a string +* @returns {string} string representation +* +* @example +* var arr = new Uint64Array( [ 1, 2, 3 ] ); +* +* var str = arr.join(); +* // returns '1,2,3' +* +* str = arr.join( '/' ); +* // returns '1/2/3' +*/ +setReadOnly( Uint64Array.prototype, 'join', function join( separator ) { + var out; + var buf; + var i; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + if ( arguments.length > 0 ) { + if ( !isString( separator ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) ); + } + } else { + separator = ','; + } + buf = this._buffer; + out = []; + for ( i = 0; i < this._length; i++ ) { + out.push( getUint64( buf, i ).toString() ); + } + return out.join( separator ); +}); + /** * Number of array elements. * From 830a973465c7353af35c5471c72a17251fdbece3 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 30 Sep 2026 05:44:41 +0000 Subject: [PATCH 091/114] test: add test --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/test/test.join.js | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.join.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.join.js b/lib/node_modules/@stdlib/array/uint64/test/test.join.js new file mode 100644 index 000000000000..9dbd1185bc04 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.join.js @@ -0,0 +1,161 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Uint64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'join' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.join ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.join.call( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `separator` argument which is not a string', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.join( value ); + }; + } +}); + +tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { + var str; + var arr; + + arr = new Uint64Array(); + str = arr.join(); + + t.strictEqual( str, '', 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a string representation of a 64-bit unsigned integer array with elements separated by a separator', function test( t ) { + var expected; + var str; + var arr; + + arr = new Uint64Array( [ 1, 2, 3, 4 ] ); + expected = '1@2@3@4'; + + str = arr.join( '@' ); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a string representation of a 64-bit unsigned integer array with elements separated by a separator (single element)', function test( t ) { + var expected; + var str; + var arr; + + arr = new Uint64Array( [ 1 ] ); + expected = '1'; + + str = arr.join(); + + t.strictEqual( str, expected, 'returns expected value' ); + + arr = new Uint64Array( [ 1 ] ); + expected = '1'; + + str = arr.join( '@' ); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if method invoked without a separator argument, the method returns a string representation of a 64-bit unsigned integer array with elements separated by a comma', function test( t ) { + var expected; + var str; + var arr; + + arr = new Uint64Array( [ 1, 2, 3, 4 ] ); + expected = '1,2,3,4'; + + str = arr.join(); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); From 3960cf4cf123358be65b5b0171bee49af6ab96c9 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 30 Sep 2026 05:46:10 +0000 Subject: [PATCH 092/114] bench: add benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/benchmark/benchmark.join.js | 76 +++++++++++++++ .../uint64/benchmark/benchmark.join.length.js | 96 +++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.js new file mode 100644 index 000000000000..7901e28c7f79 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.js @@ -0,0 +1,76 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:join', pkg ), function benchmark( b ) { + var out; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + // Benchmark worst case scenario (i.e., every element must be serialized and concatenated)... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.join(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( out ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::separator:join', pkg ), function benchmark( b ) { + var out; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + // Benchmark worst case scenario (i.e., every element must be serialized and concatenated)... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.join( '/' ); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( out ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.length.js new file mode 100644 index 000000000000..7376135ed7a6 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.length.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr = new Uint64Array( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + // Benchmark worst case scenario (i.e., every element must be serialized and concatenated)... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.join(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( out ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:join:len=%d', pkg, len ), f ); + } +} + +main(); From 5979f86b9abc6e702ee28078996fcd0cea9a0a32 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 30 Sep 2026 06:05:39 +0000 Subject: [PATCH 093/114] docs: add docs --- .../@stdlib/array/uint64/docs/repl.txt | 24 +++++++++++++++++++ .../array/uint64/docs/types/index.d.ts | 17 +++++++++++++ 2 files changed, 41 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index 662af7fb8be5..3ba7d573f5e7 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -651,6 +651,30 @@ -1 +{{alias}}.prototype.join( [separator] ) + Returns a new string by concatenating all array elements separated by a + separator string. + + Parameters + ---------- + separator: string (optional) + Separator string. Default: ','. + + Returns + ------- + out: string + Array serialized as a string. + + Examples + -------- + > var arr = new {{alias}}( [ 1, 2, 3 ] ) + [ 1n, 2n, 3n ] + > var str = arr.join() + '1,2,3' + > str = arr.join( '/' ) + '1/2/3' + + {{alias}}.prototype.set( v[, i] ) Sets one or more array elements. diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index e23336c1d0be..ec6e8ddffc71 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -716,6 +716,23 @@ declare class Uint64Array implements Uint64ArrayInterface { */ indexOf( searchElement: Uint, fromIndex?: number ): number; + /** + * Returns a new string by concatenating all array elements. + * + * @param separator - value separator (default: ',') + * @returns string + * + * @example + * var arr = new Uint64Array( [ 1, 2, 3 ] ); + * + * var str = arr.join(); + * // returns '1,2,3' + * + * str = arr.join( '/' ); + * // returns '1/2/3' + */ + join( separator?: string ): string; + /** * Sets an array element. * From 818647d06d95f522c73f56021a85a9a0a5c77337 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 30 Sep 2026 13:46:07 +0000 Subject: [PATCH 094/114] docs: add readme --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/README.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index 8cf1a30c0528..627e5cc08512 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -902,6 +902,28 @@ idx = arr.indexOf( 1, 1 ); // returns -1 ``` + + +#### Uint64Array.prototype.join( \[separator] ) + +Returns a new string by concatenating all array elements. + +```javascript +var arr = new Uint64Array( [ 1, 2, 3 ] ); + +var str = arr.join(); +// returns '1,2,3' +``` + +By default, the method separates serialized array elements with a comma. To use an alternative separator, provide a `separator` string. + +```javascript +var arr = new Uint64Array( [ 1, 2, 3 ] ); + +var str = arr.join( '/' ); +// returns '1/2/3' +``` + #### Uint64Array.prototype.set( value\[, i] ) From 33dc5e560d3692cabe24120c346903db00c51a0c Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Fri, 2 Oct 2026 18:45:51 +0000 Subject: [PATCH 095/114] feat: add keys method to array/uint64 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index a5fe60cd3b2b..1a822f78b336 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -1339,6 +1339,104 @@ setReadOnly( Uint64Array.prototype, 'join', function join( separator ) { return out.join( separator ); }); +/** +* Returns an iterator for iterating over each index key in a typed array. +* +* @name keys +* @memberof Uint64Array.prototype +* @type {Function} +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @returns {Iterator} iterator +* +* @example +* var arr = new Uint64Array( [ 1, 2 ] ); +* +* var iter = arr.keys(); +* +* var v = iter.next().value; +* // returns 0 +* +* v = iter.next().value; +* // returns 1 +* +* var bool = iter.next().done; +* // returns true +*/ +setReadOnly( Uint64Array.prototype, 'keys', function keys() { + var self; + var iter; + var len; + var FLG; + var i; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + self = this; + len = this._length; + + // Initialize an iteration index: + i = -1; + + // Create an iterator protocol-compliant object: + iter = {}; + setReadOnly( iter, 'next', next ); + setReadOnly( iter, 'return', end ); + + if ( ITERATOR_SYMBOL ) { + setReadOnly( iter, ITERATOR_SYMBOL, factory ); + } + return iter; + + /** + * Returns an iterator protocol-compliant object containing the next iterated value. + * + * @private + * @returns {Object} iterator protocol-compliant object + */ + function next() { + i += 1; + if ( FLG || i >= len ) { + return { + 'done': true + }; + } + return { + 'value': i, + 'done': false + }; + } + + /** + * Finishes an iterator. + * + * @private + * @param {*} [value] - value to return + * @returns {Object} iterator protocol-compliant object + */ + function end( value ) { + FLG = true; + if ( arguments.length ) { + return { + 'value': value, + 'done': true + }; + } + return { + 'done': true + }; + } + + /** + * Returns a new iterator. + * + * @private + * @returns {Iterator} iterator + */ + function factory() { + return self.keys(); + } +}); + /** * Number of array elements. * From 056a9d7562f825867285221ba0949aae04182526 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Fri, 2 Oct 2026 18:50:20 +0000 Subject: [PATCH 096/114] test: add test --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/test/test.keys.js | 256 ++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.keys.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.keys.js b/lib/node_modules/@stdlib/array/uint64/test/test.keys.js new file mode 100644 index 000000000000..34f00bc61596 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.keys.js @@ -0,0 +1,256 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); +var Uint64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `keys` method', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'keys' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.keys ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.keys.call( value ); + }; + } +}); + +tape( 'the method returns an iterator protocol-compliant object', function test( t ) { + var expected; + var arr; + var it; + var i; + var r; + var e; + + arr = new Uint64Array( [ 1, 2 ] ); + expected = [ + { + 'value': 0, + 'done': false + }, + { + 'value': 1, + 'done': false + }, + { + 'done': true + } + ]; + it = arr.keys(); + + t.strictEqual( typeof it, 'object', 'returns expected value' ); + t.strictEqual( typeof it.next, 'function', 'has next method' ); + + for ( i = 0; i < expected.length; i++ ) { + r = it.next(); + e = expected[ i ]; + if ( e.value === void 0 ) { + t.deepEqual( r, e, 'returns expected value' ); + } else { + t.strictEqual( r.value, e.value, 'returns expected value' ); + t.strictEqual( r.done, e.done, 'returns expected value' ); + } + } + + t.end(); +}); + +tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { + var expected; + var arr; + var it; + var i; + var v; + + arr = new Uint64Array( [] ); + expected = [ + { + 'done': true + }, + { + 'done': true + }, + { + 'done': true + } + ]; + it = arr.keys(); + + t.strictEqual( typeof it, 'object', 'returns expected value' ); + t.strictEqual( typeof it.next, 'function', 'has next method' ); + + for ( i = 0; i < expected.length; i++ ) { + v = it.next(); + t.deepEqual( v, expected[ i ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { + var arr; + var it; + var v; + + arr = new Uint64Array( [ 1, 2, 3 ] ); + it = arr.keys(); + + v = it.next(); + t.strictEqual( v.value, 0, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, 1, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.return(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { + var arr; + var it; + var v; + + arr = new Uint64Array( [ 1, 2, 3 ] ); + it = arr.keys(); + + v = it.next(); + t.strictEqual( v.value, 0, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, 1, 'returns expected value' ); + t.strictEqual( v.done, false, 'returns expected value' ); + + v = it.return( 'beep' ); + t.strictEqual( v.value, 'beep', 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + v = it.next(); + t.strictEqual( v.value, void 0, 'returns expected value' ); + t.strictEqual( v.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { + var Uint64Array; + var arr; + var it1; + var it2; + var v1; + var v2; + var i; + + Uint64Array = proxyquire( './../lib/main.js', { + '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' + }); + + arr = new Uint64Array( [ 1, 2, 3, 4 ] ); + + it1 = arr.keys(); + t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); + t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); + + it2 = it1[ '__ITERATOR_SYMBOL__' ](); + t.strictEqual( typeof it2, 'object', 'returns expected value' ); + t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); + t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); + + for ( i = 0; i < arr.length; i++ ) { + v1 = it1.next().value; + v2 = it2.next().value; + t.strictEqual( v1, v2, 'returns expected value' ); + } + t.end(); +}); + +tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { + var Uint64Array; + var arr; + var it; + + Uint64Array = proxyquire( './../lib/main.js', { + '@stdlib/symbol/iterator': false + }); + + arr = new Uint64Array( [ 1, 2, 3, 4 ] ); + + it = arr.keys(); + t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); + + t.end(); +}); From 6246951a43ec493e58c668920f046f9fe72dc3b7 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Fri, 2 Oct 2026 18:52:17 +0000 Subject: [PATCH 097/114] bench: add benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/benchmark/benchmark.keys.js | 52 ++++++++++ .../uint64/benchmark/benchmark.keys.length.js | 95 +++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.keys.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.keys.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.keys.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.keys.js new file mode 100644 index 000000000000..bdfac60a62a0 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.keys.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:keys', pkg ), function benchmark( b ) { + var iter; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + iter = arr.keys(); + if ( typeof iter !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isIteratorLike( iter ) ) { + b.fail( 'should return an iterator protocol-compliant object' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.keys.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.keys.length.js new file mode 100644 index 000000000000..59bdb5907949 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.keys.length.js @@ -0,0 +1,95 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr = new Uint64Array( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var iter; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + iter = arr.keys(); + if ( typeof iter !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isIteratorLike( iter ) ) { + b.fail( 'should return an iterator protocol-compliant object' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:keys:len=%d', pkg, len ), f ); + } +} + +main(); From 48c468954cffa303152df34867109c1013007e31 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Fri, 2 Oct 2026 18:55:06 +0000 Subject: [PATCH 098/114] docs: add docs --- .../@stdlib/array/uint64/docs/repl.txt | 21 +++++++++++++++++++ .../array/uint64/docs/types/index.d.ts | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index 3ba7d573f5e7..91c0bd32b53c 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -675,6 +675,27 @@ '1/2/3' +{{alias}}.prototype.keys() + Returns an iterator for iterating over each index key in a typed array. + + Returns + ------- + iterator: Iterator + Iterator for iterating over array index keys. + + Examples + -------- + > var arr = new {{alias}}( [ 1, 2 ] ) + [ 1n, 2n ] + > var it = arr.keys(); + > var v = it.next().value + 0 + > v = it.next().value + 1 + > v = it.next().done + true + + {{alias}}.prototype.set( v[, i] ) Sets one or more array elements. diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index ec6e8ddffc71..6ab6317c331b 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -733,6 +733,27 @@ declare class Uint64Array implements Uint64ArrayInterface { */ join( separator?: string ): string; + /** + * Returns an iterator for iterating over each index key in a typed array. + * + * @returns iterator + * + * @example + * var arr = new Uint64Array( [ 1, 2 ] ); + * + * var iter = arr.keys(); + * + * var v = iter.next().value; + * // returns 0 + * + * v = iter.next().value; + * // returns 1 + * + * var bool = iter.next().done; + * // returns true + */ + keys(): TypedIterator; + /** * Sets an array element. * From d5be9fd06eb2292c3e65a59dac6c81f2786b357e Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Fri, 2 Oct 2026 18:55:31 +0000 Subject: [PATCH 099/114] docs: add readme --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/README.md | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index 627e5cc08512..7b17c0c783c2 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -923,6 +923,31 @@ var arr = new Uint64Array( [ 1, 2, 3 ] ); var str = arr.join( '/' ); // returns '1/2/3' ``` + + +#### Uint64Array.prototype.keys() + +Returns an iterator for iterating over each index key in a typed array. + +```javascript +var arr = new Uint64Array( [ 1, 2 ] ); + +var iter = arr.keys(); + +var v = iter.next().value; +// returns 0 + +v = iter.next().value; +// returns 1 + +var bool = iter.next().done; +// returns true +``` + +The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties: + +- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished. +- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object. From 7b0e2a1eb0fab7a166b5bd6f919e4ec7e87a8451 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Sat, 3 Oct 2026 07:13:17 +0000 Subject: [PATCH 100/114] feat: add lastIndexOf method to array/uint64 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index 1a822f78b336..53692de3e646 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -1437,6 +1437,75 @@ setReadOnly( Uint64Array.prototype, 'keys', function keys() { } }); +/** +* Returns the last index at which a given element can be found. +* +* @name lastIndexOf +* @memberof Uint64Array.prototype +* @type {Function} +* @param {(Uint64|bigint|number)} searchElement - element to find +* @param {integer} [fromIndex] - index at which to start searching backward (inclusive) +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @throws {TypeError} first argument must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer +* @throws {TypeError} second argument must be an integer +* @returns {integer} index or -1 +* +* @example +* var Uint64 = require( '@stdlib/number/uint64/ctor' ); +* +* var arr = new Uint64Array( [ 1, 2, 3, 4, 3 ] ); +* +* var idx = arr.lastIndexOf( new Uint64( 3 ) ); +* // returns 4 +* +* idx = arr.lastIndexOf( 3, 3 ); +* // returns 2 +* +* idx = arr.lastIndexOf( 5, 3 ); +* // returns -1 +* +* idx = arr.lastIndexOf( 2n, -3 ); +* // returns 1 +*/ +setReadOnly( Uint64Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) { + var words; + var buf; + var idx; + var i; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + if ( !isUint64( searchElement ) ) { + try { + searchElement = new Uint64( searchElement ); + } catch ( err ) { // eslint-disable-line no-unused-vars + throw new TypeError( format( 'invalid argument. First argument must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', searchElement ) ); + } + } + if ( arguments.length > 1 ) { + if ( !isIntegerPrimitive( fromIndex ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + } + if ( fromIndex >= this._length ) { + fromIndex = this._length - 1; + } else if ( fromIndex < 0 ) { + fromIndex += this._length; + } + } else { + fromIndex = this._length - 1; + } + words = [ 0, 0 ]; + toWords( searchElement, words, 1, 0 ); + buf = this._buffer; + for ( i = fromIndex; i >= 0; i-- ) { + idx = 2 * i; + if ( words[ 0 ] === buf[ idx+indices.HIGH ] && words[ 1 ] === buf[ idx+indices.LOW ] ) { // eslint-disable-line max-len + return i; + } + } + return -1; +}); + /** * Number of array elements. * From 9d592dd18ac3b5959296c32841194e863e3cae68 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Sat, 3 Oct 2026 07:19:08 +0000 Subject: [PATCH 101/114] test: add test --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/test/test.last_index_of.js | 251 ++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.last_index_of.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.last_index_of.js b/lib/node_modules/@stdlib/array/uint64/test/test.last_index_of.js new file mode 100644 index 000000000000..a34a4d837f9d --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.last_index_of.js @@ -0,0 +1,251 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasBigIntSupport = require( '@stdlib/assert/has-bigint-support' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var BigInt = require( '@stdlib/bigint/ctor' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var Uint64Array = require( './../lib' ); + + +// VARIABLES // + +var HAS_BIGINTS = hasBigIntSupport(); +var opts = { + 'skip': !HAS_BIGINTS +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `lastIndexOf` method', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'lastIndexOf' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.lastIndexOf ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.lastIndexOf.call( value, new Uint64( 1 ) ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 3.14, + -5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.lastIndexOf( value ); + }; + } +}); + +tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + values = [ + '5', + 3.14, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.lastIndexOf( new Uint64( 1 ), value ); + }; + } +}); + +tape( 'the method returns `-1` if operating on an empty 64-bit unsigned integer array', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array(); + idx = arr.lastIndexOf( new Uint64( 1 ) ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns `-1` if a 64-bit unsigned integer is not found', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( 10 ); + idx = arr.lastIndexOf( new Uint64( 1 ) ); + + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 2, 3, 2 ] ); + idx = arr.lastIndexOf( new Uint64( 2 ) ); + + t.strictEqual( idx, 3, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports providing a search element which is a nonnegative integer', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 2, 3, 2 ] ); + + idx = arr.lastIndexOf( 2 ); + t.strictEqual( idx, 3, 'returns expected value' ); + + idx = arr.lastIndexOf( 4 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports providing a search element which is a bigint', opts, function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 2, 3, 2 ] ); + + idx = arr.lastIndexOf( BigInt( 2 ) ); + t.strictEqual( idx, 3, 'returns expected value' ); + + idx = arr.lastIndexOf( BigInt( 4 ) ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 2, 3, 2, 3 ] ); + + idx = arr.lastIndexOf( new Uint64( 2 ), 4 ); + t.strictEqual( idx, 3, 'returns expected value' ); + + idx = arr.lastIndexOf( new Uint64( 2 ), 2 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.lastIndexOf( new Uint64( 3 ), 1 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports specifying a starting search index (negative)', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 2, 3, 2, 2 ] ); + + idx = arr.lastIndexOf( new Uint64( 2 ), -3 ); + t.strictEqual( idx, 1, 'returns expected value' ); + + idx = arr.lastIndexOf( new Uint64( 3 ), -1 ); + t.strictEqual( idx, 2, 'returns expected value' ); + t.end(); +}); + +tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { + var arr; + var idx; + + arr = new Uint64Array( [ 1, 2, 3, 2, 2 ] ); + + idx = arr.lastIndexOf( new Uint64( 2 ), 10 ); + t.strictEqual( idx, 4, 'returns expected value' ); + + idx = arr.lastIndexOf( new Uint64( 4 ), 10 ); + t.strictEqual( idx, -1, 'returns expected value' ); + t.end(); +}); From 81f493d59641c2590ff9d496dad1129e6da22ada Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Sat, 3 Oct 2026 07:20:19 +0000 Subject: [PATCH 102/114] bench: add benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../benchmark/benchmark.last_index_of.js | 52 ++++++++++ .../benchmark.last_index_of.length.js | 95 +++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.last_index_of.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.last_index_of.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.last_index_of.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.last_index_of.js new file mode 100644 index 000000000000..8f97527581e8 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.last_index_of.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:lastIndexOf', pkg ), function benchmark( b ) { + var out; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + // Benchmark worst case scenario (i.e., the search element is never present, so the method must scan the entire array)... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.lastIndexOf( i+1 ); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + } + b.toc(); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.last_index_of.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.last_index_of.length.js new file mode 100644 index 000000000000..15a8167d6183 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.last_index_of.length.js @@ -0,0 +1,95 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr = new Uint64Array( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + // Benchmark worst case scenario (i.e., the search element is never present, so the method must scan the entire array)... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.lastIndexOf( i+1 ); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + } + b.toc(); + if ( out !== -1 ) { + b.fail( 'should return -1' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:lastIndexOf:len=%d', pkg, len ), f ); + } +} + +main(); From a7e72722c17dee71fc9b0600d511b0e7fb109b74 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Sat, 3 Oct 2026 07:23:45 +0000 Subject: [PATCH 103/114] docs: add docs --- .../@stdlib/array/uint64/docs/repl.txt | 30 +++++++++++++++++++ .../array/uint64/docs/types/index.d.ts | 26 ++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index 91c0bd32b53c..bceb5deae645 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -696,6 +696,36 @@ true +{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) + Returns the last index at which a given element can be found. + + If method does not find a search element, the method returns `-1`. + + Parameters + ---------- + searchElement: Uint64|number|bigint + Search element. + + fromIndex: integer (optional) + Array index at which to start the search backward. If provided a + negative value, the method resolves the start index relative to the + last array element. Default: -1. + + Returns + ------- + out: integer + Array index or `-1`. + + Examples + -------- + > var arr = new {{alias}}( [ 1, 2, 3, 2 ] ) + [ 1n, 2n, 3n, 2n ] + > var idx = arr.lastIndexOf( new {{alias:@stdlib/number/uint64/ctor}}( 2 ) ) + 3 + > idx = arr.lastIndexOf( 2, 2 ) + 1 + + {{alias}}.prototype.set( v[, i] ) Sets one or more array elements. diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 6ab6317c331b..10fade00e0ca 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -754,6 +754,32 @@ declare class Uint64Array implements Uint64ArrayInterface { */ keys(): TypedIterator; + /** + * Returns the last index at which a given element can be found. + * + * @param searchElement - element to find + * @param fromIndex - index at which to start searching backward (inclusive) + * @returns index or -1 + * + * @example + * var Uint64 = require( '@stdlib/number/uint64/ctor' ); + * + * var arr = new Uint64Array( [ 1, 2, 3, 4, 3 ] ); + * + * var idx = arr.lastIndexOf( new Uint64( 3 ) ); + * // returns 4 + * + * idx = arr.lastIndexOf( 3, 3 ); + * // returns 2 + * + * idx = arr.lastIndexOf( 5, 3 ); + * // returns -1 + * + * idx = arr.lastIndexOf( 2n, -3 ); + * // returns 1 + */ + lastIndexOf( searchElement: Uint, fromIndex?: number ): number; + /** * Sets an array element. * From c5e932f2b966943fd6dcdbdacd0a75044bb95e4d Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Sat, 3 Oct 2026 07:24:44 +0000 Subject: [PATCH 104/114] docs: add readme --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/README.md | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index 7b17c0c783c2..dd008f93fac0 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -949,6 +949,39 @@ The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the - **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished. - **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object. + + +#### Uint64Array.prototype.lastIndexOf( searchElement\[, fromIndex] ) + +Returns the last index at which a given element can be found. + +```javascript +var Uint64 = require( '@stdlib/number/uint64/ctor' ); + +var arr = new Uint64Array( [ 1, 2, 3, 4, 3 ] ); + +var idx = arr.lastIndexOf( new Uint64( 3 ) ); +// returns 4 + +idx = arr.lastIndexOf( 3, 3 ); +// returns 2 + +idx = arr.lastIndexOf( 2, -3 ); +// returns 1 +``` + +If `searchElement` is not present in the array, the method returns `-1`. + +```javascript +var arr = new Uint64Array( [ 1, 2 ] ); + +var idx = arr.lastIndexOf( 3 ); +// returns -1 + +idx = arr.lastIndexOf( 2, 0 ); +// returns -1 +``` + #### Uint64Array.prototype.set( value\[, i] ) From abccdb145f0811d7d5890f4f585b71e257d5e0b8 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Mon, 5 Oct 2026 04:19:07 +0000 Subject: [PATCH 105/114] feat: add map method for array/uint64 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index 53692de3e646..36e27a2057be 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -1506,6 +1506,66 @@ setReadOnly( Uint64Array.prototype, 'lastIndexOf', function lastIndexOf( searchE return -1; }); +/** +* Returns a new array with each element being the result of a provided callback function. +* +* @name map +* @memberof Uint64Array.prototype +* @type {Function} +* @param {Function} fcn - callback function +* @param {*} [thisArg] - callback function execution context +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @throws {TypeError} first argument must be a function +* @throws {TypeError} callback must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer +* @returns {Uint64Array} 64-bit unsigned integer array +* +* @example +* var add = require( '@stdlib/number/uint64/base/add' ); +* +* function scale( v ) { +* return add( v, v ); +* } +* +* var arr = new Uint64Array( [ 1, 2, 3 ] ); +* +* var out = arr.map( scale ); +* // returns [ 2n, 4n, 6n ] +*/ +setReadOnly( Uint64Array.prototype, 'map', function map( fcn, thisArg ) { + var outbuf; + var words; + var buf; + var out; + var idx; + var i; + var v; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + if ( !isFunction( fcn ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + } + buf = this._buffer; + out = new this.constructor( this._length ); + outbuf = out._buffer; // eslint-disable-line no-underscore-dangle + words = [ 0, 0 ]; + for ( i = 0; i < this._length; i++ ) { + v = fcn.call( thisArg, getUint64( buf, i ), i, this ); + if ( !isUint64( v ) ) { + try { + v = new Uint64( v ); + } catch ( err ) { // eslint-disable-line no-unused-vars + throw new TypeError( format( 'invalid argument. Callback must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', v ) ); + } + } + toWords( v, words, 1, 0 ); + idx = 2 * i; + outbuf[ idx+indices.HIGH ] = words[ 0 ]; + outbuf[ idx+indices.LOW ] = words[ 1 ]; + } + return out; +}); + /** * Number of array elements. * From f6bc03b270ed26a40392fd518747a955571a2629 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Mon, 5 Oct 2026 04:24:29 +0000 Subject: [PATCH 106/114] test: add test --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/test/test.map.js | 270 ++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.map.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.map.js b/lib/node_modules/@stdlib/array/uint64/test/test.map.js new file mode 100644 index 000000000000..9a2e3f9f7f18 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.map.js @@ -0,0 +1,270 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var hasBigIntSupport = require( '@stdlib/assert/has-bigint-support' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var identity = require( '@stdlib/utils/identity-function' ); +var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); +var add = require( '@stdlib/number/uint64/base/add' ); +var BigInt = require( '@stdlib/bigint/ctor' ); +var Number = require( '@stdlib/number/ctor' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var Uint64Array = require( './../lib' ); + + +// VARIABLES // + +var HAS_BIGINTS = hasBigIntSupport(); +var opts = { + 'skip': !HAS_BIGINTS +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `map` method', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'map' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.map ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.map.call( value, identity ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.map( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty 64-bit unsigned integer array', function test( t ) { + var arr; + var out; + + arr = new Uint64Array(); + out = arr.map( identity ); + + t.strictEqual( instanceOf( out, Uint64Array ), true, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.notEqual( out, arr, 'returns a new instance' ); + t.end(); +}); + +tape( 'the method returns a new 64-bit unsigned integer array containing elements which are the result of a callback function', function test( t ) { + var expected; + var actual; + var arr; + var i; + + arr = new Uint64Array( [ 1, 2, 3 ] ); + expected = [ 2, 4, 6 ]; + actual = arr.map( scale ); + + t.strictEqual( instanceOf( actual, Uint64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + t.notEqual( actual, arr, 'returns a new instance' ); + for ( i = 0; i < expected.length; i++ ) { + t.strictEqual( isEqual( actual.get( i ), new Uint64( expected[ i ] ) ), true, 'returns expected value' ); + } + t.end(); + + function scale( v ) { + return add( v, v ); + } +}); + +tape( 'the method supports providing an execution context', function test( t ) { + var expected; + var actual; + var arr; + var ctx; + var i; + + arr = new Uint64Array( [ 1, 2, 3 ] ); + expected = [ 2, 4, 6 ]; + ctx = { + 'count': 0 + }; + actual = arr.map( scale, ctx ); + + t.strictEqual( instanceOf( actual, Uint64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + t.strictEqual( isEqual( actual.get( i ), new Uint64( expected[ i ] ) ), true, 'returns expected value' ); + } + t.strictEqual( ctx.count, 3, 'returns expected value' ); + t.end(); + + function scale( v ) { + this.count += 1; // eslint-disable-line no-invalid-this + return add( v, v ); + } +}); + +tape( 'the method supports a map function which returns a nonnegative integer', function test( t ) { + var expected; + var actual; + var arr; + var i; + + arr = new Uint64Array( [ 1, 2, 3 ] ); + expected = [ 2, 4, 6 ]; + actual = arr.map( scale ); + + t.strictEqual( instanceOf( actual, Uint64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + t.strictEqual( isEqual( actual.get( i ), new Uint64( expected[ i ] ) ), true, 'returns expected value' ); + } + t.end(); + + function scale( v ) { + return Number( v ) * 2; + } +}); + +tape( 'the method supports a map function which returns a bigint', opts, function test( t ) { + var expected; + var actual; + var arr; + var i; + + arr = new Uint64Array( [ 1, 2, 3 ] ); + expected = [ 2, 4, 6 ]; + actual = arr.map( scale ); + + t.strictEqual( instanceOf( actual, Uint64Array ), true, 'returns expected value' ); + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + t.strictEqual( isEqual( actual.get( i ), new Uint64( expected[ i ] ) ), true, 'returns expected value' ); + } + t.end(); + + function scale( v ) { + return BigInt( Number( v ) * 2 ); + } +}); + +tape( 'the method throws an error if provided a map function which does not return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer', function test( t ) { + var clbks; + var arr; + var i; + + arr = new Uint64Array( [ 1, 2, 3 ] ); + clbks = [ + clbk1, + clbk2, + clbk3, + clbk4, + clbk5 + ]; + for ( i = 0; i < clbks.length; i++ ) { + t.throws( badValue( clbks[i] ), TypeError, 'throws an error when provided callback '+i ); + } + t.end(); + + function badValue( clbk ) { + return function badValue() { + return arr.map( clbk ); + }; + } + + function clbk1() { + return -1; + } + + function clbk2() { + return 3.14; + } + + function clbk3() { + return '5'; + } + + function clbk4() { + return {}; + } + + function clbk5() { + return []; + } +}); From 78bdf2173626d45239a5463c9ae25a36697be2fd Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Mon, 5 Oct 2026 04:27:37 +0000 Subject: [PATCH 107/114] bench: add benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/uint64/benchmark/benchmark.map.js | 84 ++++++++++++++ .../uint64/benchmark/benchmark.map.length.js | 107 ++++++++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.map.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.map.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.map.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.map.js new file mode 100644 index 000000000000..bcc51c2ba272 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.map.js @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isUint64Array = require( '@stdlib/assert/is-uint64array' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:map', pkg ), function benchmark( b ) { + var arr; + var out; + var i; + + arr = new Uint64Array( 10 ); + + // Benchmark worst case scenario (i.e., every element is visited and written to the output array)... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.map( fcn ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isUint64Array( out ) ) { + b.fail( 'should return a Uint64Array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function fcn( v ) { + return v; + } +}); + +bench( format( '%s::this_context:map', pkg ), function benchmark( b ) { + var arr; + var out; + var i; + + arr = new Uint64Array( 10 ); + + // Benchmark worst case scenario (i.e., every element is visited and written to the output array)... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.map( fcn, {} ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isUint64Array( out ) ) { + b.fail( 'should return a Uint64Array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + + function fcn( v ) { + return v; + } +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.map.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.map.length.js new file mode 100644 index 000000000000..56496f47c282 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.map.length.js @@ -0,0 +1,107 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isUint64Array = require( '@stdlib/assert/is-uint64array' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Callback function. +* +* @private +* @param {Uint64} value - array element +* @returns {Uint64} transformed value +*/ +function fcn( value ) { + return value; +} + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr = new Uint64Array( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + // Benchmark worst case scenario (i.e., every element is visited and written to the output array)... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.map( fcn ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isUint64Array( out ) ) { + b.fail( 'should return a Uint64Array' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:map:len=%d', pkg, len ), f ); + } +} + +main(); From 78044208016eaea4ae9fa7ac77637a72aa80d7ad Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Mon, 5 Oct 2026 04:33:00 +0000 Subject: [PATCH 108/114] docs: add docs --- .../@stdlib/array/uint64/docs/repl.txt | 34 +++++++++++++++++++ .../array/uint64/docs/types/index.d.ts | 21 ++++++++++++ 2 files changed, 55 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index bceb5deae645..22c1ece24bbc 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -726,6 +726,40 @@ 1 +{{alias}}.prototype.map( clbk[, thisArg] ) + Returns a new array with each element being the result of a provided + callback function. + + A callback function is provided the following arguments: + + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + The returned array has the same data type as the host array. + + Parameters + ---------- + clbk: Function + Function which maps array elements to elements in the new array. + + thisArg: any (optional) + Execution context. + + Returns + ------- + out: Uint64Array + A new typed array. + + Examples + -------- + > function clbk( v ) { return v; }; + > var arr = new {{alias}}( [ 1, 2 ] ) + [ 1n, 2n ] + > var out = arr.map( clbk ) + [ 1n, 2n ] + + {{alias}}.prototype.set( v[, i] ) Sets one or more array elements. diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 10fade00e0ca..89f470968a4a 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -780,6 +780,27 @@ declare class Uint64Array implements Uint64ArrayInterface { */ lastIndexOf( searchElement: Uint, fromIndex?: number ): number; + /** + * Returns a new array with each element being the result of a provided callback function. + * + * @param fcn - callback function + * @param thisArg - execution context + * @returns new array containing transformed elements + * + * @example + * var add = require( '@stdlib/number/uint64/base/add' ); + * + * function scale( v ) { + * return add( v, v ); + * } + * + * var arr = new Uint64Array( [ 1, 2, 3 ] ); + * + * var out = arr.map( scale ); + * // returns [ 2n, 4n, 6n ] + */ + map( fcn: MapFcn, thisArg?: ThisParameterType> ): Uint64Array; + /** * Sets an array element. * From 71a75ef7229caa242de10de09ae326f0ac8e42c9 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Mon, 5 Oct 2026 04:34:15 +0000 Subject: [PATCH 109/114] docs: add readme --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/README.md | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index dd008f93fac0..e3493b7b2024 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -982,6 +982,54 @@ idx = arr.lastIndexOf( 2, 0 ); // returns -1 ``` + + +#### Uint64Array.prototype.map( callbackFn\[, thisArg] ) + +Returns a new array with each element being the result of a provided callback function. + +```javascript +var add = require( '@stdlib/number/uint64/base/add' ); + +function scale( v ) { + return add( v, v ); +} + +var arr = new Uint64Array( [ 1, 2, 3 ] ); + +var out = arr.map( scale ); +// returns [ 2n, 4n, 6n ] +``` + +The callback 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 +var add = require( '@stdlib/number/uint64/base/add' ); + +function scale( v ) { + this.count += 1; + return add( v, v ); +} + +var arr = new Uint64Array( [ 1, 2, 3 ] ); + +var context = { + 'count': 0 +}; + +var out = arr.map( scale, context ); +// returns [ 2n, 4n, 6n ] + +var count = context.count; +// returns 3 +``` + #### Uint64Array.prototype.set( value\[, i] ) From 34bcba5d2a5875ba423b7c99111773567ff456fb Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Tue, 27 Oct 2026 14:32:01 +0000 Subject: [PATCH 110/114] fix: fix order of length --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index 36e27a2057be..87e2082b8cc5 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -1506,6 +1506,24 @@ setReadOnly( Uint64Array.prototype, 'lastIndexOf', function lastIndexOf( searchE return -1; }); +/** +* Number of array elements. +* +* @name length +* @memberof Uint64Array.prototype +* @readonly +* @type {NonNegativeInteger} +* +* @example +* var arr = new Uint64Array( 10 ); +* +* var len = arr.length; +* // returns 10 +*/ +setReadOnlyAccessor( Uint64Array.prototype, 'length', function get() { + return this._length; +}); + /** * Returns a new array with each element being the result of a provided callback function. * @@ -1566,24 +1584,6 @@ setReadOnly( Uint64Array.prototype, 'map', function map( fcn, thisArg ) { return out; }); -/** -* Number of array elements. -* -* @name length -* @memberof Uint64Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Uint64Array( 10 ); -* -* var len = arr.length; -* // returns 10 -*/ -setReadOnlyAccessor( Uint64Array.prototype, 'length', function get() { - return this._length; -}); - /** * Sets an array element. * From c85a407e4a374c5bcc09b80a298d13f9985bb078 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Tue, 6 Oct 2026 03:53:08 +0000 Subject: [PATCH 111/114] feat: add reduce method for array/uint64 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index 87e2082b8cc5..2ca2a0a478e4 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -1584,6 +1584,58 @@ setReadOnly( Uint64Array.prototype, 'map', function map( fcn, thisArg ) { return out; }); +/** +* 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. +* +* @name reduce +* @memberof Uint64Array.prototype +* @type {Function} +* @param {Function} reducer - callback function +* @param {*} [initialValue] - initial value +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @throws {TypeError} first argument must be a function +* @throws {Error} if not provided an initial value, the array must have at least one element +* @returns {*} accumulated result +* +* @example +* var add = require( '@stdlib/number/uint64/base/add' ); +* +* var arr = new Uint64Array( [ 1, 2, 3 ] ); +* +* var u = arr.reduce( add ); +* // returns [ 6n ] +*/ +setReadOnly( Uint64Array.prototype, 'reduce', function reduce( reducer, initialValue ) { + var buf; + var acc; + var len; + var v; + var i; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + if ( !isFunction( reducer ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); + } + buf = this._buffer; + len = this._length; + if ( arguments.length > 1 ) { + acc = initialValue; + i = 0; + } else { + if ( len === 0 ) { + throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); + } + acc = getUint64( buf, 0 ); + i = 1; + } + for ( ; i < len; i++ ) { + v = getUint64( buf, i ); + acc = reducer( acc, v, i, this ); + } + return acc; +}); + /** * Sets an array element. * From 9f2ebac0edeea6f249f77198a9ef2ad12d62dcc7 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Tue, 6 Oct 2026 04:01:55 +0000 Subject: [PATCH 112/114] test: add test --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/test/test.reduce.js | 204 ++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.reduce.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.reduce.js b/lib/node_modules/@stdlib/array/uint64/test/test.reduce.js new file mode 100644 index 000000000000..07d31060422a --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.reduce.js @@ -0,0 +1,204 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var isUint64 = require( '@stdlib/assert/is-uint64' ); +var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); +var add = require( '@stdlib/number/uint64/base/add' ); +var Number = require( '@stdlib/number/ctor' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var Uint64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `reduce` method', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'reduce' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.reduce ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.reduce.call( value, add ); + }; + } +}); + +tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.reduce( value ); + }; + } +}); + +tape( 'the method throws an error if not provided an initial value when operating on an empty 64-bit unsigned integer array', function test( t ) { + var arr; + + arr = new Uint64Array( 0 ); + t.throws( foo, Error, 'throws an error' ); + t.end(); + + function foo() { + arr.reduce( add ); + } +}); + +tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { + var valueArray; + var accArray; + var expected; + var actual; + var arr; + + arr = new Uint64Array( [ 1, 2, 3 ] ); + accArray = [ 1, 3 ]; + valueArray = [ 2, 3 ]; + expected = new Uint64( 6 ); + actual = arr.reduce( reducer ); + + t.strictEqual( isUint64( actual ), true, 'returns expected value' ); + t.strictEqual( isEqual( actual, expected ), true, 'returns expected value' ); + + t.end(); + + function reducer( acc, value, index ) { + var ind = index - 1; + t.strictEqual( isUint64( acc ), true, 'returns expected value' ); + t.strictEqual( isEqual( acc, new Uint64( accArray[ ind ] ) ), true, 'returns expected value' ); + t.strictEqual( isUint64( value ), true, 'returns expected value' ); + t.strictEqual( isEqual( value, new Uint64( valueArray[ ind ] ) ), true, 'returns expected value' ); + return add( acc, value ); + } +}); + +tape( 'the method supports providing an initial value as the second argument', function test( t ) { + var valueArray; + var accArray; + var expected; + var actual; + var arr; + + arr = new Uint64Array( [ 1, 2, 3 ] ); + accArray = [ 2, 3, 5 ]; + valueArray = [ 1, 2, 3 ]; + expected = new Uint64( 8 ); + actual = arr.reduce( reducer, new Uint64( 2 ) ); + + t.strictEqual( isUint64( actual ), true, 'returns expected value' ); + t.strictEqual( isEqual( actual, expected ), true, 'returns expected value' ); + + t.end(); + + function reducer( acc, value, index ) { + t.strictEqual( isUint64( acc ), true, 'returns expected value' ); + t.strictEqual( isEqual( acc, new Uint64( accArray[ index ] ) ), true, 'returns expected value' ); + t.strictEqual( isUint64( value ), true, 'returns expected value' ); + t.strictEqual( isEqual( value, new Uint64( valueArray[ index ] ) ), true, 'returns expected value' ); + return add( acc, value ); + } +}); + +tape( 'the method returns the accumulated result', function test( t ) { + var expected; + var actual; + var arr; + + arr = new Uint64Array( [ 1, 2, 3 ] ); + expected = new Uint64( 6 ); + actual = arr.reduce( add ); + + t.strictEqual( isUint64( actual ), true, 'returns expected value' ); + t.strictEqual( isEqual( actual, expected ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the method supports returning real-valued results', function test( t ) { + var expected; + var actual; + var arr; + + arr = new Uint64Array( [ 1, 2, 3 ] ); + expected = 6; + actual = arr.reduce( reducer, 0 ); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); + + function reducer( acc, value ) { + return acc + Number( value ); + } +}); From 5c24f5a8dcaed1c3c4cfe999d2b7cf4cad7fe099 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Tue, 6 Oct 2026 04:05:19 +0000 Subject: [PATCH 113/114] bench: add benchmarks --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../uint64/benchmark/benchmark.reduce.js | 81 ++++++++++++++++ .../benchmark/benchmark.reduce.length.js | 97 +++++++++++++++++++ 2 files changed, 178 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.reduce.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.reduce.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.reduce.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.reduce.js new file mode 100644 index 000000000000..b7376999c583 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.reduce.js @@ -0,0 +1,81 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isUint64 = require( '@stdlib/assert/is-uint64' ); +var add = require( '@stdlib/number/uint64/base/add' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:reduce', pkg ), function benchmark( b ) { + var out; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + // Benchmark worst case scenario (i.e., every element is visited and passed to the reducer)... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reduce( add ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isUint64( out ) ) { + b.fail( 'should return a 64-bit unsigned integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::initial_value:reduce', pkg ), function benchmark( b ) { + var out; + var arr; + var v; + var i; + + arr = new Uint64Array( 10 ); + + v = new Uint64( 0 ); + + // Benchmark worst case scenario (i.e., every element is visited and passed to the reducer)... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reduce( add, v ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isUint64( out ) ) { + b.fail( 'should return a 64-bit unsigned integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.reduce.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.reduce.length.js new file mode 100644 index 000000000000..2336da53d722 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.reduce.length.js @@ -0,0 +1,97 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isUint64 = require( '@stdlib/assert/is-uint64' ); +var add = require( '@stdlib/number/uint64/base/add' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr = new Uint64Array( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + // Benchmark worst case scenario (i.e., every element is visited and passed to the reducer)... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reduce( add ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isUint64( out ) ) { + b.fail( 'should return a 64-bit unsigned integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:reduce:len=%d', pkg, len ), f ); + } +} + +main(); From f8286bac302b7a697f8db317c3e55c54ab7a547f Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Tue, 6 Oct 2026 04:08:50 +0000 Subject: [PATCH 114/114] docs: add readme --- .../@stdlib/array/uint64/README.md | 38 +++++++++++++++++ .../@stdlib/array/uint64/docs/repl.txt | 41 +++++++++++++++++++ .../array/uint64/docs/types/index.d.ts | 17 ++++++++ 3 files changed, 96 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index e3493b7b2024..67893b932a53 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -1030,6 +1030,44 @@ var count = context.count; // returns 3 ``` + + +#### Uint64Array.prototype.reduce( reducerFn\[, initialValue] ) + +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. + +```javascript +var add = require( '@stdlib/number/uint64/base/add' ); + +var arr = new Uint64Array( [ 1, 2, 3 ] ); + +var u = arr.reduce( add ); +// returns [ 6n ] +``` + +The reducer function is provided four arguments: + +- **acc**: accumulated result. +- **value**: current array element. +- **index**: current array element index. +- **arr**: the array on which this method was called. + +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. + +```javascript +var Number = require( '@stdlib/number/ctor' ); + +function reducer( acc, v ) { + acc += Number( v ); + return acc; +} + +var arr = new Uint64Array( [ 1, 2, 3 ] ); + +var sum = arr.reduce( reducer, 2 ); +// returns 8 +``` + #### Uint64Array.prototype.set( value\[, i] ) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index 22c1ece24bbc..408e736c352f 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -760,6 +760,47 @@ [ 1n, 2n ] +{{alias}}.prototype.reduce( reducerFn[, initialValue] ) + Applies a provided 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. + + A reducer function is provided the following arguments: + + - acc: accumulated result. + - value: current array element. + - index: current array element index. + - arr: the array on which the method was called. + + If provided an initial value, the method invokes a provided function with + the initial value as the first argument and the first array element as the + second argument. + + If not provided an initial value, the method invokes a provided function + with the first array element as the first argument and the second array + element as the second argument. + + Parameters + ---------- + reducerFn: Function + Function to apply to each array element. + + initialValue: any (optional) + Initial accumulation value. + + Returns + ------- + out: any + Accumulated result. + + Examples + -------- + > var arr = new {{alias}}( [ 1, 2, 3 ] ) + [ 1n, 2n, 3n ] + > var u = arr.reduce( {{alias:@stdlib/number/uint64/base/add}} ) + [ 6n ] + + {{alias}}.prototype.set( v[, i] ) Sets one or more array elements. diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 89f470968a4a..a1b1c1f0d09d 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts @@ -801,6 +801,23 @@ declare class Uint64Array implements Uint64ArrayInterface { */ map( fcn: MapFcn, thisArg?: ThisParameterType> ): Uint64Array; + /** + * 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. + * + * @param reducer - callback function + * @param initialValue - initial value + * @returns accumulated result + * + * @example + * var add = require( '@stdlib/number/uint64/base/add' ); + * + * var arr = new Uint64Array( [ 1, 2, 3 ] ); + * + * var u = arr.reduce( add ); + * // returns [ 6n ] + */ + reduce( reducer: Reducer, initialValue?: U ): U; + /** * Sets an array element. *