From 75abc528ffbafb4b593fb69ec0b97cdade579316 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Mon, 5 Oct 2026 04:19:07 +0000 Subject: [PATCH 1/5] 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 dd158c90cb94..8a1955877897 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -749,6 +749,66 @@ setReadOnly( Uint64Array.prototype, 'get', function get( idx ) { return getUint64( this._buffer, idx ); }); +/** +* 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 023fdcf1a80e1bc1fdd699e068534481d76d2c0d Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Mon, 5 Oct 2026 04:24:29 +0000 Subject: [PATCH 2/5] 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 b690f4c657c3910080b2f11dbd4c3c875d205687 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Mon, 5 Oct 2026 04:27:37 +0000 Subject: [PATCH 3/5] 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 a5c007e61e2bbd712d5ab1f080e2b238a3a1ba28 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Mon, 5 Oct 2026 04:33:00 +0000 Subject: [PATCH 4/5] 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 6dd3c27d5987..b62bd25c40cf 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -299,6 +299,40 @@ [ 2n ] +{{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 73e7941a80c5..3c3c712cf0ce 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 @@ -482,6 +482,27 @@ declare class Uint64Array implements Uint64ArrayInterface { */ get( i: number ): Uint64 | void; + /** + * 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 97f8bd0c1eacb7d7b993a74c1aa73b751a529d55 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Mon, 5 Oct 2026 04:34:15 +0000 Subject: [PATCH 5/5] 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 f0d84ef9697c..c83d6a102780 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -342,6 +342,54 @@ var z = arr.get( 100 ); // returns undefined ``` + + +#### 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] )