From 1f92cc29523a53e0c29849e5042b2f93dcd8ef27 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 30 Sep 2026 05:35:45 +0000 Subject: [PATCH 1/5] feat: add join method to array/uint64 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/uint64/lib/main.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/lib/main.js b/lib/node_modules/@stdlib/array/uint64/lib/main.js index dd158c90cb94..d925ee4ec43b 100644 --- a/lib/node_modules/@stdlib/array/uint64/lib/main.js +++ b/lib/node_modules/@stdlib/array/uint64/lib/main.js @@ -30,6 +30,7 @@ var isCollection = require( '@stdlib/assert/is-collection' ); var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); var isObject = require( '@stdlib/assert/is-object' ); var isFunction = require( '@stdlib/assert/is-function' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var isUint64 = require( '@stdlib/assert/is-uint64' ); var isInteger = require( '@stdlib/math/base/assert/is-integer' ); var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); @@ -749,6 +750,48 @@ setReadOnly( Uint64Array.prototype, 'get', function get( idx ) { return getUint64( this._buffer, idx ); }); +/** +* Returns a new string by concatenating all array elements. +* +* @name join +* @memberof Uint64Array.prototype +* @type {Function} +* @param {string} [separator=','] - element separator +* @throws {TypeError} `this` must be a 64-bit unsigned integer array +* @throws {TypeError} first argument must be a string +* @returns {string} string representation +* +* @example +* var arr = new Uint64Array( [ 1, 2, 3 ] ); +* +* var str = arr.join(); +* // returns '1,2,3' +* +* str = arr.join( '/' ); +* // returns '1/2/3' +*/ +setReadOnly( Uint64Array.prototype, 'join', function join( separator ) { + var out; + var buf; + var i; + if ( !isUint64Array( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); + } + if ( arguments.length > 0 ) { + if ( !isString( separator ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) ); + } + } else { + separator = ','; + } + buf = this._buffer; + out = []; + for ( i = 0; i < this._length; i++ ) { + out.push( getUint64( buf, i ).toString() ); + } + return out.join( separator ); +}); + /** * Number of array elements. * From 8ab21a8bd9712f0179b801d034fcdd5eaee733fa Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 30 Sep 2026 05:44:41 +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.join.js | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/test/test.join.js diff --git a/lib/node_modules/@stdlib/array/uint64/test/test.join.js b/lib/node_modules/@stdlib/array/uint64/test/test.join.js new file mode 100644 index 000000000000..9dbd1185bc04 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/test/test.join.js @@ -0,0 +1,161 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var Uint64Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { + t.strictEqual( hasOwnProp( Uint64Array.prototype, 'join' ), true, 'has property' ); + t.strictEqual( isFunction( Uint64Array.prototype.join ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [] + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.join.call( value ); + }; + } +}); + +tape( 'the method throws an error if invoked with a `separator` argument which is not a string', function test( t ) { + var values; + var arr; + var i; + + arr = new Uint64Array( 5 ); + + values = [ + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.join( value ); + }; + } +}); + +tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { + var str; + var arr; + + arr = new Uint64Array(); + str = arr.join(); + + t.strictEqual( str, '', 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a string representation of a 64-bit unsigned integer array with elements separated by a separator', function test( t ) { + var expected; + var str; + var arr; + + arr = new Uint64Array( [ 1, 2, 3, 4 ] ); + expected = '1@2@3@4'; + + str = arr.join( '@' ); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a string representation of a 64-bit unsigned integer array with elements separated by a separator (single element)', function test( t ) { + var expected; + var str; + var arr; + + arr = new Uint64Array( [ 1 ] ); + expected = '1'; + + str = arr.join(); + + t.strictEqual( str, expected, 'returns expected value' ); + + arr = new Uint64Array( [ 1 ] ); + expected = '1'; + + str = arr.join( '@' ); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if method invoked without a separator argument, the method returns a string representation of a 64-bit unsigned integer array with elements separated by a comma', function test( t ) { + var expected; + var str; + var arr; + + arr = new Uint64Array( [ 1, 2, 3, 4 ] ); + expected = '1,2,3,4'; + + str = arr.join(); + + t.strictEqual( str, expected, 'returns expected value' ); + t.end(); +}); From ff0b3174fb37b238b688ac247a005017232fe763 Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 30 Sep 2026 05:46:10 +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.join.js | 76 +++++++++++++++ .../uint64/benchmark/benchmark.join.length.js | 96 +++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.js create mode 100644 lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.length.js diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.js new file mode 100644 index 000000000000..7901e28c7f79 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.js @@ -0,0 +1,76 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// MAIN // + +bench( format( '%s:join', pkg ), function benchmark( b ) { + var out; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + // Benchmark worst case scenario (i.e., every element must be serialized and concatenated)... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.join(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( out ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::separator:join', pkg ), function benchmark( b ) { + var out; + var arr; + var i; + + arr = new Uint64Array( 10 ); + + // Benchmark worst case scenario (i.e., every element must be serialized and concatenated)... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.join( '/' ); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( out ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.length.js b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.length.js new file mode 100644 index 000000000000..7376135ed7a6 --- /dev/null +++ b/lib/node_modules/@stdlib/array/uint64/benchmark/benchmark.join.length.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var Uint64Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr = new Uint64Array( len ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + // Benchmark worst case scenario (i.e., every element must be serialized and concatenated)... + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.join(); + if ( typeof out !== 'string' ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( out ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:join:len=%d', pkg, len ), f ); + } +} + +main(); From cd5fbefcc7c0239ce4959200e4c1187055a161ba Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 30 Sep 2026 06:05:39 +0000 Subject: [PATCH 4/5] docs: add docs --- .../@stdlib/array/uint64/docs/repl.txt | 24 +++++++++++++++++++ .../array/uint64/docs/types/index.d.ts | 17 +++++++++++++ 2 files changed, 41 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt index 6dd3c27d5987..4b6cefa7fb30 100644 --- a/lib/node_modules/@stdlib/array/uint64/docs/repl.txt +++ b/lib/node_modules/@stdlib/array/uint64/docs/repl.txt @@ -299,6 +299,30 @@ [ 2n ] +{{alias}}.prototype.join( [separator] ) + Returns a new string by concatenating all array elements separated by a + separator string. + + Parameters + ---------- + separator: string (optional) + Separator string. Default: ','. + + Returns + ------- + out: string + Array serialized as a string. + + Examples + -------- + > var arr = new {{alias}}( [ 1, 2, 3 ] ) + [ 1n, 2n, 3n ] + > var str = arr.join() + '1,2,3' + > str = arr.join( '/' ) + '1/2/3' + + {{alias}}.prototype.set( v[, i] ) Sets one or more array elements. diff --git a/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/uint64/docs/types/index.d.ts index 73e7941a80c5..b9f62e20521e 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,23 @@ declare class Uint64Array implements Uint64ArrayInterface { */ get( i: number ): Uint64 | void; + /** + * Returns a new string by concatenating all array elements. + * + * @param separator - value separator (default: ',') + * @returns string + * + * @example + * var arr = new Uint64Array( [ 1, 2, 3 ] ); + * + * var str = arr.join(); + * // returns '1,2,3' + * + * str = arr.join( '/' ); + * // returns '1/2/3' + */ + join( separator?: string ): string; + /** * Sets an array element. * From 130d991958a7aa99a2a8247d1c16f26a6543e0ed Mon Sep 17 00:00:00 2001 From: Divit Jain Date: Wed, 30 Sep 2026 13:46:07 +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 | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/node_modules/@stdlib/array/uint64/README.md b/lib/node_modules/@stdlib/array/uint64/README.md index f0d84ef9697c..be10ab940e80 100644 --- a/lib/node_modules/@stdlib/array/uint64/README.md +++ b/lib/node_modules/@stdlib/array/uint64/README.md @@ -342,6 +342,28 @@ var z = arr.get( 100 ); // returns undefined ``` + + +#### Uint64Array.prototype.join( \[separator] ) + +Returns a new string by concatenating all array elements. + +```javascript +var arr = new Uint64Array( [ 1, 2, 3 ] ); + +var str = arr.join(); +// returns '1,2,3' +``` + +By default, the method separates serialized array elements with a comma. To use an alternative separator, provide a `separator` string. + +```javascript +var arr = new Uint64Array( [ 1, 2, 3 ] ); + +var str = arr.join( '/' ); +// returns '1/2/3' +``` + #### Uint64Array.prototype.set( value\[, i] )