From fb29f40278289c8af519ba39f8a2ede26cd0b2de Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 16:16:30 +0000 Subject: [PATCH 1/9] 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 e366fe395f55..851ed4fccadf 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -709,6 +709,50 @@ setReadOnly( Uint64Array.prototype, 'entries', function entries() { } }); +/** +* 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 5162a3c7968f3ddc8b2b39c3ca7e203879b2f6dc Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 16:44:06 +0000 Subject: [PATCH 2/9] 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 427a80101402e4b8faca3b4688f0d777af33deba Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 16:47:18 +0000 Subject: [PATCH 3/9] 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 73e7941a80c5..b1928a1d2af5 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 @@ -459,6 +459,28 @@ declare class Uint64Array implements Uint64ArrayInterface { */ entries(): TypedIterator<[number, Uint64]>; + /** + * 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 408b962262cef14e4a2280db67d85e6e28a89427 Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 16:51:43 +0000 Subject: [PATCH 4/9] 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 6dd3c27d5987..f5d417996728 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -275,6 +275,40 @@ true +{{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 6ffd22b84e7e42b73451cdf2f759333d0946309c Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 17:02:08 +0000 Subject: [PATCH 5/9] 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 1d5953e053c18861602969ccce8da07da4fefeb1 Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 17:06:45 +0000 Subject: [PATCH 6/9] 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 9e7ea549f00d..924897f54796 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -316,6 +316,56 @@ 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.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 2c1983eb60a832026d753c90168a9036e98e2150 Mon Sep 17 00:00:00 2001 From: Divit Date: Wed, 9 Sep 2026 17:17:53 +0000 Subject: [PATCH 7/9] 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 b042ff5a3d6c063ff0bb5f25f866c0949ec8a2df Mon Sep 17 00:00:00 2001 From: Divit Date: Wed, 9 Sep 2026 17:22:37 +0000 Subject: [PATCH 8/9] 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 f5d417996728..70db72ed4b05 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -303,7 +303,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 c794c977aabbecc0a9d4741ae9382d64e58fffa9 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Thu, 24 Sep 2026 16:33:45 +0000 Subject: [PATCH 9/9] 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 );