From fb7605f95987315b70e0610a45e445f1ba83bfc4 Mon Sep 17 00:00:00 2001 From: Divit Date: Wed, 5 Aug 2026 08:39:30 +0000 Subject: [PATCH 01/10] 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 cd2cd62ab497fa04dc40210891531de7306ce38c Mon Sep 17 00:00:00 2001 From: Divit Date: Wed, 5 Aug 2026 08:48:06 +0000 Subject: [PATCH 02/10] 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 c4c2be8f107c..855c409a95ee 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 01e8e9824f9a5871662e4a43e77268a8c0b5a7b4 Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 10 Aug 2026 13:14:05 +0000 Subject: [PATCH 03/10] 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 725df849226022b068e4cebb477bc05b0afb8a21 Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 10 Aug 2026 14:47:02 +0000 Subject: [PATCH 04/10] 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 597a98c23d0d8de66ed39ebeeb5d283978443de9 Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 10 Aug 2026 17:10:59 +0000 Subject: [PATCH 05/10] 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 73e7941a80c5..68976dcdf96b 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 9ef153214af0a8d43440ed2739aa9ce8badcc9ee Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 10 Aug 2026 17:48:24 +0000 Subject: [PATCH 06/10] 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 6dd3c27d5987..d5cd6c5dc6ba 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 80bc68b7650ccffc6338474491d73cdd0ead8047 Mon Sep 17 00:00:00 2001 From: Divit Date: Mon, 10 Aug 2026 17:56:52 +0000 Subject: [PATCH 07/10] 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 9e7ea549f00d..d21cd52f075f 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -278,6 +278,109 @@ z = 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 1f3dd106b6f4d9c97c3129568c01f6ec09337d8d Mon Sep 17 00:00:00 2001 From: Divit Date: Tue, 11 Aug 2026 16:55:40 +0000 Subject: [PATCH 08/10] 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 d5cd6c5dc6ba..381c342841f0 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 f8d149b1fb468a38ca68bfcb458d22dd250aa03c Mon Sep 17 00:00:00 2001 From: Divit Date: Fri, 14 Aug 2026 06:11:23 +0000 Subject: [PATCH 09/10] 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 d21cd52f075f..f67642e426d4 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 68976dcdf96b..22ed92a34a0a 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 855c409a95ee..e1c7e2649f0e 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 e695b2ac9a6ca6c8251549beefdd8bdf7acdc02b Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Thu, 24 Sep 2026 04:30:54 +0000 Subject: [PATCH 10/10] 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();