From d99224762b96e2adacd801f1e9c84558f2847ef0 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:29:55 -0700 Subject: [PATCH 01/60] feat: add `assert/is-equal-int32array` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../assert/is-equal-int32array/README.md | 103 +++++++++++++++++ .../benchmark/benchmark.length.js | 96 ++++++++++++++++ .../assert/is-equal-int32array/docs/repl.txt | 32 ++++++ .../is-equal-int32array/docs/types/index.d.ts | 51 +++++++++ .../is-equal-int32array/docs/types/test.ts | 36 ++++++ .../is-equal-int32array/examples/index.js | 40 +++++++ .../assert/is-equal-int32array/lib/index.js | 54 +++++++++ .../assert/is-equal-int32array/lib/main.js | 61 ++++++++++ .../assert/is-equal-int32array/package.json | 74 ++++++++++++ .../assert/is-equal-int32array/test/test.js | 106 ++++++++++++++++++ 10 files changed, 653 insertions(+) create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int32array/README.md create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int32array/benchmark/benchmark.length.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int32array/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int32array/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int32array/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int32array/examples/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int32array/lib/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int32array/lib/main.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int32array/package.json create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int32array/test/test.js diff --git a/lib/node_modules/@stdlib/assert/is-equal-int32array/README.md b/lib/node_modules/@stdlib/assert/is-equal-int32array/README.md new file mode 100644 index 000000000000..790723099b97 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int32array/README.md @@ -0,0 +1,103 @@ + + +# isEqualInt32Array + +> Test if two arguments are both Int32Arrays and have equal values. + +
+ +## Usage + +```javascript +var isEqualInt32Array = require( '@stdlib/assert/is-equal-int32array' ); +``` + +#### isEqualInt32Array( v1, v2 ) + +Tests if two arguments are both Int32Arrays and have equal values. + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); + +var x = new Int32Array( [ 1, 2 ] ); +var y = new Int32Array( [ 1, 2 ] ); +var bool = isEqualInt32Array( x, y ); +// returns true + +bool = isEqualInt32Array( x, new Int32Array( [ 1, 3 ] ) ); +// returns false +``` + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var isEqualInt32Array = require( '@stdlib/assert/is-equal-int32array' ); + +var x = new Int32Array( [ 1, 2, 3 ] ); +var y = new Int32Array( [ 1, 2, 3 ] ); +var out = isEqualInt32Array( x, y ); +// returns true + +x = new Int32Array( [ 0, 0, 0 ] ); +y = [ 0, 0, 0 ]; +out = isEqualInt32Array( x, y ); +// returns false + +x = new Int32Array( [ 1, 2, 3 ] ); +y = new Int32Array( [ 1, 2, 4 ] ); +out = isEqualInt32Array( x, y ); +// returns false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/assert/is-equal-int32array/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/assert/is-equal-int32array/benchmark/benchmark.length.js new file mode 100644 index 000000000000..3f54c1426555 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int32array/benchmark/benchmark.length.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var zeroTo = require( '@stdlib/array/zero-to' ); +var pkg = require( './../package.json' ).name; +var isEqualInt32Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = zeroTo( len, 'int32' ); + var y = zeroTo( len, 'int32' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var bool; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isEqualInt32Array( x, y ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/assert/is-equal-int32array/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-equal-int32array/docs/repl.txt new file mode 100644 index 000000000000..1df00c947204 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int32array/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( v1, v2 ) + Tests if two arguments are both Int32Arrays and have equal values. + + Parameters + ---------- + v1: any + First input value. + + v2: any + Second input value. + + Returns + ------- + bool: boolean + Boolean indicating whether two arguments are equal. + + Examples + -------- + > var x = new {{alias:@stdlib/array/int32}}( [ 1, 2, 3 ] ); + > var y = new {{alias:@stdlib/array/int32}}( [ 1, 2, 3 ] ); + > var bool = {{alias}}( x, y ) + true + + > x = new {{alias:@stdlib/array/int32}}( [ 1, 2, 3 ] ); + > y = new {{alias:@stdlib/array/int32}}( [ 1, 2, 4 ] ); + > bool = {{alias}}( x, y ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/assert/is-equal-int32array/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-equal-int32array/docs/types/index.d.ts new file mode 100644 index 000000000000..4d970732fc12 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int32array/docs/types/index.d.ts @@ -0,0 +1,51 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/** +* Tests if two arguments are both Int32Arrays and have equal values. +* +* @param v1 - first input value +* @param v2 - second input value +* @returns boolean indicating whether two arguments are equal +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var x = new Int32Array( [ 1, 2, 3 ] ); +* var y = new Int32Array( [ 1, 2, 3 ] ); +* +* var out = isEqualInt32Array( x, y ); +* // returns true +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var x = new Int32Array( [ 1, 2, 3 ] ); +* var y = new Int32Array( [ 1, 2, 4 ] ); +* +* var out = isEqualInt32Array( x, y ); +* // returns false +*/ +declare function isEqualInt32Array( v1: any, v2: any ): boolean; + + +// EXPORTS // + +export = isEqualInt32Array; diff --git a/lib/node_modules/@stdlib/assert/is-equal-int32array/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-equal-int32array/docs/types/test.ts new file mode 100644 index 000000000000..400bc0249c59 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int32array/docs/types/test.ts @@ -0,0 +1,36 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import isEqualInt32Array = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isEqualInt32Array( 3.14, 3.14 ); // $ExpectType boolean + isEqualInt32Array( null, null ); // $ExpectType boolean + isEqualInt32Array( 'beep', 'boop' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isEqualInt32Array(); // $ExpectError + isEqualInt32Array( 3.14 ); // $ExpectError + isEqualInt32Array( 'beep', 'beep', 3.14 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-int32array/examples/index.js b/lib/node_modules/@stdlib/assert/is-equal-int32array/examples/index.js new file mode 100644 index 000000000000..d2289bf10d19 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int32array/examples/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var Int32Array = require( '@stdlib/array/int32' ); +var isEqualInt32Array = require( './../lib' ); + +var x = new Int32Array( [ 1, 2, 3 ] ); +var y = new Int32Array( [ 1, 2, 3 ] ); +var out = isEqualInt32Array( x, y ); +console.log( out ); +// => true + +x = new Int32Array( [ 0, 0, 0 ] ); +y = [ 0, 0, 0 ]; +out = isEqualInt32Array( x, y ); +console.log( out ); +// => false + +x = new Int32Array( [ 1, 2, 3 ] ); +y = new Int32Array( [ 1, 2, 4 ] ); +out = isEqualInt32Array( x, y ); +console.log( out ); +// => false diff --git a/lib/node_modules/@stdlib/assert/is-equal-int32array/lib/index.js b/lib/node_modules/@stdlib/assert/is-equal-int32array/lib/index.js new file mode 100644 index 000000000000..7f686644947f --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int32array/lib/index.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Test if two arguments are both Int32Arrays and have equal values. +* +* @module @stdlib/assert/is-equal-int32array +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var isEqualInt32Array = require( '@stdlib/assert/is-equal-int32array' ); +* +* var x = new Int32Array( [ 1, 2, 3 ] ); +* var y = new Int32Array( [ 1, 2, 3 ] ); +* +* var out = isEqualInt32Array( x, y ); +* // returns true +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var isEqualInt32Array = require( '@stdlib/assert/is-equal-int32array' ); +* +* var x = new Int32Array( [ 1, 2, 3 ] ); +* var y = new Int32Array( [ 1, 2, 4 ] ); +* +* var out = isEqualInt32Array( x, y ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/is-equal-int32array/lib/main.js b/lib/node_modules/@stdlib/assert/is-equal-int32array/lib/main.js new file mode 100644 index 000000000000..742dc39f0f5c --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int32array/lib/main.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isInt32Array = require( '@stdlib/assert/is-int32array' ); +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); + + +// MAIN // + +/** +* Tests if two arguments are both Int32Arrays and have equal values. +* +* @param {*} v1 - first value +* @param {*} v2 - second value +* @returns {boolean} boolean result +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var x = new Int32Array( [ 1, 2, 3 ] ); +* var y = new Int32Array( [ 1, 2, 3 ] ); +* +* var out = isEqualInt32Array( x, y ); +* // returns true +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var x = new Int32Array( [ 1, 2, 3 ] ); +* var y = new Int32Array( [ 1, 2, 4 ] ); +* +* var out = isEqualInt32Array( x, y ); +* // returns false +*/ +function isEqualInt32Array( v1, v2 ) { + return ( isInt32Array( v1 ) && isInt32Array( v2 ) && hasEqualValues( v1, v2 ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = isEqualInt32Array; diff --git a/lib/node_modules/@stdlib/assert/is-equal-int32array/package.json b/lib/node_modules/@stdlib/assert/is-equal-int32array/package.json new file mode 100644 index 000000000000..407169643c55 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int32array/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/assert/is-equal-int32array", + "version": "0.0.0", + "description": "Test if two arguments are both Int32Arrays and have equal values.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "equal", + "same", + "strict", + "is", + "isequal", + "isstrictequal", + "type", + "check", + "valid", + "validate", + "test", + "typed", + "array" + ] +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-int32array/test/test.js b/lib/node_modules/@stdlib/assert/is-equal-int32array/test/test.js new file mode 100644 index 000000000000..b9ee65decca0 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int32array/test/test.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Int32Array = require( '@stdlib/array/int32' ); +var typedarray = require( '@stdlib/array/typed' ); +var isEqualInt32Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isEqualInt32Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided two Int32Arrays having equal values', function test( t ) { + var x; + var y; + + x = new Int32Array( [ 1, 2, 3 ] ); + t.strictEqual( isEqualInt32Array( x, x ), true, 'returns expected value' ); + + x = new Int32Array( [ 1, 2, 3 ] ); + y = new Int32Array( [ 1, 2, 3 ] ); + t.strictEqual( isEqualInt32Array( x, y ), true, 'returns expected value' ); + + x = new Int32Array( [ 0, 0, 0 ] ); + y = new Int32Array( [ 0, 0, 0 ] ); + t.strictEqual( isEqualInt32Array( x, y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `false` if not provided two Int32Arrays having equal values', function test( t ) { + var x; + var y; + var i; + + x = [ + '', + 'beep', + 5, + 3.14, + -3.14, + 0.0, + -0.0, + true, + false, + null, + void 0, + [ 1.0 ], + {}, + function noop() {}, + typedarray( 10, 'float64' ), + typedarray( 10, 'int32' ), + typedarray( 10, 'float32' ), + [ 1.0, 2.0, 3.0 ], + [ NaN, NaN, NaN ] + ]; + y = [ + 'abc', + 'boop', + -5, + -3.14, + 3.14, + -0.0, + 0.0, + false, + true, + void 0, + null, + [ -1.0 ], + {}, + function noop() {}, + typedarray( 10, 'float64' ), + typedarray( 10, 'uint32' ), + typedarray( 10, 'float64' ), + [ 2.0, 4.0, 6.0 ], + [ NaN, NaN, NaN ] + ]; + for ( i = 0; i < x.length; i++ ) { + t.strictEqual( isEqualInt32Array( x[ i ], y[ i ] ), false, 'returns expected value when provided '+x[ i ]+' and '+y[ i ] ); + } + t.end(); +}); From c211225353b6474b34ee770eb40e91d73176ce02 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:35:23 -0700 Subject: [PATCH 02/60] refactor: consolidate branching into a single line --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/assert/is-equal-array/lib/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-equal-array/lib/main.js b/lib/node_modules/@stdlib/assert/is-equal-array/lib/main.js index 1538fe90986a..0f8963702a74 100644 --- a/lib/node_modules/@stdlib/assert/is-equal-array/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-equal-array/lib/main.js @@ -48,10 +48,7 @@ var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); * // returns false */ function isEqualArray( v1, v2 ) { - if ( isArray( v1 ) && isArray( v2 ) ) { - return hasEqualValues( v1, v2 ); - } - return false; + return ( isArray( v1 ) && isArray( v2 ) && hasEqualValues( v1, v2 ) ); } From d0356d11a8dbb533e432505033425cdb1975119e Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:36:35 -0700 Subject: [PATCH 03/60] refactor: consolidate into a single line --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/assert/is-same-accessor-array/lib/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-same-accessor-array/lib/main.js b/lib/node_modules/@stdlib/assert/is-same-accessor-array/lib/main.js index 6bcf1b57edbb..edcfcaa6b831 100644 --- a/lib/node_modules/@stdlib/assert/is-same-accessor-array/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-same-accessor-array/lib/main.js @@ -58,10 +58,7 @@ var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); * // returns false */ function isSameAccessorArray( v1, v2 ) { - if ( isAccessorArray( v1 ) && isAccessorArray( v2 ) ) { - return hasSameValues( v1, v2 ); - } - return false; + return ( isAccessorArray( v1 ) && isAccessorArray( v2 ) && hasSameValues( v1, v2 ) ); // eslint-disable-line max-len } From 52fdc1c3fce187d4bac3f072f15156ea0ac90371 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:37:10 -0700 Subject: [PATCH 04/60] refactor: consolidate into a single line --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/assert/is-same-array/lib/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-same-array/lib/main.js b/lib/node_modules/@stdlib/assert/is-same-array/lib/main.js index 60469b928165..5fa15f07977d 100644 --- a/lib/node_modules/@stdlib/assert/is-same-array/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-same-array/lib/main.js @@ -48,10 +48,7 @@ var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); * // returns false */ function isSameArray( v1, v2 ) { - if ( isArray( v1 ) && isArray( v2 ) ) { - return hasSameValues( v1, v2 ); - } - return false; + return ( isArray( v1 ) && isArray( v2 ) && hasSameValues( v1, v2 ) ); } From 76c666029858a1a2b8095b5c597788400155cf1f Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:38:03 -0700 Subject: [PATCH 05/60] refactor: consolidate into single line --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/assert/is-same-array-like/lib/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-same-array-like/lib/main.js b/lib/node_modules/@stdlib/assert/is-same-array-like/lib/main.js index 19961022fb25..f2e64636799a 100644 --- a/lib/node_modules/@stdlib/assert/is-same-array-like/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-same-array-like/lib/main.js @@ -48,10 +48,7 @@ var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); * // returns false */ function isSameArrayLike( v1, v2 ) { - if ( isArrayLike( v1 ) && isArrayLike( v2 ) ) { - return hasSameValues( v1, v2 ); - } - return false; + return ( isArrayLike( v1 ) && isArrayLike( v2 ) && hasSameValues( v1, v2 ) ); // eslint-disable-line max-len } From 34dd8723b2d5273032a355528a8bd736342bd26a Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:39:20 -0700 Subject: [PATCH 06/60] refactor: consolidate into a single line --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/assert/is-same-array-like-object/lib/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-same-array-like-object/lib/main.js b/lib/node_modules/@stdlib/assert/is-same-array-like-object/lib/main.js index 603c33f4f19f..bd7a657f490f 100644 --- a/lib/node_modules/@stdlib/assert/is-same-array-like-object/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-same-array-like-object/lib/main.js @@ -48,10 +48,7 @@ var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); * // returns false */ function isSameArrayLikeObject( v1, v2 ) { - if ( isArrayLikeObject( v1 ) && isArrayLikeObject( v2 ) ) { - return hasSameValues( v1, v2 ); - } - return false; + return ( isArrayLikeObject( v1 ) && isArrayLikeObject( v2 ) && hasSameValues( v1, v2 ) ); // eslint-disable-line max-len } From 5b6e996601393004b47a1b993f0fcf1728923487 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:40:06 -0700 Subject: [PATCH 07/60] refactor: consolidate into a single line --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/assert/is-same-complex128/lib/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-same-complex128/lib/main.js b/lib/node_modules/@stdlib/assert/is-same-complex128/lib/main.js index b92a934043f8..28e1237fa618 100644 --- a/lib/node_modules/@stdlib/assert/is-same-complex128/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-same-complex128/lib/main.js @@ -52,10 +52,7 @@ var isSameValue = require( '@stdlib/complex/float64/base/assert/is-same-value' ) * // returns false */ function isSameComplex128( v1, v2 ) { - if ( isComplex128( v1 ) && isComplex128( v2 ) ) { - return isSameValue( v1, v2 ); - } - return false; + return ( isComplex128( v1 ) && isComplex128( v2 ) && isSameValue( v1, v2 ) ); // eslint-disable-line max-len } From b3a13ca6c8f0d98a616a2113c51e8dafd7aef906 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:40:29 -0700 Subject: [PATCH 08/60] refactor: consolidate into a single line --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/assert/is-same-complex128array/lib/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-same-complex128array/lib/main.js b/lib/node_modules/@stdlib/assert/is-same-complex128array/lib/main.js index 7acf2d7b8b7c..953cff593e93 100644 --- a/lib/node_modules/@stdlib/assert/is-same-complex128array/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-same-complex128array/lib/main.js @@ -52,10 +52,7 @@ var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); * // returns false */ function isSameComplex128Array( v1, v2 ) { - if ( isComplex128Array( v1 ) && isComplex128Array( v2 ) ) { - return hasSameValues( v1, v2 ); - } - return false; + return ( isComplex128Array( v1 ) && isComplex128Array( v2 ) && hasSameValues( v1, v2 ) ); // eslint-disable-line max-len } From f6f9485b3f2b225d51c5409bdcb51384848040bf Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:40:46 -0700 Subject: [PATCH 09/60] refactor: consolidate into a single line --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/assert/is-same-complex64/lib/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-same-complex64/lib/main.js b/lib/node_modules/@stdlib/assert/is-same-complex64/lib/main.js index a13a481b5cdf..e4c256502d37 100644 --- a/lib/node_modules/@stdlib/assert/is-same-complex64/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-same-complex64/lib/main.js @@ -52,10 +52,7 @@ var isSameValuef = require( '@stdlib/complex/float32/base/assert/is-same-value' * // returns false */ function isSameComplex64( v1, v2 ) { - if ( isComplex64( v1 ) && isComplex64( v2 ) ) { - return isSameValuef( v1, v2 ); - } - return false; + return ( isComplex64( v1 ) && isComplex64( v2 ) && isSameValuef( v1, v2 ) ); } From a256f353b37fe5b1cdb0ba900ee1c056a2b54cc2 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:41:41 -0700 Subject: [PATCH 10/60] refactor: consolidate into a single line --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/assert/is-same-complex64array/lib/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-same-complex64array/lib/main.js b/lib/node_modules/@stdlib/assert/is-same-complex64array/lib/main.js index e63b2ae0f594..600f2447be41 100644 --- a/lib/node_modules/@stdlib/assert/is-same-complex64array/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-same-complex64array/lib/main.js @@ -52,10 +52,7 @@ var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); * // returns false */ function isSameComplex64Array( v1, v2 ) { - if ( isComplex64Array( v1 ) && isComplex64Array( v2 ) ) { - return hasSameValues( v1, v2 ); - } - return false; + return ( isComplex64Array( v1 ) && isComplex64Array( v2 ) && hasSameValues( v1, v2 ) ); } From 0c75a9b0f5c86a5b912b073808b1a45ae4d503f8 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:42:10 -0700 Subject: [PATCH 11/60] refactor: consolidate into a single line --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/assert/is-same-date-object/lib/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/lib/main.js b/lib/node_modules/@stdlib/assert/is-same-date-object/lib/main.js index d804d00bcd48..dbc69319c72e 100644 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-same-date-object/lib/main.js @@ -45,10 +45,7 @@ var isDateObject = require( '@stdlib/assert/is-date-object' ); * // returns false */ function isSameDateObject( d1, d2 ) { - if ( isDateObject( d1 ) && isDateObject( d2 ) ) { - return d1.getTime() === d2.getTime(); - } - return false; + return ( isDateObject( d1 ) && isDateObject( d2 ) && ( d1.getTime() === d2.getTime() ) ); // eslint-disable-line max-len } From 3af943de04b70b8151f3db29d0725cf7558c0e94 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:42:31 -0700 Subject: [PATCH 12/60] refactor: consolidate into a single line --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/assert/is-same-float32array/lib/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-same-float32array/lib/main.js b/lib/node_modules/@stdlib/assert/is-same-float32array/lib/main.js index c90ff78f1aef..a88331ed19e1 100644 --- a/lib/node_modules/@stdlib/assert/is-same-float32array/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-same-float32array/lib/main.js @@ -52,10 +52,7 @@ var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); * // returns false */ function isSameFloat32Array( v1, v2 ) { - if ( isFloat32Array( v1 ) && isFloat32Array( v2 ) ) { - return hasSameValues( v1, v2 ); - } - return false; + return ( isFloat32Array( v1 ) && isFloat32Array( v2 ) && hasSameValues( v1, v2 ) ); // eslint-disable-line max-len } From 6a430d7465fae0732b6dfdb13cc5e89c7b6ded2a Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:43:32 -0700 Subject: [PATCH 13/60] refactor: consolidate into a single line --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/assert/is-same-float64array/lib/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-same-float64array/lib/main.js b/lib/node_modules/@stdlib/assert/is-same-float64array/lib/main.js index 801225b7aa46..92010f2e2c41 100644 --- a/lib/node_modules/@stdlib/assert/is-same-float64array/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-same-float64array/lib/main.js @@ -52,10 +52,7 @@ var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); * // returns false */ function isSameFloat64Array( v1, v2 ) { - if ( isFloat64Array( v1 ) && isFloat64Array( v2 ) ) { - return hasSameValues( v1, v2 ); - } - return false; + return ( isFloat64Array( v1 ) && isFloat64Array( v2 ) && hasSameValues( v1, v2 ) ); // eslint-disable-line max-len } From 27489884ce92a99ddc545684e4bbb1c12e4471cd Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:44:01 -0700 Subject: [PATCH 14/60] refactor: consolidate into a single line --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/assert/is-same-typed-array-like/lib/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-same-typed-array-like/lib/main.js b/lib/node_modules/@stdlib/assert/is-same-typed-array-like/lib/main.js index 1844db528431..c19cf9dc7c1f 100644 --- a/lib/node_modules/@stdlib/assert/is-same-typed-array-like/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-same-typed-array-like/lib/main.js @@ -54,10 +54,7 @@ var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); * // returns false */ function isSameTypedArrayLike( v1, v2 ) { - if ( isTypedArrayLike( v1 ) && isTypedArrayLike( v2 ) ) { - return hasSameValues( v1, v2 ); - } - return false; + return ( isTypedArrayLike( v1 ) && isTypedArrayLike( v2 ) && hasSameValues( v1, v2 ) ); // eslint-disable-line max-len } From b0071b257c59721a7f0dc27a30861fe7cca75c4c Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:55:11 -0700 Subject: [PATCH 15/60] feat: add `assert/is-equal-booleanarray` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../assert/is-equal-booleanarray/README.md | 100 +++++++++++++++++ .../benchmark/benchmark.length.js | 106 ++++++++++++++++++ .../is-equal-booleanarray/docs/repl.txt | 32 ++++++ .../docs/types/index.d.ts | 51 +++++++++ .../is-equal-booleanarray/docs/types/test.ts | 36 ++++++ .../is-equal-booleanarray/examples/index.js | 34 ++++++ .../assert/is-equal-booleanarray/lib/index.js | 54 +++++++++ .../assert/is-equal-booleanarray/lib/main.js | 61 ++++++++++ .../assert/is-equal-booleanarray/package.json | 77 +++++++++++++ .../assert/is-equal-booleanarray/test/test.js | 101 +++++++++++++++++ 10 files changed, 652 insertions(+) create mode 100644 lib/node_modules/@stdlib/assert/is-equal-booleanarray/README.md create mode 100644 lib/node_modules/@stdlib/assert/is-equal-booleanarray/benchmark/benchmark.length.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-booleanarray/examples/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-booleanarray/lib/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-booleanarray/lib/main.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-booleanarray/package.json create mode 100644 lib/node_modules/@stdlib/assert/is-equal-booleanarray/test/test.js diff --git a/lib/node_modules/@stdlib/assert/is-equal-booleanarray/README.md b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/README.md new file mode 100644 index 000000000000..8518cd4a221a --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/README.md @@ -0,0 +1,100 @@ + + +# isEqualBooleanArray + +> Test if two arguments are both [BooleanArrays][@stdlib/array/bool] and have equal values. + +
+ +## Usage + +```javascript +var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); +``` + +#### isEqualBooleanArray( v1, v2 ) + +Tests if two arguments are both [BooleanArrays][@stdlib/array/bool] and have equal values. + +```javascript +var BooleanArray = require( '@stdlib/array/bool' ); + +var x = new BooleanArray( [ true, false ] ); +var y = new BooleanArray( [ true, false ] ); +var bool = isEqualBooleanArray( x, y ); +// returns true + +bool = isEqualBooleanArray( x, [ true, false ] ); +// returns false +``` + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var BooleanArray = require( '@stdlib/array/bool' ); +var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); + +var x = new BooleanArray( [ true, false, false, true ] ); +var y = new BooleanArray( [ true, false, false, true ] ); +var out = isEqualBooleanArray( x, y ); +// returns true + +x = new BooleanArray( [ true, false, false, true ] ); +y = new BooleanArray( [ true, true, false, false ] ); +out = isEqualBooleanArray( x, y ); +// returns false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/assert/is-equal-booleanarray/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/benchmark/benchmark.length.js new file mode 100644 index 000000000000..b6dd4ad48f91 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/benchmark/benchmark.length.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var Boolean = require( '@stdlib/boolean/ctor' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var pkg = require( './../package.json' ).name; +var isEqualBooleanArray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x; + var y; + var i; + + x = []; + for ( i = 0; i < len; i++ ) { + x.push( Boolean( i%2 ) ); + } + x = new BooleanArray( x ); + y = new BooleanArray( x ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var bool; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isEqualBooleanArray( x, y ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/repl.txt new file mode 100644 index 000000000000..c2e170686bab --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( v1, v2 ) + Tests if two arguments are both BooleanArrays and have equal values. + + Parameters + ---------- + v1: any + First input value. + + v2: any + Second input value. + + Returns + ------- + bool: boolean + Boolean indicating whether two arguments are equal. + + Examples + -------- + > var x = new {{alias:@stdlib/array/bool}}( [ true, false, false, true ] ); + > var y = new {{alias:@stdlib/array/bool}}( [ true, false, false, true ] ); + > var bool = {{alias}}( x, y ) + true + + > x = new {{alias:@stdlib/array/bool}}( [ true, false, false, true ] ); + > y = new {{alias:@stdlib/array/bool}}( [ true, true, false, false ] ); + > bool = {{alias}}( x, y ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/types/index.d.ts new file mode 100644 index 000000000000..5e603a44ec7d --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/types/index.d.ts @@ -0,0 +1,51 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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. +*/ + +// TypeScript Version: 4.1 + +/** +* Tests if two arguments are both BooleanArrays and have equal values. +* +* @param v1 - first input value +* @param v2 - second input value +* @returns boolean indicating whether two arguments are equal +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* +* var x = new BooleanArray( [ true, false, false, true ] ); +* var y = new BooleanArray( [ true, false, false, true ] ); +* +* var out = isEqualBooleanArray( x, y ); +* // returns true +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* +* var x = new BooleanArray( [ true, false, false, true ] ); +* var y = new BooleanArray( [ true, true, false, false ] ); +* +* var out = isEqualBooleanArray( x, y ); +* // returns false +*/ +declare function isEqualBooleanArray( v1: any, v2: any ): boolean; + + +// EXPORTS // + +export = isEqualBooleanArray; diff --git a/lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/types/test.ts new file mode 100644 index 000000000000..3dc546d5f148 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/types/test.ts @@ -0,0 +1,36 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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. +*/ + +import isEqualBooleanArray = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isEqualBooleanArray( true, true ); // $ExpectType boolean + isEqualBooleanArray( null, null ); // $ExpectType boolean + isEqualBooleanArray( 'beep', 'boop' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isEqualBooleanArray(); // $ExpectError + isEqualBooleanArray( 3.14 ); // $ExpectError + isEqualBooleanArray( 'beep', 'beep', 3.14 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-booleanarray/examples/index.js b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/examples/index.js new file mode 100644 index 000000000000..b49411df58f3 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/examples/index.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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'; + +var BooleanArray = require( '@stdlib/array/bool' ); +var isEqualBooleanArray = require( './../lib' ); + +var x = new BooleanArray( [ true, false, false, true ] ); +var y = new BooleanArray( [ true, false, false, true ] ); +var out = isEqualBooleanArray( x, y ); +console.log( out ); +// => true + +x = new BooleanArray( [ true, false, false, true ] ); +y = new BooleanArray( [ true, true, false, false ] ); +out = isEqualBooleanArray( x, y ); +console.log( out ); +// => false diff --git a/lib/node_modules/@stdlib/assert/is-equal-booleanarray/lib/index.js b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/lib/index.js new file mode 100644 index 000000000000..83a33140552a --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/lib/index.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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'; + +/** +* Test if two arguments are both BooleanArrays and have equal values. +* +* @module @stdlib/assert/is-equal-booleanarray +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); +* +* var x = new BooleanArray( [ true, false, false, true ] ); +* var y = new BooleanArray( [ true, false, false, true ] ); +* +* var out = isEqualBooleanArray( x, y ); +* // returns true +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); +* +* var x = new BooleanArray( [ true, false, false, true ] ); +* var y = new BooleanArray( [ true, true, false, false ] ); +* +* var out = isEqualBooleanArray( x, y ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/is-equal-booleanarray/lib/main.js b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/lib/main.js new file mode 100644 index 000000000000..c133b926ea44 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/lib/main.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); + + +// MAIN // + +/** +* Tests if two arguments are both BooleanArrays and have equal values. +* +* @param {*} v1 - first value +* @param {*} v2 - second value +* @returns {boolean} boolean result +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* +* var x = new BooleanArray( [ true, false, false, true ] ); +* var y = new BooleanArray( [ true, false, false, true ] ); +* +* var out = isEqualBooleanArray( x, y ); +* // returns true +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* +* var x = new BooleanArray( [ true, false, false, true ] ); +* var y = new BooleanArray( [ true, true, false, false ] ); +* +* var out = isEqualBooleanArray( x, y ); +* // returns false +*/ +function isEqualBooleanArray( v1, v2 ) { + return ( isBooleanArray( v1 ) && isBooleanArray( v2 ) && hasEqualValues( v1, v2 ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = isEqualBooleanArray; diff --git a/lib/node_modules/@stdlib/assert/is-equal-booleanarray/package.json b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/package.json new file mode 100644 index 000000000000..884ab378d5db --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/package.json @@ -0,0 +1,77 @@ +{ + "name": "@stdlib/assert/is-equal-booleanarray", + "version": "0.0.0", + "description": "Test if two arguments are both BooleanArrays and have equal values.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "equal", + "same", + "strict", + "is", + "issame", + "issamevalue", + "isequal", + "isstrictequal", + "type", + "check", + "valid", + "validate", + "test", + "typed", + "array", + "bool" + ] +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-booleanarray/test/test.js b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/test/test.js new file mode 100644 index 000000000000..e34172d397a5 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/test/test.js @@ -0,0 +1,101 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 typedarray = require( '@stdlib/array/typed' ); +var isEqualBooleanArray = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isEqualBooleanArray, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided two BooleanArrays having equal values', function test( t ) { + var x; + var y; + + x = typedarray( [ 1, 0, 0, 1 ], 'bool' ); + t.strictEqual( isEqualBooleanArray( x, x ), true, 'returns expected value' ); + + x = typedarray( [ 1, 0, 0, 1 ], 'bool' ); + y = typedarray( [ 1, 0, 0, 1 ], 'bool' ); + t.strictEqual( isEqualBooleanArray( x, y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `false` if not provided two BooleanArrays having equal values', function test( t ) { + var x; + var y; + var i; + + x = [ + '', + 'beep', + 5, + 3.14, + -3.14, + 0.0, + -0.0, + true, + false, + null, + void 0, + [], + {}, + function noop() {}, + typedarray( 10, 'float32' ), + typedarray( 10, 'int32' ), + typedarray( 10, 'bool' ), + typedarray( [ 1.0, 2.0, 3.0, 4.0 ], 'complex64' ), + typedarray( [ 0, 0, 0, 0 ], 'bool' ) + ]; + y = [ + 'abc', + 'boop', + -5, + -3.14, + 3.14, + -0.0, + 0.0, + false, + true, + void 0, + null, + [], + {}, + function noop() {}, + typedarray( 10, 'float32' ), + typedarray( 10, 'int32' ), + typedarray( 10, 'float32' ), + typedarray( [ 2.0, 4.0, 6.0, 8.0 ], 'complex64' ), + typedarray( [ 0, 0, 0, 1 ], 'bool' ) + ]; + for ( i = 0; i < x.length; i++ ) { + t.strictEqual( isEqualBooleanArray( x[ i ], y[ i ] ), false, 'returns expected value when provided '+x[ i ]+' and '+y[ i ] ); + } + t.end(); +}); From b6b1bb1cac8664502e870976f41dc3d1143e229c Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:58:45 -0700 Subject: [PATCH 16/60] refactor: update import paths --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../array/base/mskfilter/test/test.assign.js | 14 +++++++------- .../array/base/mskreject/test/test.assign.js | 14 +++++++------- .../@stdlib/array/base/take/test/test.assign.js | 12 ++++++------ .../@stdlib/array/base/without/test/test.assign.js | 8 ++++---- .../@stdlib/array/from-scalar/test/test.js | 8 ++++---- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/node_modules/@stdlib/array/base/mskfilter/test/test.assign.js b/lib/node_modules/@stdlib/array/base/mskfilter/test/test.assign.js index 852fd29e5929..baba0c4c1a7a 100644 --- a/lib/node_modules/@stdlib/array/base/mskfilter/test/test.assign.js +++ b/lib/node_modules/@stdlib/array/base/mskfilter/test/test.assign.js @@ -26,7 +26,7 @@ var BooleanArray = require( '@stdlib/array/bool' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var Int32Array = require( '@stdlib/array/int32' ); var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' ); +var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); var zeros = require( '@stdlib/array/zeros' ); var mskfilter = require( './../lib/assign.js' ); @@ -210,7 +210,7 @@ tape( 'the function filters array elements (boolean array)', function test( t ) expected = new BooleanArray( [ false, true ] ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); mask = [ 0, 0, 0, 0 ]; out = new BooleanArray( 0 ); @@ -218,7 +218,7 @@ tape( 'the function filters array elements (boolean array)', function test( t ) expected = new BooleanArray( [] ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); mask = [ 0, 0, 0, 1 ]; out = new BooleanArray( 1 ); @@ -226,7 +226,7 @@ tape( 'the function filters array elements (boolean array)', function test( t ) expected = new BooleanArray( [ true ] ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); mask = [ 1, 1, 1, 1 ]; out = new BooleanArray( 4 ); @@ -234,7 +234,7 @@ tape( 'the function filters array elements (boolean array)', function test( t ) expected = new BooleanArray( [ true, false, false, true ] ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); mask = [ 0, 1, 0, 1 ]; out = new BooleanArray( 4 ); @@ -242,7 +242,7 @@ tape( 'the function filters array elements (boolean array)', function test( t ) expected = new BooleanArray( [ false, true, false, false ] ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); t.end(); }); @@ -343,7 +343,7 @@ tape( 'the function returns leaves an output array unchanged if provided a secon out = new BooleanArray( [ false, false, false, false ] ); expected = new BooleanArray( [ false, false, false, false ] ); actual = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/array/base/mskreject/test/test.assign.js b/lib/node_modules/@stdlib/array/base/mskreject/test/test.assign.js index d2864e1cde39..ed4d04c3a226 100644 --- a/lib/node_modules/@stdlib/array/base/mskreject/test/test.assign.js +++ b/lib/node_modules/@stdlib/array/base/mskreject/test/test.assign.js @@ -26,7 +26,7 @@ var BooleanArray = require( '@stdlib/array/bool' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var Int32Array = require( '@stdlib/array/int32' ); var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' ); +var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); var zeros = require( '@stdlib/array/zeros' ); var mskreject = require( './../lib/assign.js' ); @@ -210,7 +210,7 @@ tape( 'the function rejects array elements (boolean array)', function test( t ) expected = new BooleanArray( [ false, true ] ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); mask = [ 1, 1, 1, 1 ]; out = new BooleanArray( 0 ); @@ -218,7 +218,7 @@ tape( 'the function rejects array elements (boolean array)', function test( t ) expected = new BooleanArray( [] ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); mask = [ 1, 1, 1, 0 ]; out = new BooleanArray( 1 ); @@ -226,7 +226,7 @@ tape( 'the function rejects array elements (boolean array)', function test( t ) expected = new BooleanArray( [ true ] ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); mask = [ 0, 0, 0, 0 ]; out = new BooleanArray( 4 ); @@ -234,7 +234,7 @@ tape( 'the function rejects array elements (boolean array)', function test( t ) expected = new BooleanArray( [ true, false, false, true ] ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); mask = [ 1, 0, 1, 0 ]; out = new BooleanArray( 4 ); @@ -242,7 +242,7 @@ tape( 'the function rejects array elements (boolean array)', function test( t ) expected = new BooleanArray( [ false, true, false, false ] ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); t.end(); }); @@ -343,7 +343,7 @@ tape( 'the function returns leaves an output array unchanged if provided a secon out = new BooleanArray( [ false, false, false, false ] ); expected = new BooleanArray( [ false, false, false, false ] ); actual = mskreject( x, mask, out, 1, 0 ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/array/base/take/test/test.assign.js b/lib/node_modules/@stdlib/array/base/take/test/test.assign.js index 1fad572c9b60..42859d24512d 100644 --- a/lib/node_modules/@stdlib/array/base/take/test/test.assign.js +++ b/lib/node_modules/@stdlib/array/base/take/test/test.assign.js @@ -28,7 +28,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' ); +var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); var zeros = require( '@stdlib/array/zeros' ); var take = require( './../lib/assign.js' ); @@ -190,7 +190,7 @@ tape( 'the function takes elements from an array (boolean array)', function test expected = new BooleanArray( [ false, true ] ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); indices = [ 1, 1, 3, 3 ]; out = new BooleanArray( indices.length*2 ); @@ -198,7 +198,7 @@ tape( 'the function takes elements from an array (boolean array)', function test expected = new BooleanArray( [ false, false, false, false, true, false, true, false ] ); // eslint-disable-line max-len t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); indices = [ 3, 2, 1, 0 ]; out = new BooleanArray( indices.length ); @@ -206,7 +206,7 @@ tape( 'the function takes elements from an array (boolean array)', function test expected = new BooleanArray( [ true, false, false, true ] ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); indices = [ 1, 1, 1, 1 ]; out = new BooleanArray( indices.length+1 ); @@ -214,7 +214,7 @@ tape( 'the function takes elements from an array (boolean array)', function test expected = new BooleanArray( [ false, false, false, false, false ] ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); t.end(); }); @@ -304,7 +304,7 @@ tape( 'the function returns leaves an output array unchanged if provided a secon out = new BooleanArray( [ false, false, false, false ] ); expected = new BooleanArray( [ false, false, false, false ] ); actual = take( x, [], 'throw', out, 1, 0 ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/array/base/without/test/test.assign.js b/lib/node_modules/@stdlib/array/base/without/test/test.assign.js index fbd359fc2b81..40202622b32d 100644 --- a/lib/node_modules/@stdlib/array/base/without/test/test.assign.js +++ b/lib/node_modules/@stdlib/array/base/without/test/test.assign.js @@ -27,7 +27,7 @@ var Complex128Array = require( '@stdlib/array/complex128' ); var BooleanArray = require( '@stdlib/array/bool' ); var AccessorArray = require( '@stdlib/array/base/accessor' ); var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' ); +var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); var zeros = require( '@stdlib/array/zeros' ); var without = require( './../lib/assign.js' ); @@ -365,21 +365,21 @@ tape( 'the function copies elements to another array and sets an element at a sp actual = without( x, 0, out, 1, 0 ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); out = new BooleanArray( (x.length-1)*2 ); expected = new BooleanArray( [ 1, 0, 1, 0, 1, 0 ] ); actual = without( x, 1, out, 2, 0 ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); out = new BooleanArray( (x.length-1)*2 ); expected = new BooleanArray( [ 0, 1, 0, 1, 0, 1 ] ); actual = without( x, 2, out, -2, out.length-1 ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/array/from-scalar/test/test.js b/lib/node_modules/@stdlib/array/from-scalar/test/test.js index 1f968fda3738..a8f8d9af84db 100644 --- a/lib/node_modules/@stdlib/array/from-scalar/test/test.js +++ b/lib/node_modules/@stdlib/array/from-scalar/test/test.js @@ -29,7 +29,7 @@ var BooleanArray = require( '@stdlib/array/bool' ); var Float64Array = require( '@stdlib/array/float64' ); var Float32Array = require( '@stdlib/array/float32' ); var Int32Array = require( '@stdlib/array/int32' ); -var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' ); +var isEqualBooleanArray = require( '@stdlib/assert/is-booleanarray' ); var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); @@ -87,7 +87,7 @@ tape( 'the function returns a single element containing a provided scalar value actual = array2scalar( true ); expected = new BooleanArray( [ true ] ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); t.end(); }); @@ -192,12 +192,12 @@ tape( 'the function returns a single element containing a provided scalar value actual = array2scalar( false, 'bool' ); expected = new BooleanArray( [ false ] ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); actual = array2scalar( true, 'bool' ); expected = new BooleanArray( [ true ] ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); t.end(); }); From 6e6299ec821002ff57bd4f4d6f3fd7a0e56a77bd Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 22:59:52 -0700 Subject: [PATCH 17/60] remove: remove `assert/is-same-booleanarray` This commit removes `@stdlib/assert/is-same-booleanarray` in favor of `@stdlib/assert/is-equal-booleanarray`. BREAKING CHANGE: remove `assert/is-same-booleanarray` To migrate, users should update their import paths to use `@stdlib/assert/is-equal-booleanarray`. The behavior is the same. The removed package used the same value algorithm which is not necessary for comparing boolean values. By migrating to use `is-equal-booleanarray`, the comparison should faster and have better performance, as the underlying implementation uses strict equality. --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../assert/is-same-booleanarray/README.md | 102 ----------------- .../benchmark/benchmark.length.js | 106 ------------------ .../assert/is-same-booleanarray/docs/repl.txt | 32 ------ .../docs/types/index.d.ts | 51 --------- .../is-same-booleanarray/docs/types/test.ts | 36 ------ .../is-same-booleanarray/examples/index.js | 34 ------ .../assert/is-same-booleanarray/lib/index.js | 54 --------- .../assert/is-same-booleanarray/lib/main.js | 64 ----------- .../assert/is-same-booleanarray/package.json | 77 ------------- .../assert/is-same-booleanarray/test/test.js | 101 ----------------- 10 files changed, 657 deletions(-) delete mode 100644 lib/node_modules/@stdlib/assert/is-same-booleanarray/README.md delete mode 100644 lib/node_modules/@stdlib/assert/is-same-booleanarray/benchmark/benchmark.length.js delete mode 100644 lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/repl.txt delete mode 100644 lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/types/index.d.ts delete mode 100644 lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/types/test.ts delete mode 100644 lib/node_modules/@stdlib/assert/is-same-booleanarray/examples/index.js delete mode 100644 lib/node_modules/@stdlib/assert/is-same-booleanarray/lib/index.js delete mode 100644 lib/node_modules/@stdlib/assert/is-same-booleanarray/lib/main.js delete mode 100644 lib/node_modules/@stdlib/assert/is-same-booleanarray/package.json delete mode 100644 lib/node_modules/@stdlib/assert/is-same-booleanarray/test/test.js diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/README.md b/lib/node_modules/@stdlib/assert/is-same-booleanarray/README.md deleted file mode 100644 index b069aecf20d7..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/README.md +++ /dev/null @@ -1,102 +0,0 @@ - - -# isSameBooleanArray - -> Test if two arguments are both [BooleanArrays][@stdlib/array/bool] and have the [same values][@stdlib/assert/is-same-value]. - -
- -## Usage - -```javascript -var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' ); -``` - -#### isSameBooleanArray( v1, v2 ) - -Tests if two arguments are both [BooleanArrays][@stdlib/array/bool] and have the [same values][@stdlib/assert/is-same-value]. - -```javascript -var BooleanArray = require( '@stdlib/array/bool' ); - -var x = new BooleanArray( [ true, false ] ); -var y = new BooleanArray( [ true, false ] ); -var bool = isSameBooleanArray( x, y ); -// returns true - -bool = isSameBooleanArray( x, [ true, false ] ); -// returns false -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var BooleanArray = require( '@stdlib/array/bool' ); -var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' ); - -var x = new BooleanArray( [ true, false, false, true ] ); -var y = new BooleanArray( [ true, false, false, true ] ); -var out = isSameBooleanArray( x, y ); -// returns true - -x = new BooleanArray( [ true, false, false, true ] ); -y = new BooleanArray( [ true, true, false, false ] ); -out = isSameBooleanArray( x, y ); -// returns false -``` - -
- - - - - - - - - - - - - - diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/assert/is-same-booleanarray/benchmark/benchmark.length.js deleted file mode 100644 index 82a55c1b563d..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/benchmark/benchmark.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pow = require( '@stdlib/math/base/special/pow' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var BooleanArray = require( '@stdlib/array/bool' ); -var pkg = require( './../package.json' ).name; -var isSameBooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var y; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( Boolean( i%2 ) ); - } - x = new BooleanArray( x ); - y = new BooleanArray( x ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = isSameBooleanArray( x, y ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/repl.txt deleted file mode 100644 index 9ed0fbe15ef8..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( v1, v2 ) - Tests if two arguments are both BooleanArrays and have the same values. - - Parameters - ---------- - v1: any - First input value. - - v2: any - Second input value. - - Returns - ------- - bool: boolean - Boolean indicating whether two arguments are the same. - - Examples - -------- - > var x = new {{alias:@stdlib/array/bool}}( [ true, false, false, true ] ); - > var y = new {{alias:@stdlib/array/bool}}( [ true, false, false, true ] ); - > var bool = {{alias}}( x, y ) - true - - > x = new {{alias:@stdlib/array/bool}}( [ true, false, false, true ] ); - > y = new {{alias:@stdlib/array/bool}}( [ true, true, false, false ] ); - > bool = {{alias}}( x, y ) - false - - See Also - -------- - diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/types/index.d.ts deleted file mode 100644 index cc768f78a9ef..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/types/index.d.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 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. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if two arguments are both BooleanArrays and have the same values. -* -* @param v1 - first input value -* @param v2 - second input value -* @returns boolean indicating whether two arguments are the same -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var x = new BooleanArray( [ true, false, false, true ] ); -* var y = new BooleanArray( [ true, false, false, true ] ); -* -* var out = isSameBooleanArray( x, y ); -* // returns true -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var x = new BooleanArray( [ true, false, false, true ] ); -* var y = new BooleanArray( [ true, true, false, false ] ); -* -* var out = isSameBooleanArray( x, y ); -* // returns false -*/ -declare function isSameBooleanArray( v1: any, v2: any ): boolean; - - -// EXPORTS // - -export = isSameBooleanArray; diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/types/test.ts deleted file mode 100644 index 27aec976ac81..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 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. -*/ - -import isSameBooleanArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isSameBooleanArray( true, true ); // $ExpectType boolean - isSameBooleanArray( null, null ); // $ExpectType boolean - isSameBooleanArray( 'beep', 'boop' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isSameBooleanArray(); // $ExpectError - isSameBooleanArray( 3.14 ); // $ExpectError - isSameBooleanArray( 'beep', 'beep', 3.14 ); // $ExpectError -} diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/examples/index.js b/lib/node_modules/@stdlib/assert/is-same-booleanarray/examples/index.js deleted file mode 100644 index e0899ff43005..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/examples/index.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 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'; - -var BooleanArray = require( '@stdlib/array/bool' ); -var isSameBooleanArray = require( './../lib' ); - -var x = new BooleanArray( [ true, false, false, true ] ); -var y = new BooleanArray( [ true, false, false, true ] ); -var out = isSameBooleanArray( x, y ); -console.log( out ); -// => true - -x = new BooleanArray( [ true, false, false, true ] ); -y = new BooleanArray( [ true, true, false, false ] ); -out = isSameBooleanArray( x, y ); -console.log( out ); -// => false diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/lib/index.js b/lib/node_modules/@stdlib/assert/is-same-booleanarray/lib/index.js deleted file mode 100644 index 0620d6d52255..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/lib/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 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'; - -/** -* Test if two arguments are both BooleanArrays and have the same values. -* -* @module @stdlib/assert/is-same-booleanarray -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' ); -* -* var x = new BooleanArray( [ true, false, false, true ] ); -* var y = new BooleanArray( [ true, false, false, true ] ); -* -* var out = isSameBooleanArray( x, y ); -* // returns true -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' ); -* -* var x = new BooleanArray( [ true, false, false, true ] ); -* var y = new BooleanArray( [ true, true, false, false ] ); -* -* var out = isSameBooleanArray( x, y ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/lib/main.js b/lib/node_modules/@stdlib/assert/is-same-booleanarray/lib/main.js deleted file mode 100644 index ca2162e2a5aa..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/lib/main.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 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 isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); - - -// MAIN // - -/** -* Tests if two arguments are both BooleanArrays and have the same values. -* -* @param {*} v1 - first value -* @param {*} v2 - second value -* @returns {boolean} boolean result -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var x = new BooleanArray( [ true, false, false, true ] ); -* var y = new BooleanArray( [ true, false, false, true ] ); -* -* var out = isSameBooleanArray( x, y ); -* // returns true -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var x = new BooleanArray( [ true, false, false, true ] ); -* var y = new BooleanArray( [ true, true, false, false ] ); -* -* var out = isSameBooleanArray( x, y ); -* // returns false -*/ -function isSameBooleanArray( v1, v2 ) { - if ( isBooleanArray( v1 ) && isBooleanArray( v2 ) ) { - return hasSameValues( v1, v2 ); - } - return false; -} - - -// EXPORTS // - -module.exports = isSameBooleanArray; diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/package.json b/lib/node_modules/@stdlib/assert/is-same-booleanarray/package.json deleted file mode 100644 index ff14fd60947c..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/package.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "name": "@stdlib/assert/is-same-booleanarray", - "version": "0.0.0", - "description": "Test if two arguments are both BooleanArrays and have the same values.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdassert", - "assertion", - "assert", - "utilities", - "utility", - "utils", - "util", - "equal", - "same", - "strict", - "is", - "issame", - "issamevalue", - "isequal", - "isstrictequal", - "type", - "check", - "valid", - "validate", - "test", - "typed", - "array", - "bool" - ] -} diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/test/test.js b/lib/node_modules/@stdlib/assert/is-same-booleanarray/test/test.js deleted file mode 100644 index 4624cf3d3f86..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/test/test.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 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 typedarray = require( '@stdlib/array/typed' ); -var isSameBooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isSameBooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided two BooleanArrays having the same values', function test( t ) { - var x; - var y; - - x = typedarray( [ 1, 0, 0, 1 ], 'bool' ); - t.strictEqual( isSameBooleanArray( x, x ), true, 'returns expected value' ); - - x = typedarray( [ 1, 0, 0, 1 ], 'bool' ); - y = typedarray( [ 1, 0, 0, 1 ], 'bool' ); - t.strictEqual( isSameBooleanArray( x, y ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if not provided two BooleanArrays having the same values', function test( t ) { - var x; - var y; - var i; - - x = [ - '', - 'beep', - 5, - 3.14, - -3.14, - 0.0, - -0.0, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - typedarray( 10, 'float32' ), - typedarray( 10, 'int32' ), - typedarray( 10, 'bool' ), - typedarray( [ 1.0, 2.0, 3.0, 4.0 ], 'complex64' ), - typedarray( [ 0, 0, 0, 0 ], 'bool' ) - ]; - y = [ - 'abc', - 'boop', - -5, - -3.14, - 3.14, - -0.0, - 0.0, - false, - true, - void 0, - null, - [], - {}, - function noop() {}, - typedarray( 10, 'float32' ), - typedarray( 10, 'int32' ), - typedarray( 10, 'float32' ), - typedarray( [ 2.0, 4.0, 6.0, 8.0 ], 'complex64' ), - typedarray( [ 0, 0, 0, 1 ], 'bool' ) - ]; - for ( i = 0; i < x.length; i++ ) { - t.strictEqual( isSameBooleanArray( x[ i ], y[ i ] ), false, 'returns expected value when provided '+x[ i ]+' and '+y[ i ] ); - } - t.end(); -}); From 2562ae5291e724fdef5468e80789f427afec669e Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 23:03:26 -0700 Subject: [PATCH 18/60] feat: add `isEqualBooleanArray` to namespace --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/assert/lib/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/lib/index.js b/lib/node_modules/@stdlib/assert/lib/index.js index 30f116c28f64..760a08b7f3bc 100644 --- a/lib/node_modules/@stdlib/assert/lib/index.js +++ b/lib/node_modules/@stdlib/assert/lib/index.js @@ -1170,6 +1170,15 @@ setReadOnly( ns, 'isEnumerablePropertyIn', require( '@stdlib/assert/is-enumerabl */ setReadOnly( ns, 'isEqualArray', require( '@stdlib/assert/is-equal-array' ) ); +/** +* @name isEqualBooleanArray +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-equal-booleanarray} +*/ +setReadOnly( ns, 'isEqualBooleanArray', require( '@stdlib/assert/is-equal-booleanarray' ) ); + /** * @name isError * @memberof ns From 4bd2e6d16c24ce62967d5cd43b6b5a63b8820675 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 23:04:11 -0700 Subject: [PATCH 19/60] feat: add `isEqualInt32Array` to namespace --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/assert/lib/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/lib/index.js b/lib/node_modules/@stdlib/assert/lib/index.js index 760a08b7f3bc..371471c9ab09 100644 --- a/lib/node_modules/@stdlib/assert/lib/index.js +++ b/lib/node_modules/@stdlib/assert/lib/index.js @@ -1179,6 +1179,15 @@ setReadOnly( ns, 'isEqualArray', require( '@stdlib/assert/is-equal-array' ) ); */ setReadOnly( ns, 'isEqualBooleanArray', require( '@stdlib/assert/is-equal-booleanarray' ) ); +/** +* @name isEqualInt32Array +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-equal-int32array} +*/ +setReadOnly( ns, 'isEqualInt32Array', require( '@stdlib/assert/is-equal-int32array' ) ); + /** * @name isError * @memberof ns From ccf69dc0beccc374941e7edfb766a1732d994cbd Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 23:05:05 -0700 Subject: [PATCH 20/60] docs: fix description --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/assert/is-booleanarray/lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-booleanarray/lib/main.js b/lib/node_modules/@stdlib/assert/is-booleanarray/lib/main.js index 85290e8b5fd2..81172709d977 100644 --- a/lib/node_modules/@stdlib/assert/is-booleanarray/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-booleanarray/lib/main.js @@ -27,7 +27,7 @@ var constructorName = require( '@stdlib/utils/constructor-name' ); // MAIN // /** -* Tests if a value is a Complex64Array. +* Tests if a value is a BooleanArray. * * @param {*} value - value to test * @returns {boolean} boolean indicating whether a value is a BooleanArray From 3e1cf706cab583d76379448eed6b973c194a12f4 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 23:06:08 -0700 Subject: [PATCH 21/60] feat: add `isSameAccessorArray` to namespace --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/assert/lib/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/lib/index.js b/lib/node_modules/@stdlib/assert/lib/index.js index 371471c9ab09..d62319864239 100644 --- a/lib/node_modules/@stdlib/assert/lib/index.js +++ b/lib/node_modules/@stdlib/assert/lib/index.js @@ -2214,6 +2214,15 @@ setReadOnly( ns, 'isSafeInteger', require( '@stdlib/assert/is-safe-integer' ) ); */ setReadOnly( ns, 'isSafeIntegerArray', require( '@stdlib/assert/is-safe-integer-array' ) ); +/** +* @name isSameAccessorArray +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-same-accessor-array} +*/ +setReadOnly( ns, 'isSameAccessorArray', require( '@stdlib/assert/is-same-accessor-array' ) ); + /** * @name isSameArray * @memberof ns From 4c3778042bee27fe41910c5c0ec94a5c5c219f13 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 23:06:50 -0700 Subject: [PATCH 22/60] feat: add `isSameArrayLikeObject` to namespace --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/assert/lib/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/lib/index.js b/lib/node_modules/@stdlib/assert/lib/index.js index d62319864239..6fc6bb350c24 100644 --- a/lib/node_modules/@stdlib/assert/lib/index.js +++ b/lib/node_modules/@stdlib/assert/lib/index.js @@ -2241,6 +2241,15 @@ setReadOnly( ns, 'isSameArray', require( '@stdlib/assert/is-same-array' ) ); */ setReadOnly( ns, 'isSameArrayLike', require( '@stdlib/assert/is-same-array-like' ) ); +/** +* @name isSameArrayLikeObject +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-same-array-like-object} +*/ +setReadOnly( ns, 'isSameArrayLikeObject', require( '@stdlib/assert/is-same-array-like-object' ) ); + /** * @name isSameComplex64 * @memberof ns From da7cd36c6233b19e9ebc5140ee497b95e822559a Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 23:08:52 -0700 Subject: [PATCH 23/60] feat: add `isSameTypedArrayLike` to namespace --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/assert/lib/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/lib/index.js b/lib/node_modules/@stdlib/assert/lib/index.js index 6fc6bb350c24..4905de127107 100644 --- a/lib/node_modules/@stdlib/assert/lib/index.js +++ b/lib/node_modules/@stdlib/assert/lib/index.js @@ -2322,6 +2322,15 @@ setReadOnly( ns, 'isSameNativeClass', require( '@stdlib/assert/is-same-native-cl */ setReadOnly( ns, 'isSameType', require( '@stdlib/assert/is-same-type' ) ); +/** +* @name isSameTypedArrayLike +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-same-typed-array-like} +*/ +setReadOnly( ns, 'isSameTypedArrayLike', require( '@stdlib/assert/is-same-typed-array-like' ) ); + /** * @name isSameValue * @memberof ns From dd4918035f7c85aa0d69697e9d1eb05bc7688ee2 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 23:14:42 -0700 Subject: [PATCH 24/60] feat: add `assert/is-equal-date-object` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../assert/is-equal-date-object/README.md | 90 +++++++++++++++++++ .../benchmark/benchmark.js | 62 +++++++++++++ .../assert/is-equal-date-object/docs/repl.txt | 32 +++++++ .../docs/types/index.d.ts | 47 ++++++++++ .../is-equal-date-object/docs/types/test.ts | 36 ++++++++ .../is-equal-date-object/examples/index.js | 51 +++++++++++ .../assert/is-equal-date-object/lib/index.js | 52 +++++++++++ .../assert/is-equal-date-object/lib/main.js | 54 +++++++++++ .../assert/is-equal-date-object/package.json | 77 ++++++++++++++++ .../assert/is-equal-date-object/test/test.js | 90 +++++++++++++++++++ 10 files changed, 591 insertions(+) create mode 100644 lib/node_modules/@stdlib/assert/is-equal-date-object/README.md create mode 100644 lib/node_modules/@stdlib/assert/is-equal-date-object/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-date-object/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/assert/is-equal-date-object/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-date-object/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-date-object/examples/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-date-object/lib/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-date-object/lib/main.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-date-object/package.json create mode 100644 lib/node_modules/@stdlib/assert/is-equal-date-object/test/test.js diff --git a/lib/node_modules/@stdlib/assert/is-equal-date-object/README.md b/lib/node_modules/@stdlib/assert/is-equal-date-object/README.md new file mode 100644 index 000000000000..a5391201c000 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/README.md @@ -0,0 +1,90 @@ + + +# isEqualDateObject + +> Test if two values are [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) objects corresponding to the same date and time. + +
+ +## Usage + +```javascript +var isEqualDateObject = require( '@stdlib/assert/is-equal-date-object' ); +``` + +#### isEqualDateObject( d1, d2 ) + +Tests if two values are both Date objects corresponding to the same date and time. + +```javascript +var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +var bool = isEqualDateObject( d1, d2 ); +// returns true + +bool = isEqualDateObject( d1, new Date( 2023, 11, 31, 23, 59, 59, 78 ) ); +// returns false +``` + +
+ + + +
+ +## Examples + + + +```javascript +var isEqualDateObject = require( '@stdlib/assert/is-equal-date-object' ); + +var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + +var bool = isEqualDateObject( d1, d2 ); +// returns true + +d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); + +bool = isEqualDateObject( d1, d2 ); +// returns false + +d1 = new Date(); +d2 = new Date( '2024-12-31T23:59:59.999' ); + +bool = isEqualDateObject( d1, d2 ); +// returns false + +var d3 = new Date( 2024, 11, 31 ); +var d4 = new Date( 'December 31, 2024 23:59:59:999' ); + +bool = isEqualDateObject( d1, d3 ); +// returns false + +bool = isEqualDateObject( d2, d4 ); +// returns true +``` + +
+ + diff --git a/lib/node_modules/@stdlib/assert/is-equal-date-object/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/is-equal-date-object/benchmark/benchmark.js new file mode 100644 index 000000000000..5430e44de47b --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/benchmark/benchmark.js @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var isEqualDateObject = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var date1; + var date2; + var bool; + var i; + values = [ + '5', + 'Date', + new Date( 'December 31, 2024 23:59:59:999' ), + new Date( '2024-12-31T23:59:59.999' ), + NaN, + true, + false, + null + ]; + date1 = new Date(); + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + date2 = values[ i%values.length ]; + bool = isEqualDateObject( date1, date2 ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/assert/is-equal-date-object/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-equal-date-object/docs/repl.txt new file mode 100644 index 000000000000..e4f3c43ab945 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( d1, d2 ) + Tests if two values are both Date objects corresponding to the same date + and time. + + Parameters + ---------- + d1: any + First input value. + d2: any + Second input value. + + Returns + ------- + bool: boolean + Boolean indicating whether both values are Date objects corresponding to + the same date and time. + + Examples + -------- + > var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + > var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + > var bool = {{alias}}( d1, d2 ) + true + > d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + > d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); + > bool = {{alias}}( d1, d2 ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/assert/is-equal-date-object/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-equal-date-object/docs/types/index.d.ts new file mode 100644 index 000000000000..2b8bda12f5d1 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/docs/types/index.d.ts @@ -0,0 +1,47 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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. +*/ + +// TypeScript Version: 4.1 + +/** +* Tests if two values are both Date objects corresponding to the same date and time. +* +* @param d1 - first input value +* @param d2 - second input value +* @returns boolean indicating whether both are Date objects corresponding to the same date and time +* +* @example +* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* +* var bool = isEqualDateObject( d1, d2 ); +* // returns true +* +* @example +* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); +* +* var bool = isEqualDateObject( d1, d2 ); +* // returns false +*/ +declare function isEqualDateObject( d1: any, d2: any ): boolean; + + +// EXPORTS // + +export = isEqualDateObject; diff --git a/lib/node_modules/@stdlib/assert/is-equal-date-object/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-equal-date-object/docs/types/test.ts new file mode 100644 index 000000000000..0c5c2b19837e --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/docs/types/test.ts @@ -0,0 +1,36 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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. +*/ + +import isEqualDateObject = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isEqualDateObject( new Date(), new Date() ); // $ExpectType boolean + isEqualDateObject( null, null ); // $ExpectType boolean + isEqualDateObject( 'beep', 'boop' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isEqualDateObject(); // $ExpectError + isEqualDateObject( new Date() ); // $ExpectError + isEqualDateObject( 'beep', 'beep', new Date() ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-date-object/examples/index.js b/lib/node_modules/@stdlib/assert/is-equal-date-object/examples/index.js new file mode 100644 index 000000000000..d02e3931ca10 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/examples/index.js @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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'; + +var isEqualDateObject = require( './../lib' ); + +var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + +var bool = isEqualDateObject( d1, d2 ); +console.log( bool ); +// => true + +d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); + +bool = isEqualDateObject( d1, d2 ); +console.log( bool ); +// => false + +d1 = new Date(); +d2 = new Date( '2024-12-31T23:59:59.999' ); +bool = isEqualDateObject( d1, d2 ); +// returns false + +var d3 = new Date( 2024, 11, 31 ); +var d4 = new Date( 'December 31, 2024 23:59:59:999' ); + +bool = isEqualDateObject( d1, d3 ); +console.log( bool ); +// => false + +bool = isEqualDateObject( d2, d4 ); +console.log( bool ); +// => true diff --git a/lib/node_modules/@stdlib/assert/is-equal-date-object/lib/index.js b/lib/node_modules/@stdlib/assert/is-equal-date-object/lib/index.js new file mode 100644 index 000000000000..46149c9be308 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/lib/index.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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'; + +/** +* Test if two arguments are both Date objects corresponding to the same date and time. +* +* @module @stdlib/assert/is-equal-date-object +* +* @example +* var isEqualDateObject = require( '@stdlib/assert/is-equal-date-object' ); +* +* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* +* var bool = isEqualDateObject( d1, d2 ); +* // returns true +* +* @example +* var isEqualDateObject = require( '@stdlib/assert/is-equal-date-object' ); +* +* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); +* +* var bool = isEqualDateObject( d1, d2 ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/is-equal-date-object/lib/main.js b/lib/node_modules/@stdlib/assert/is-equal-date-object/lib/main.js new file mode 100644 index 000000000000..6a0305c9629b --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/lib/main.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isDateObject = require( '@stdlib/assert/is-date-object' ); + + +// MAIN // + +/** +* Tests if two arguments are both Date objects corresponding to the same date and time. +* +* @param {*} d1 - first value +* @param {*} d2 - second value +* @returns {boolean} boolean result +* +* @example +* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* var bool = isEqualDateObject( d1, d2 ); +* // returns true +* +* @example +* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); +* var bool = isEqualDateObject( d1, d2 ); +* // returns false +*/ +function isEqualDateObject( d1, d2 ) { + return ( isDateObject( d1 ) && isDateObject( d2 ) && ( d1.getTime() === d2.getTime() ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = isEqualDateObject; diff --git a/lib/node_modules/@stdlib/assert/is-equal-date-object/package.json b/lib/node_modules/@stdlib/assert/is-equal-date-object/package.json new file mode 100644 index 000000000000..2c916eb13915 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/package.json @@ -0,0 +1,77 @@ +{ + "name": "@stdlib/assert/is-equal-date-object", + "version": "0.0.0", + "description": "Test if two values are both Date objects corresponding to the same date and time.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "equal", + "same", + "strict", + "is", + "issame", + "issamevalue", + "isequal", + "isstrictequal", + "type", + "check", + "valid", + "validate", + "test", + "date", + "time", + "generic" + ] +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-date-object/test/test.js b/lib/node_modules/@stdlib/assert/is-equal-date-object/test/test.js new file mode 100644 index 000000000000..bc7e42944651 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/test/test.js @@ -0,0 +1,90 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isEqualDateObject = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isEqualDateObject, 'function', 'main export is a function' ); + t.end(); +} ); + +tape( 'the function returns `true` if provided two Date objects corresponding to the same date and time', function test( t ) { + var d1; + var d2; + + d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + t.strictEqual( isEqualDateObject( d1, d1 ), true, 'returns expected value' ); + + d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + t.strictEqual( isEqualDateObject( d1, d2 ), true, 'returns expected value' ); + + d1 = new Date( 'December 31, 2024 23:59:59:999' ); + d2 = new Date( '2024-12-31T23:59:59.999' ); + t.strictEqual( isEqualDateObject( d1, d2 ), true, 'returns expected value' ); + + t.end(); +} ); + +tape( 'the function returns `false` if not provided two Date objects corresponding to the same date and time', function test( t ) { + var d1; + var d2; + + d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); + t.strictEqual( isEqualDateObject( d1, d2 ), false, 'returns expected value' ); + + d1 = new Date(); + d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + t.strictEqual( isEqualDateObject( d1, d2 ), false, 'returns expected value' ); + + d1 = new Date( 2024, 11, 31 ); + d2 = new Date( 2024, 11, 30 ); + t.strictEqual( isEqualDateObject( d1, d2 ), false, 'returns expected value' ); + + d1 = new Date( 2024, 11, 31 ); + d2 = 'string'; + t.strictEqual( isEqualDateObject( d1, d2 ), false, 'returns expected value' ); + + d1 = new Date( 2024, 11, 31 ); + d2 = 1; + t.strictEqual( isEqualDateObject( d1, d2 ), false, 'returns expected value' ); + + d1 = new Date( 2024, 11, 31 ); + d2 = void 0; + t.strictEqual( isEqualDateObject( d1, d2 ), false, 'returns expected value' ); + + d1 = new Date( 2024, 11, 31 ); + d2 = {}; + t.strictEqual( isEqualDateObject( d1, d2 ), false, 'returns expected value' ); + + d1 = new Date( 2024, 11, 31 ); + d2 = []; + t.strictEqual( isEqualDateObject( d1, d2 ), false, 'returns expected value' ); + + t.end(); +} ); From 175765cf2181ed5ac877b74fa1378367573e271f Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 23:15:49 -0700 Subject: [PATCH 25/60] remove: remove `assert/is-same-date-object` This commit removes `@stdlib/assert/is-same-date-object` in favor of `@stdlib/assert/is-equal-date-object`. BREAKING CHANGE: remove `assert/is-same-date-object` To migrate, users should update their import paths to use `@stdlib/assert/is-equal-date-object`. --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../assert/is-same-date-object/README.md | 90 ------------------- .../benchmark/benchmark.js | 62 ------------- .../assert/is-same-date-object/docs/repl.txt | 32 ------- .../is-same-date-object/docs/types/index.d.ts | 47 ---------- .../is-same-date-object/docs/types/test.ts | 36 -------- .../is-same-date-object/examples/index.js | 51 ----------- .../assert/is-same-date-object/lib/index.js | 52 ----------- .../assert/is-same-date-object/lib/main.js | 54 ----------- .../assert/is-same-date-object/package.json | 77 ---------------- .../assert/is-same-date-object/test/test.js | 90 ------------------- 10 files changed, 591 deletions(-) delete mode 100644 lib/node_modules/@stdlib/assert/is-same-date-object/README.md delete mode 100644 lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/benchmark.js delete mode 100644 lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt delete mode 100644 lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/index.d.ts delete mode 100644 lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/test.ts delete mode 100644 lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js delete mode 100644 lib/node_modules/@stdlib/assert/is-same-date-object/lib/index.js delete mode 100644 lib/node_modules/@stdlib/assert/is-same-date-object/lib/main.js delete mode 100644 lib/node_modules/@stdlib/assert/is-same-date-object/package.json delete mode 100644 lib/node_modules/@stdlib/assert/is-same-date-object/test/test.js diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/README.md b/lib/node_modules/@stdlib/assert/is-same-date-object/README.md deleted file mode 100644 index ca7a7af7a886..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/README.md +++ /dev/null @@ -1,90 +0,0 @@ - - -# isSameDateObject - -> Test if two values are [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) objects corresponding to the same date and time. - -
- -## Usage - -```javascript -var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); -``` - -#### isSameDateObject( d1, d2 ) - -Tests if two values are both Date objects corresponding to the same date and time. - -```javascript -var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); -var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); -var bool = isSameDateObject( d1, d2 ); -// returns true - -bool = isSameDateObject( d1, new Date( 2023, 11, 31, 23, 59, 59, 78 ) ); -// returns false -``` - -
- - - -
- -## Examples - - - -```javascript -var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); - -var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); -var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); - -var bool = isSameDateObject( d1, d2 ); -// returns true - -d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); -d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); - -bool = isSameDateObject( d1, d2 ); -// returns false - -d1 = new Date(); -d2 = new Date( '2024-12-31T23:59:59.999' ); - -bool = isSameDateObject( d1, d2 ); -// returns false - -var d3 = new Date( 2024, 11, 31 ); -var d4 = new Date( 'December 31, 2024 23:59:59:999' ); - -bool = isSameDateObject( d1, d3 ); -// returns false - -bool = isSameDateObject( d2, d4 ); -// returns true -``` - -
- - diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/benchmark.js deleted file mode 100644 index 3c000a5afc7c..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/benchmark.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isSameDateObject = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var date1; - var date2; - var bool; - var i; - values = [ - '5', - 'Date', - new Date( 'December 31, 2024 23:59:59:999' ), - new Date( '2024-12-31T23:59:59.999' ), - NaN, - true, - false, - null - ]; - date1 = new Date(); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - date2 = values[ i%values.length ]; - bool = isSameDateObject( date1, date2 ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt deleted file mode 100644 index e5078d774774..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( d1, d2 ) - Tests if two values are both Date objects corresponding - to the same date and time. - - Parameters - ---------- - d1: any - First input value. - d2: any - Second input value. - - Returns - ------- - bool: boolean - Boolean indicating whether both values are Date objects - corresponding to the same date and time. - - Examples - -------- - > var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); - > var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); - > var bool = {{alias}}( d1, d2 ) - true - > var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); - > var d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); - > var bool = {{alias}}( d1, d2 ) - false - - See Also - -------- - diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/index.d.ts deleted file mode 100644 index 557a16d2e67a..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/index.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 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. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if two values are both Date objects corresponding to the same date and time. -* -* @param d1 - first input value -* @param d2 - second input value -* @returns boolean indicating whether both are Date objects corresponding to the same date and time. -* -* @example -* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); -* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); -* -* var bool = isSameDateObject( d1, d2 ); -* // returns true -* -* @example -* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); -* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); -* -* var bool = isSameDateObject( d1, d2 ); -* // returns false -*/ -declare function isSameDateObject( d1: any, d2: any ): boolean; - - -// EXPORTS // - -export = isSameDateObject; diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/test.ts deleted file mode 100644 index 0bc2ed487ab6..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 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. -*/ - -import isSameDateObject = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isSameDateObject( new Date(), new Date() ); // $ExpectType boolean - isSameDateObject( null, null ); // $ExpectType boolean - isSameDateObject( 'beep', 'boop' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isSameDateObject(); // $ExpectError - isSameDateObject( new Date() ); // $ExpectError - isSameDateObject( 'beep', 'beep', new Date() ); // $ExpectError -} diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js b/lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js deleted file mode 100644 index 000083c80701..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 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'; - -var isSameDateObject = require( './../lib' ); - -var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); -var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); - -var bool = isSameDateObject( d1, d2 ); -console.log( bool ); -// => true - -d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); -d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); - -bool = isSameDateObject( d1, d2 ); -console.log( bool ); -// => false - -d1 = new Date(); -d2 = new Date( '2024-12-31T23:59:59.999' ); -bool = isSameDateObject( d1, d2 ); -// returns false - -var d3 = new Date( 2024, 11, 31 ); -var d4 = new Date( 'December 31, 2024 23:59:59:999' ); - -bool = isSameDateObject( d1, d3 ); -console.log( bool ); -// => false - -bool = isSameDateObject( d2, d4 ); -console.log( bool ); -// => true diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/lib/index.js b/lib/node_modules/@stdlib/assert/is-same-date-object/lib/index.js deleted file mode 100644 index 8344411ffca0..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 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'; - -/** -* Test if two arguments are both Date objects corresponding to the same date and time. -* -* @module @stdlib/assert/is-same-date-object -* -* @example -* var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); -* -* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); -* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); -* -* var bool = isSameDateObject( d1, d2 ); -* // returns true -* -* @example -* var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); -* -* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); -* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); -* -* var bool = isSameDateObject( d1, d2 ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/lib/main.js b/lib/node_modules/@stdlib/assert/is-same-date-object/lib/main.js deleted file mode 100644 index dbc69319c72e..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/lib/main.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 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 isDateObject = require( '@stdlib/assert/is-date-object' ); - - -// MAIN // - -/** -* Tests if two arguments are both Date objects corresponding to the same date and time. -* -* @param {*} d1 - first value -* @param {*} d2 - second value -* @returns {boolean} boolean result -* -* @example -* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); -* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); -* var bool = isSameDateObject( d1, d2 ); -* // returns true -* -* @example -* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); -* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); -* var bool = isSameDateObject( d1, d2 ); -* // returns false -*/ -function isSameDateObject( d1, d2 ) { - return ( isDateObject( d1 ) && isDateObject( d2 ) && ( d1.getTime() === d2.getTime() ) ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = isSameDateObject; diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/package.json b/lib/node_modules/@stdlib/assert/is-same-date-object/package.json deleted file mode 100644 index 185de9500037..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/package.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "name": "@stdlib/assert/is-same-date-object", - "version": "0.0.0", - "description": "Test if two values are both Date objects corresponding to the same date and time.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdassert", - "assertion", - "assert", - "utilities", - "utility", - "utils", - "util", - "equal", - "same", - "strict", - "is", - "issame", - "issamevalue", - "isequal", - "isstrictequal", - "type", - "check", - "valid", - "validate", - "test", - "date", - "time", - "generic" - ] -} diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/test/test.js b/lib/node_modules/@stdlib/assert/is-same-date-object/test/test.js deleted file mode 100644 index 1f85c75dca84..000000000000 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/test/test.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 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 isSameDateObject = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isSameDateObject, 'function', 'main export is a function' ); - t.end(); -} ); - -tape( 'the function returns `true` if provided two Date objects corresponding to the same date and time', function test( t ) { - var d1; - var d2; - - d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); - t.strictEqual( isSameDateObject( d1, d1 ), true, 'returns expected value' ); - - d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); - d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); - t.strictEqual( isSameDateObject( d1, d2 ), true, 'returns expected value' ); - - d1 = new Date( 'December 31, 2024 23:59:59:999' ); - d2 = new Date( '2024-12-31T23:59:59.999' ); - t.strictEqual( isSameDateObject( d1, d2 ), true, 'returns expected value' ); - - t.end(); -} ); - -tape( 'the function returns `false` if not provided two Date objects corresponding to the same date and time', function test( t ) { - var d1; - var d2; - - d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); - d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); - t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); - - d1 = new Date(); - d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); - t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); - - d1 = new Date( 2024, 11, 31 ); - d2 = new Date( 2024, 11, 30 ); - t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); - - d1 = new Date( 2024, 11, 31 ); - d2 = 'string'; - t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); - - d1 = new Date( 2024, 11, 31 ); - d2 = 1; - t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); - - d1 = new Date( 2024, 11, 31 ); - d2 = undefined; - t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); - - d1 = new Date( 2024, 11, 31 ); - d2 = {}; - t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); - - d1 = new Date( 2024, 11, 31 ); - d2 = []; - t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); - - t.end(); -} ); From a35512895adec8d5749ad26d8dda7f0a9a881a52 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 23:16:52 -0700 Subject: [PATCH 26/60] feat: add `isEqualDateObject` to namespace --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/assert/lib/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/lib/index.js b/lib/node_modules/@stdlib/assert/lib/index.js index 4905de127107..35350fcf2d82 100644 --- a/lib/node_modules/@stdlib/assert/lib/index.js +++ b/lib/node_modules/@stdlib/assert/lib/index.js @@ -1179,6 +1179,15 @@ setReadOnly( ns, 'isEqualArray', require( '@stdlib/assert/is-equal-array' ) ); */ setReadOnly( ns, 'isEqualBooleanArray', require( '@stdlib/assert/is-equal-booleanarray' ) ); +/** +* @name isEqualDateObject +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-equal-date-object} +*/ +setReadOnly( ns, 'isEqualDateObject', require( '@stdlib/assert/is-equal-date-object' ) ); + /** * @name isEqualInt32Array * @memberof ns From a793df7d544ebddf43f03082abaf1bef24f82c56 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 23:21:53 -0700 Subject: [PATCH 27/60] refactor!: rename `isSameDateObject` to `isEqualDateObject` BREAKING CHANGE: rename identifier To migrate, users should use the property `isEqualDateObject`. --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/namespace/lib/namespace/i.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/namespace/lib/namespace/i.js b/lib/node_modules/@stdlib/namespace/lib/namespace/i.js index b29e30dbecd5..2c3bb9a0527a 100644 --- a/lib/node_modules/@stdlib/namespace/lib/namespace/i.js +++ b/lib/node_modules/@stdlib/namespace/lib/namespace/i.js @@ -2827,6 +2827,17 @@ ns.push({ ] }); +ns.push({ + 'alias': 'isEqualDateObject', + 'path': '@stdlib/assert/is-equal-date-object', + 'value': require( '@stdlib/assert/is-equal-date-object' ), + 'type': 'Function', + 'related': [ + '@stdlib/assert/is-date-object', + '@stdlib/assert/is-same-value' + ] +}); + ns.push({ 'alias': 'isError', 'path': '@stdlib/assert/is-error', @@ -4150,17 +4161,6 @@ ns.push({ ] }); -ns.push({ - 'alias': 'isSameDateObject', - 'path': '@stdlib/assert/is-same-date-object', - 'value': require( '@stdlib/assert/is-same-date-object' ), - 'type': 'Function', - 'related': [ - '@stdlib/assert/is-date-object', - '@stdlib/assert/is-same-value' - ] -}); - ns.push({ 'alias': 'isSameFloat32Array', 'path': '@stdlib/assert/is-same-float32array', From 52d148a7c32085d3f133a0c5a2ce6cc31cfdd6f9 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 18 May 2025 23:23:05 -0700 Subject: [PATCH 28/60] feat: add `assert/is-equal-int16array` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../assert/is-equal-int16array/README.md | 103 +++++++++++++++++ .../benchmark/benchmark.length.js | 96 ++++++++++++++++ .../assert/is-equal-int16array/docs/repl.txt | 32 ++++++ .../is-equal-int16array/docs/types/index.d.ts | 51 +++++++++ .../is-equal-int16array/docs/types/test.ts | 36 ++++++ .../is-equal-int16array/examples/index.js | 40 +++++++ .../assert/is-equal-int16array/lib/index.js | 54 +++++++++ .../assert/is-equal-int16array/lib/main.js | 61 ++++++++++ .../assert/is-equal-int16array/package.json | 74 ++++++++++++ .../assert/is-equal-int16array/test/test.js | 106 ++++++++++++++++++ 10 files changed, 653 insertions(+) create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int16array/README.md create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int16array/benchmark/benchmark.length.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int16array/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int16array/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int16array/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int16array/examples/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int16array/lib/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int16array/lib/main.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int16array/package.json create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int16array/test/test.js diff --git a/lib/node_modules/@stdlib/assert/is-equal-int16array/README.md b/lib/node_modules/@stdlib/assert/is-equal-int16array/README.md new file mode 100644 index 000000000000..3ed63cb98570 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int16array/README.md @@ -0,0 +1,103 @@ + + +# isEqualInt16Array + +> Test if two arguments are both Int16Arrays and have equal values. + +
+ +## Usage + +```javascript +var isEqualInt16Array = require( '@stdlib/assert/is-equal-int16array' ); +``` + +#### isEqualInt16Array( v1, v2 ) + +Tests if two arguments are both Int16Arrays and have equal values. + +```javascript +var Int16Array = require( '@stdlib/array/int16' ); + +var x = new Int16Array( [ 1, 2 ] ); +var y = new Int16Array( [ 1, 2 ] ); +var bool = isEqualInt16Array( x, y ); +// returns true + +bool = isEqualInt16Array( x, new Int16Array( [ 1, 3 ] ) ); +// returns false +``` + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var Int16Array = require( '@stdlib/array/int16' ); +var isEqualInt16Array = require( '@stdlib/assert/is-equal-int16array' ); + +var x = new Int16Array( [ 1, 2, 3 ] ); +var y = new Int16Array( [ 1, 2, 3 ] ); +var out = isEqualInt16Array( x, y ); +// returns true + +x = new Int16Array( [ 0, 0, 0 ] ); +y = [ 0, 0, 0 ]; +out = isEqualInt16Array( x, y ); +// returns false + +x = new Int16Array( [ 1, 2, 3 ] ); +y = new Int16Array( [ 1, 2, 4 ] ); +out = isEqualInt16Array( x, y ); +// returns false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/assert/is-equal-int16array/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/assert/is-equal-int16array/benchmark/benchmark.length.js new file mode 100644 index 000000000000..0d06a997ef3f --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int16array/benchmark/benchmark.length.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var zeroTo = require( '@stdlib/array/zero-to' ); +var pkg = require( './../package.json' ).name; +var isEqualInt16Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = zeroTo( len, 'int16' ); + var y = zeroTo( len, 'int16' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var bool; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isEqualInt16Array( x, y ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/assert/is-equal-int16array/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-equal-int16array/docs/repl.txt new file mode 100644 index 000000000000..295f6f7dbc12 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int16array/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( v1, v2 ) + Tests if two arguments are both Int16Arrays and have equal values. + + Parameters + ---------- + v1: any + First input value. + + v2: any + Second input value. + + Returns + ------- + bool: boolean + Boolean indicating whether two arguments are equal. + + Examples + -------- + > var x = new {{alias:@stdlib/array/int16}}( [ 1, 2, 3 ] ); + > var y = new {{alias:@stdlib/array/int16}}( [ 1, 2, 3 ] ); + > var bool = {{alias}}( x, y ) + true + + > x = new {{alias:@stdlib/array/int16}}( [ 1, 2, 3 ] ); + > y = new {{alias:@stdlib/array/int16}}( [ 1, 2, 4 ] ); + > bool = {{alias}}( x, y ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/assert/is-equal-int16array/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-equal-int16array/docs/types/index.d.ts new file mode 100644 index 000000000000..67236ff375f1 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int16array/docs/types/index.d.ts @@ -0,0 +1,51 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/** +* Tests if two arguments are both Int16Arrays and have equal values. +* +* @param v1 - first input value +* @param v2 - second input value +* @returns boolean indicating whether two arguments are equal +* +* @example +* var Int16Array = require( '@stdlib/array/int16' ); +* +* var x = new Int16Array( [ 1, 2, 3 ] ); +* var y = new Int16Array( [ 1, 2, 3 ] ); +* +* var out = isEqualInt16Array( x, y ); +* // returns true +* +* @example +* var Int16Array = require( '@stdlib/array/int16' ); +* +* var x = new Int16Array( [ 1, 2, 3 ] ); +* var y = new Int16Array( [ 1, 2, 4 ] ); +* +* var out = isEqualInt16Array( x, y ); +* // returns false +*/ +declare function isEqualInt16Array( v1: any, v2: any ): boolean; + + +// EXPORTS // + +export = isEqualInt16Array; diff --git a/lib/node_modules/@stdlib/assert/is-equal-int16array/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-equal-int16array/docs/types/test.ts new file mode 100644 index 000000000000..e548a358ce1e --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int16array/docs/types/test.ts @@ -0,0 +1,36 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import isEqualInt16Array = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isEqualInt16Array( 3.14, 3.14 ); // $ExpectType boolean + isEqualInt16Array( null, null ); // $ExpectType boolean + isEqualInt16Array( 'beep', 'boop' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isEqualInt16Array(); // $ExpectError + isEqualInt16Array( 3.14 ); // $ExpectError + isEqualInt16Array( 'beep', 'beep', 3.14 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-int16array/examples/index.js b/lib/node_modules/@stdlib/assert/is-equal-int16array/examples/index.js new file mode 100644 index 000000000000..af0571c40270 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int16array/examples/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var Int16Array = require( '@stdlib/array/int16' ); +var isEqualInt16Array = require( './../lib' ); + +var x = new Int16Array( [ 1, 2, 3 ] ); +var y = new Int16Array( [ 1, 2, 3 ] ); +var out = isEqualInt16Array( x, y ); +console.log( out ); +// => true + +x = new Int16Array( [ 0, 0, 0 ] ); +y = [ 0, 0, 0 ]; +out = isEqualInt16Array( x, y ); +console.log( out ); +// => false + +x = new Int16Array( [ 1, 2, 3 ] ); +y = new Int16Array( [ 1, 2, 4 ] ); +out = isEqualInt16Array( x, y ); +console.log( out ); +// => false diff --git a/lib/node_modules/@stdlib/assert/is-equal-int16array/lib/index.js b/lib/node_modules/@stdlib/assert/is-equal-int16array/lib/index.js new file mode 100644 index 000000000000..dfc295fc7b07 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int16array/lib/index.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Test if two arguments are both Int16Arrays and have equal values. +* +* @module @stdlib/assert/is-equal-int16array +* +* @example +* var Int16Array = require( '@stdlib/array/int16' ); +* var isEqualInt16Array = require( '@stdlib/assert/is-equal-int16array' ); +* +* var x = new Int16Array( [ 1, 2, 3 ] ); +* var y = new Int16Array( [ 1, 2, 3 ] ); +* +* var out = isEqualInt16Array( x, y ); +* // returns true +* +* @example +* var Int16Array = require( '@stdlib/array/int16' ); +* var isEqualInt16Array = require( '@stdlib/assert/is-equal-int16array' ); +* +* var x = new Int16Array( [ 1, 2, 3 ] ); +* var y = new Int16Array( [ 1, 2, 4 ] ); +* +* var out = isEqualInt16Array( x, y ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/is-equal-int16array/lib/main.js b/lib/node_modules/@stdlib/assert/is-equal-int16array/lib/main.js new file mode 100644 index 000000000000..11c0cad8bc5b --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int16array/lib/main.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isInt16Array = require( '@stdlib/assert/is-int16array' ); +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); + + +// MAIN // + +/** +* Tests if two arguments are both Int16Arrays and have equal values. +* +* @param {*} v1 - first value +* @param {*} v2 - second value +* @returns {boolean} boolean result +* +* @example +* var Int16Array = require( '@stdlib/array/int16' ); +* +* var x = new Int16Array( [ 1, 2, 3 ] ); +* var y = new Int16Array( [ 1, 2, 3 ] ); +* +* var out = isEqualInt16Array( x, y ); +* // returns true +* +* @example +* var Int16Array = require( '@stdlib/array/int16' ); +* +* var x = new Int16Array( [ 1, 2, 3 ] ); +* var y = new Int16Array( [ 1, 2, 4 ] ); +* +* var out = isEqualInt16Array( x, y ); +* // returns false +*/ +function isEqualInt16Array( v1, v2 ) { + return ( isInt16Array( v1 ) && isInt16Array( v2 ) && hasEqualValues( v1, v2 ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = isEqualInt16Array; diff --git a/lib/node_modules/@stdlib/assert/is-equal-int16array/package.json b/lib/node_modules/@stdlib/assert/is-equal-int16array/package.json new file mode 100644 index 000000000000..92d9bae6a4a7 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int16array/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/assert/is-equal-int16array", + "version": "0.0.0", + "description": "Test if two arguments are both Int16Arrays and have equal values.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "equal", + "same", + "strict", + "is", + "isequal", + "isstrictequal", + "type", + "check", + "valid", + "validate", + "test", + "typed", + "array" + ] +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-int16array/test/test.js b/lib/node_modules/@stdlib/assert/is-equal-int16array/test/test.js new file mode 100644 index 000000000000..62a2caeeea34 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int16array/test/test.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Int16Array = require( '@stdlib/array/int16' ); +var typedarray = require( '@stdlib/array/typed' ); +var isEqualInt16Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isEqualInt16Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided two Int16Arrays having equal values', function test( t ) { + var x; + var y; + + x = new Int16Array( [ 1, 2, 3 ] ); + t.strictEqual( isEqualInt16Array( x, x ), true, 'returns expected value' ); + + x = new Int16Array( [ 1, 2, 3 ] ); + y = new Int16Array( [ 1, 2, 3 ] ); + t.strictEqual( isEqualInt16Array( x, y ), true, 'returns expected value' ); + + x = new Int16Array( [ 0, 0, 0 ] ); + y = new Int16Array( [ 0, 0, 0 ] ); + t.strictEqual( isEqualInt16Array( x, y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `false` if not provided two Int16Arrays having equal values', function test( t ) { + var x; + var y; + var i; + + x = [ + '', + 'beep', + 5, + 3.14, + -3.14, + 0.0, + -0.0, + true, + false, + null, + void 0, + [ 1.0 ], + {}, + function noop() {}, + typedarray( 10, 'float64' ), + typedarray( 10, 'int16' ), + typedarray( 10, 'float32' ), + [ 1.0, 2.0, 3.0 ], + [ NaN, NaN, NaN ] + ]; + y = [ + 'abc', + 'boop', + -5, + -3.14, + 3.14, + -0.0, + 0.0, + false, + true, + void 0, + null, + [ -1.0 ], + {}, + function noop() {}, + typedarray( 10, 'float64' ), + typedarray( 10, 'uint16' ), + typedarray( 10, 'float64' ), + [ 2.0, 4.0, 6.0 ], + [ NaN, NaN, NaN ] + ]; + for ( i = 0; i < x.length; i++ ) { + t.strictEqual( isEqualInt16Array( x[ i ], y[ i ] ), false, 'returns expected value when provided '+x[ i ]+' and '+y[ i ] ); + } + t.end(); +}); From 4ab192805184fcce9b7def031c1abb97cd09faa3 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 00:21:12 -0700 Subject: [PATCH 29/60] feat: add `isEqualInt16Array` to namespace --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/assert/lib/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/lib/index.js b/lib/node_modules/@stdlib/assert/lib/index.js index 35350fcf2d82..eb475a4a4efd 100644 --- a/lib/node_modules/@stdlib/assert/lib/index.js +++ b/lib/node_modules/@stdlib/assert/lib/index.js @@ -1188,6 +1188,15 @@ setReadOnly( ns, 'isEqualBooleanArray', require( '@stdlib/assert/is-equal-boolea */ setReadOnly( ns, 'isEqualDateObject', require( '@stdlib/assert/is-equal-date-object' ) ); +/** +* @name isEqualInt16Array +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-equal-int16array} +*/ +setReadOnly( ns, 'isEqualInt16Array', require( '@stdlib/assert/is-equal-int16array' ) ); + /** * @name isEqualInt32Array * @memberof ns From 3f9732c9d21636d96316bd2c01f90edd50f0805f Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 00:24:42 -0700 Subject: [PATCH 30/60] feat: add `assert/is-equal-int8array` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../assert/is-equal-int8array/README.md | 103 +++++++++++++++++ .../benchmark/benchmark.length.js | 96 ++++++++++++++++ .../assert/is-equal-int8array/docs/repl.txt | 32 ++++++ .../is-equal-int8array/docs/types/index.d.ts | 51 +++++++++ .../is-equal-int8array/docs/types/test.ts | 36 ++++++ .../is-equal-int8array/examples/index.js | 40 +++++++ .../assert/is-equal-int8array/lib/index.js | 54 +++++++++ .../assert/is-equal-int8array/lib/main.js | 61 ++++++++++ .../assert/is-equal-int8array/package.json | 74 ++++++++++++ .../assert/is-equal-int8array/test/test.js | 106 ++++++++++++++++++ 10 files changed, 653 insertions(+) create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int8array/README.md create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int8array/benchmark/benchmark.length.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int8array/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int8array/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int8array/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int8array/examples/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int8array/lib/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int8array/lib/main.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int8array/package.json create mode 100644 lib/node_modules/@stdlib/assert/is-equal-int8array/test/test.js diff --git a/lib/node_modules/@stdlib/assert/is-equal-int8array/README.md b/lib/node_modules/@stdlib/assert/is-equal-int8array/README.md new file mode 100644 index 000000000000..09b5215154be --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int8array/README.md @@ -0,0 +1,103 @@ + + +# isEqualInt8Array + +> Test if two arguments are both Int8Arrays and have equal values. + +
+ +## Usage + +```javascript +var isEqualInt8Array = require( '@stdlib/assert/is-equal-int8array' ); +``` + +#### isEqualInt8Array( v1, v2 ) + +Tests if two arguments are both Int8Arrays and have equal values. + +```javascript +var Int8Array = require( '@stdlib/array/int8' ); + +var x = new Int8Array( [ 1, 2 ] ); +var y = new Int8Array( [ 1, 2 ] ); +var bool = isEqualInt8Array( x, y ); +// returns true + +bool = isEqualInt8Array( x, new Int8Array( [ 1, 3 ] ) ); +// returns false +``` + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var Int8Array = require( '@stdlib/array/int8' ); +var isEqualInt8Array = require( '@stdlib/assert/is-equal-int8array' ); + +var x = new Int8Array( [ 1, 2, 3 ] ); +var y = new Int8Array( [ 1, 2, 3 ] ); +var out = isEqualInt8Array( x, y ); +// returns true + +x = new Int8Array( [ 0, 0, 0 ] ); +y = [ 0, 0, 0 ]; +out = isEqualInt8Array( x, y ); +// returns false + +x = new Int8Array( [ 1, 2, 3 ] ); +y = new Int8Array( [ 1, 2, 4 ] ); +out = isEqualInt8Array( x, y ); +// returns false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/assert/is-equal-int8array/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/assert/is-equal-int8array/benchmark/benchmark.length.js new file mode 100644 index 000000000000..53c6fef02a43 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int8array/benchmark/benchmark.length.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var zeroTo = require( '@stdlib/array/zero-to' ); +var pkg = require( './../package.json' ).name; +var isEqualInt8Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = zeroTo( len, 'int8' ); + var y = zeroTo( len, 'int8' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var bool; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isEqualInt8Array( x, y ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/assert/is-equal-int8array/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-equal-int8array/docs/repl.txt new file mode 100644 index 000000000000..0fbd62a1cf85 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int8array/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( v1, v2 ) + Tests if two arguments are both Int8Arrays and have equal values. + + Parameters + ---------- + v1: any + First input value. + + v2: any + Second input value. + + Returns + ------- + bool: boolean + Boolean indicating whether two arguments are equal. + + Examples + -------- + > var x = new {{alias:@stdlib/array/int8}}( [ 1, 2, 3 ] ); + > var y = new {{alias:@stdlib/array/int8}}( [ 1, 2, 3 ] ); + > var bool = {{alias}}( x, y ) + true + + > x = new {{alias:@stdlib/array/int8}}( [ 1, 2, 3 ] ); + > y = new {{alias:@stdlib/array/int8}}( [ 1, 2, 4 ] ); + > bool = {{alias}}( x, y ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/assert/is-equal-int8array/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-equal-int8array/docs/types/index.d.ts new file mode 100644 index 000000000000..459324ab146d --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int8array/docs/types/index.d.ts @@ -0,0 +1,51 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/** +* Tests if two arguments are both Int8Arrays and have equal values. +* +* @param v1 - first input value +* @param v2 - second input value +* @returns boolean indicating whether two arguments are equal +* +* @example +* var Int8Array = require( '@stdlib/array/int8' ); +* +* var x = new Int8Array( [ 1, 2, 3 ] ); +* var y = new Int8Array( [ 1, 2, 3 ] ); +* +* var out = isEqualInt8Array( x, y ); +* // returns true +* +* @example +* var Int8Array = require( '@stdlib/array/int8' ); +* +* var x = new Int8Array( [ 1, 2, 3 ] ); +* var y = new Int8Array( [ 1, 2, 4 ] ); +* +* var out = isEqualInt8Array( x, y ); +* // returns false +*/ +declare function isEqualInt8Array( v1: any, v2: any ): boolean; + + +// EXPORTS // + +export = isEqualInt8Array; diff --git a/lib/node_modules/@stdlib/assert/is-equal-int8array/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-equal-int8array/docs/types/test.ts new file mode 100644 index 000000000000..a87c48d2c94e --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int8array/docs/types/test.ts @@ -0,0 +1,36 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import isEqualInt8Array = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isEqualInt8Array( 3.14, 3.14 ); // $ExpectType boolean + isEqualInt8Array( null, null ); // $ExpectType boolean + isEqualInt8Array( 'beep', 'boop' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isEqualInt8Array(); // $ExpectError + isEqualInt8Array( 3.14 ); // $ExpectError + isEqualInt8Array( 'beep', 'beep', 3.14 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-int8array/examples/index.js b/lib/node_modules/@stdlib/assert/is-equal-int8array/examples/index.js new file mode 100644 index 000000000000..cd536810fc7a --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int8array/examples/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var Int8Array = require( '@stdlib/array/int8' ); +var isEqualInt8Array = require( './../lib' ); + +var x = new Int8Array( [ 1, 2, 3 ] ); +var y = new Int8Array( [ 1, 2, 3 ] ); +var out = isEqualInt8Array( x, y ); +console.log( out ); +// => true + +x = new Int8Array( [ 0, 0, 0 ] ); +y = [ 0, 0, 0 ]; +out = isEqualInt8Array( x, y ); +console.log( out ); +// => false + +x = new Int8Array( [ 1, 2, 3 ] ); +y = new Int8Array( [ 1, 2, 4 ] ); +out = isEqualInt8Array( x, y ); +console.log( out ); +// => false diff --git a/lib/node_modules/@stdlib/assert/is-equal-int8array/lib/index.js b/lib/node_modules/@stdlib/assert/is-equal-int8array/lib/index.js new file mode 100644 index 000000000000..7a8f0008cd65 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int8array/lib/index.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Test if two arguments are both Int8Arrays and have equal values. +* +* @module @stdlib/assert/is-equal-int8array +* +* @example +* var Int8Array = require( '@stdlib/array/int8' ); +* var isEqualInt8Array = require( '@stdlib/assert/is-equal-int8array' ); +* +* var x = new Int8Array( [ 1, 2, 3 ] ); +* var y = new Int8Array( [ 1, 2, 3 ] ); +* +* var out = isEqualInt8Array( x, y ); +* // returns true +* +* @example +* var Int8Array = require( '@stdlib/array/int8' ); +* var isEqualInt8Array = require( '@stdlib/assert/is-equal-int8array' ); +* +* var x = new Int8Array( [ 1, 2, 3 ] ); +* var y = new Int8Array( [ 1, 2, 4 ] ); +* +* var out = isEqualInt8Array( x, y ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/is-equal-int8array/lib/main.js b/lib/node_modules/@stdlib/assert/is-equal-int8array/lib/main.js new file mode 100644 index 000000000000..d47fa7bd11de --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int8array/lib/main.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isInt8Array = require( '@stdlib/assert/is-int8array' ); +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); + + +// MAIN // + +/** +* Tests if two arguments are both Int8Arrays and have equal values. +* +* @param {*} v1 - first value +* @param {*} v2 - second value +* @returns {boolean} boolean result +* +* @example +* var Int8Array = require( '@stdlib/array/int8' ); +* +* var x = new Int8Array( [ 1, 2, 3 ] ); +* var y = new Int8Array( [ 1, 2, 3 ] ); +* +* var out = isEqualInt8Array( x, y ); +* // returns true +* +* @example +* var Int8Array = require( '@stdlib/array/int8' ); +* +* var x = new Int8Array( [ 1, 2, 3 ] ); +* var y = new Int8Array( [ 1, 2, 4 ] ); +* +* var out = isEqualInt8Array( x, y ); +* // returns false +*/ +function isEqualInt8Array( v1, v2 ) { + return ( isInt8Array( v1 ) && isInt8Array( v2 ) && hasEqualValues( v1, v2 ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = isEqualInt8Array; diff --git a/lib/node_modules/@stdlib/assert/is-equal-int8array/package.json b/lib/node_modules/@stdlib/assert/is-equal-int8array/package.json new file mode 100644 index 000000000000..479f41b96395 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int8array/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/assert/is-equal-int8array", + "version": "0.0.0", + "description": "Test if two arguments are both Int8Arrays and have equal values.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "equal", + "same", + "strict", + "is", + "isequal", + "isstrictequal", + "type", + "check", + "valid", + "validate", + "test", + "typed", + "array" + ] +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-int8array/test/test.js b/lib/node_modules/@stdlib/assert/is-equal-int8array/test/test.js new file mode 100644 index 000000000000..7d15631814d1 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-int8array/test/test.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Int8Array = require( '@stdlib/array/int8' ); +var typedarray = require( '@stdlib/array/typed' ); +var isEqualInt8Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isEqualInt8Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided two Int8Arrays having equal values', function test( t ) { + var x; + var y; + + x = new Int8Array( [ 1, 2, 3 ] ); + t.strictEqual( isEqualInt8Array( x, x ), true, 'returns expected value' ); + + x = new Int8Array( [ 1, 2, 3 ] ); + y = new Int8Array( [ 1, 2, 3 ] ); + t.strictEqual( isEqualInt8Array( x, y ), true, 'returns expected value' ); + + x = new Int8Array( [ 0, 0, 0 ] ); + y = new Int8Array( [ 0, 0, 0 ] ); + t.strictEqual( isEqualInt8Array( x, y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `false` if not provided two Int8Arrays having equal values', function test( t ) { + var x; + var y; + var i; + + x = [ + '', + 'beep', + 5, + 3.14, + -3.14, + 0.0, + -0.0, + true, + false, + null, + void 0, + [ 1.0 ], + {}, + function noop() {}, + typedarray( 10, 'float64' ), + typedarray( 10, 'int8' ), + typedarray( 10, 'float32' ), + [ 1.0, 2.0, 3.0 ], + [ NaN, NaN, NaN ] + ]; + y = [ + 'abc', + 'boop', + -5, + -3.14, + 3.14, + -0.0, + 0.0, + false, + true, + void 0, + null, + [ -1.0 ], + {}, + function noop() {}, + typedarray( 10, 'float64' ), + typedarray( 10, 'uint8' ), + typedarray( 10, 'float64' ), + [ 2.0, 4.0, 6.0 ], + [ NaN, NaN, NaN ] + ]; + for ( i = 0; i < x.length; i++ ) { + t.strictEqual( isEqualInt8Array( x[ i ], y[ i ] ), false, 'returns expected value when provided '+x[ i ]+' and '+y[ i ] ); + } + t.end(); +}); From aae76239c23144a092995e22a5c50a64a115d621 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 00:25:44 -0700 Subject: [PATCH 31/60] feat: add `isEqualInt8Array` to namespace --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/assert/lib/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/lib/index.js b/lib/node_modules/@stdlib/assert/lib/index.js index eb475a4a4efd..0be6eadc727c 100644 --- a/lib/node_modules/@stdlib/assert/lib/index.js +++ b/lib/node_modules/@stdlib/assert/lib/index.js @@ -1188,6 +1188,15 @@ setReadOnly( ns, 'isEqualBooleanArray', require( '@stdlib/assert/is-equal-boolea */ setReadOnly( ns, 'isEqualDateObject', require( '@stdlib/assert/is-equal-date-object' ) ); +/** +* @name isEqualInt8Array +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-equal-int8array} +*/ +setReadOnly( ns, 'isEqualInt8Array', require( '@stdlib/assert/is-equal-int8array' ) ); + /** * @name isEqualInt16Array * @memberof ns From 3c3514f9dbac38514db2a04701259ad4dfda76a6 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 00:27:44 -0700 Subject: [PATCH 32/60] feat: add `assert/is-equal-uint32array` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../assert/is-equal-uint32array/README.md | 103 +++++++++++++++++ .../benchmark/benchmark.length.js | 96 ++++++++++++++++ .../assert/is-equal-uint32array/docs/repl.txt | 32 ++++++ .../docs/types/index.d.ts | 51 +++++++++ .../is-equal-uint32array/docs/types/test.ts | 36 ++++++ .../is-equal-uint32array/examples/index.js | 40 +++++++ .../assert/is-equal-uint32array/lib/index.js | 54 +++++++++ .../assert/is-equal-uint32array/lib/main.js | 61 ++++++++++ .../assert/is-equal-uint32array/package.json | 74 ++++++++++++ .../assert/is-equal-uint32array/test/test.js | 106 ++++++++++++++++++ 10 files changed, 653 insertions(+) create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint32array/README.md create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint32array/benchmark/benchmark.length.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint32array/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint32array/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint32array/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint32array/examples/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint32array/lib/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint32array/lib/main.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint32array/package.json create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint32array/test/test.js diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint32array/README.md b/lib/node_modules/@stdlib/assert/is-equal-uint32array/README.md new file mode 100644 index 000000000000..2c9346d29deb --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint32array/README.md @@ -0,0 +1,103 @@ + + +# isEqualUint32Array + +> Test if two arguments are both Uint32Arrays and have equal values. + +
+ +## Usage + +```javascript +var isEqualUint32Array = require( '@stdlib/assert/is-equal-uint32array' ); +``` + +#### isEqualUint32Array( v1, v2 ) + +Tests if two arguments are both Uint32Arrays and have equal values. + +```javascript +var Uint32Array = require( '@stdlib/array/uint32' ); + +var x = new Uint32Array( [ 1, 2 ] ); +var y = new Uint32Array( [ 1, 2 ] ); +var bool = isEqualUint32Array( x, y ); +// returns true + +bool = isEqualUint32Array( x, new Uint32Array( [ 1, 3 ] ) ); +// returns false +``` + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var Uint32Array = require( '@stdlib/array/uint32' ); +var isEqualUint32Array = require( '@stdlib/assert/is-equal-uint32array' ); + +var x = new Uint32Array( [ 1, 2, 3 ] ); +var y = new Uint32Array( [ 1, 2, 3 ] ); +var out = isEqualUint32Array( x, y ); +// returns true + +x = new Uint32Array( [ 0, 0, 0 ] ); +y = [ 0, 0, 0 ]; +out = isEqualUint32Array( x, y ); +// returns false + +x = new Uint32Array( [ 1, 2, 3 ] ); +y = new Uint32Array( [ 1, 2, 4 ] ); +out = isEqualUint32Array( x, y ); +// returns false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint32array/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/assert/is-equal-uint32array/benchmark/benchmark.length.js new file mode 100644 index 000000000000..5c89e70afed7 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint32array/benchmark/benchmark.length.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var zeroTo = require( '@stdlib/array/zero-to' ); +var pkg = require( './../package.json' ).name; +var isEqualUint32Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = zeroTo( len, 'uint32' ); + var y = zeroTo( len, 'uint32' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var bool; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isEqualUint32Array( x, y ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint32array/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-equal-uint32array/docs/repl.txt new file mode 100644 index 000000000000..7bb53319aa22 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint32array/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( v1, v2 ) + Tests if two arguments are both Uint32Arrays and have equal values. + + Parameters + ---------- + v1: any + First input value. + + v2: any + Second input value. + + Returns + ------- + bool: boolean + Boolean indicating whether two arguments are equal. + + Examples + -------- + > var x = new {{alias:@stdlib/array/uint32}}( [ 1, 2, 3 ] ); + > var y = new {{alias:@stdlib/array/uint32}}( [ 1, 2, 3 ] ); + > var bool = {{alias}}( x, y ) + true + + > x = new {{alias:@stdlib/array/uint32}}( [ 1, 2, 3 ] ); + > y = new {{alias:@stdlib/array/uint32}}( [ 1, 2, 4 ] ); + > bool = {{alias}}( x, y ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint32array/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-equal-uint32array/docs/types/index.d.ts new file mode 100644 index 000000000000..d62dee5abfb9 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint32array/docs/types/index.d.ts @@ -0,0 +1,51 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/** +* Tests if two arguments are both Uint32Arrays and have equal values. +* +* @param v1 - first input value +* @param v2 - second input value +* @returns boolean indicating whether two arguments are equal +* +* @example +* var Uint32Array = require( '@stdlib/array/uint32' ); +* +* var x = new Uint32Array( [ 1, 2, 3 ] ); +* var y = new Uint32Array( [ 1, 2, 3 ] ); +* +* var out = isEqualUint32Array( x, y ); +* // returns true +* +* @example +* var Uint32Array = require( '@stdlib/array/uint32' ); +* +* var x = new Uint32Array( [ 1, 2, 3 ] ); +* var y = new Uint32Array( [ 1, 2, 4 ] ); +* +* var out = isEqualUint32Array( x, y ); +* // returns false +*/ +declare function isEqualUint32Array( v1: any, v2: any ): boolean; + + +// EXPORTS // + +export = isEqualUint32Array; diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint32array/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-equal-uint32array/docs/types/test.ts new file mode 100644 index 000000000000..29bb1a4deeff --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint32array/docs/types/test.ts @@ -0,0 +1,36 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import isEqualUint32Array = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isEqualUint32Array( 3.14, 3.14 ); // $ExpectType boolean + isEqualUint32Array( null, null ); // $ExpectType boolean + isEqualUint32Array( 'beep', 'boop' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isEqualUint32Array(); // $ExpectError + isEqualUint32Array( 3.14 ); // $ExpectError + isEqualUint32Array( 'beep', 'beep', 3.14 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint32array/examples/index.js b/lib/node_modules/@stdlib/assert/is-equal-uint32array/examples/index.js new file mode 100644 index 000000000000..5727fc101ba6 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint32array/examples/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var Uint32Array = require( '@stdlib/array/uint32' ); +var isEqualUint32Array = require( './../lib' ); + +var x = new Uint32Array( [ 1, 2, 3 ] ); +var y = new Uint32Array( [ 1, 2, 3 ] ); +var out = isEqualUint32Array( x, y ); +console.log( out ); +// => true + +x = new Uint32Array( [ 0, 0, 0 ] ); +y = [ 0, 0, 0 ]; +out = isEqualUint32Array( x, y ); +console.log( out ); +// => false + +x = new Uint32Array( [ 1, 2, 3 ] ); +y = new Uint32Array( [ 1, 2, 4 ] ); +out = isEqualUint32Array( x, y ); +console.log( out ); +// => false diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint32array/lib/index.js b/lib/node_modules/@stdlib/assert/is-equal-uint32array/lib/index.js new file mode 100644 index 000000000000..6f7660cd10e6 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint32array/lib/index.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Test if two arguments are both Uint32Arrays and have equal values. +* +* @module @stdlib/assert/is-equal-uint32array +* +* @example +* var Uint32Array = require( '@stdlib/array/uint32' ); +* var isEqualUint32Array = require( '@stdlib/assert/is-equal-uint32array' ); +* +* var x = new Uint32Array( [ 1, 2, 3 ] ); +* var y = new Uint32Array( [ 1, 2, 3 ] ); +* +* var out = isEqualUint32Array( x, y ); +* // returns true +* +* @example +* var Uint32Array = require( '@stdlib/array/uint32' ); +* var isEqualUint32Array = require( '@stdlib/assert/is-equal-uint32array' ); +* +* var x = new Uint32Array( [ 1, 2, 3 ] ); +* var y = new Uint32Array( [ 1, 2, 4 ] ); +* +* var out = isEqualUint32Array( x, y ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint32array/lib/main.js b/lib/node_modules/@stdlib/assert/is-equal-uint32array/lib/main.js new file mode 100644 index 000000000000..85178ce66e62 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint32array/lib/main.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isUint32Array = require( '@stdlib/assert/is-uint32array' ); +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); + + +// MAIN // + +/** +* Tests if two arguments are both Uint32Arrays and have equal values. +* +* @param {*} v1 - first value +* @param {*} v2 - second value +* @returns {boolean} boolean result +* +* @example +* var Uint32Array = require( '@stdlib/array/uint32' ); +* +* var x = new Uint32Array( [ 1, 2, 3 ] ); +* var y = new Uint32Array( [ 1, 2, 3 ] ); +* +* var out = isEqualUint32Array( x, y ); +* // returns true +* +* @example +* var Uint32Array = require( '@stdlib/array/uint32' ); +* +* var x = new Uint32Array( [ 1, 2, 3 ] ); +* var y = new Uint32Array( [ 1, 2, 4 ] ); +* +* var out = isEqualUint32Array( x, y ); +* // returns false +*/ +function isEqualUint32Array( v1, v2 ) { + return ( isUint32Array( v1 ) && isUint32Array( v2 ) && hasEqualValues( v1, v2 ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = isEqualUint32Array; diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint32array/package.json b/lib/node_modules/@stdlib/assert/is-equal-uint32array/package.json new file mode 100644 index 000000000000..5e13d836d4ce --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint32array/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/assert/is-equal-uint32array", + "version": "0.0.0", + "description": "Test if two arguments are both Uint32Arrays and have equal values.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "equal", + "same", + "strict", + "is", + "isequal", + "isstrictequal", + "type", + "check", + "valid", + "validate", + "test", + "typed", + "array" + ] +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint32array/test/test.js b/lib/node_modules/@stdlib/assert/is-equal-uint32array/test/test.js new file mode 100644 index 000000000000..a182be71c8aa --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint32array/test/test.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Uint32Array = require( '@stdlib/array/uint32' ); +var typedarray = require( '@stdlib/array/typed' ); +var isEqualUint32Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isEqualUint32Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided two Uint32Arrays having equal values', function test( t ) { + var x; + var y; + + x = new Uint32Array( [ 1, 2, 3 ] ); + t.strictEqual( isEqualUint32Array( x, x ), true, 'returns expected value' ); + + x = new Uint32Array( [ 1, 2, 3 ] ); + y = new Uint32Array( [ 1, 2, 3 ] ); + t.strictEqual( isEqualUint32Array( x, y ), true, 'returns expected value' ); + + x = new Uint32Array( [ 0, 0, 0 ] ); + y = new Uint32Array( [ 0, 0, 0 ] ); + t.strictEqual( isEqualUint32Array( x, y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `false` if not provided two Uint32Arrays having equal values', function test( t ) { + var x; + var y; + var i; + + x = [ + '', + 'beep', + 5, + 3.14, + -3.14, + 0.0, + -0.0, + true, + false, + null, + void 0, + [ 1.0 ], + {}, + function noop() {}, + typedarray( 10, 'float64' ), + typedarray( 10, 'int32' ), + typedarray( 10, 'float32' ), + [ 1.0, 2.0, 3.0 ], + [ NaN, NaN, NaN ] + ]; + y = [ + 'abc', + 'boop', + -5, + -3.14, + 3.14, + -0.0, + 0.0, + false, + true, + void 0, + null, + [ -1.0 ], + {}, + function noop() {}, + typedarray( 10, 'float64' ), + typedarray( 10, 'uint32' ), + typedarray( 10, 'float64' ), + [ 2.0, 4.0, 6.0 ], + [ NaN, NaN, NaN ] + ]; + for ( i = 0; i < x.length; i++ ) { + t.strictEqual( isEqualUint32Array( x[ i ], y[ i ] ), false, 'returns expected value when provided '+x[ i ]+' and '+y[ i ] ); + } + t.end(); +}); From 2b1076f075bcfef6f18fc4318878863a87056f49 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 00:28:48 -0700 Subject: [PATCH 33/60] feat: add `isEqualUint32Array` to namespace --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/assert/lib/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/lib/index.js b/lib/node_modules/@stdlib/assert/lib/index.js index 0be6eadc727c..f6c0fead8f50 100644 --- a/lib/node_modules/@stdlib/assert/lib/index.js +++ b/lib/node_modules/@stdlib/assert/lib/index.js @@ -1215,6 +1215,15 @@ setReadOnly( ns, 'isEqualInt16Array', require( '@stdlib/assert/is-equal-int16arr */ setReadOnly( ns, 'isEqualInt32Array', require( '@stdlib/assert/is-equal-int32array' ) ); +/** +* @name isEqualUint32Array +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-equal-uint32array} +*/ +setReadOnly( ns, 'isEqualUint32Array', require( '@stdlib/assert/is-equal-uint32array' ) ); + /** * @name isError * @memberof ns From e556b6e4ab49bd8e8995a9154a82a4c93b46d84e Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 00:31:04 -0700 Subject: [PATCH 34/60] feat: add `assert/is-equal-uint16array` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../assert/is-equal-uint16array/README.md | 103 +++++++++++++++++ .../benchmark/benchmark.length.js | 96 ++++++++++++++++ .../assert/is-equal-uint16array/docs/repl.txt | 32 ++++++ .../docs/types/index.d.ts | 51 +++++++++ .../is-equal-uint16array/docs/types/test.ts | 36 ++++++ .../is-equal-uint16array/examples/index.js | 40 +++++++ .../assert/is-equal-uint16array/lib/index.js | 54 +++++++++ .../assert/is-equal-uint16array/lib/main.js | 61 ++++++++++ .../assert/is-equal-uint16array/package.json | 74 ++++++++++++ .../assert/is-equal-uint16array/test/test.js | 106 ++++++++++++++++++ 10 files changed, 653 insertions(+) create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint16array/README.md create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint16array/benchmark/benchmark.length.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint16array/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint16array/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint16array/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint16array/examples/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint16array/lib/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint16array/lib/main.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint16array/package.json create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint16array/test/test.js diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint16array/README.md b/lib/node_modules/@stdlib/assert/is-equal-uint16array/README.md new file mode 100644 index 000000000000..4e6fa2fb1820 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint16array/README.md @@ -0,0 +1,103 @@ + + +# isEqualUint16Array + +> Test if two arguments are both Uint16Arrays and have equal values. + +
+ +## Usage + +```javascript +var isEqualUint16Array = require( '@stdlib/assert/is-equal-uint16array' ); +``` + +#### isEqualUint16Array( v1, v2 ) + +Tests if two arguments are both Uint16Arrays and have equal values. + +```javascript +var Uint16Array = require( '@stdlib/array/uint16' ); + +var x = new Uint16Array( [ 1, 2 ] ); +var y = new Uint16Array( [ 1, 2 ] ); +var bool = isEqualUint16Array( x, y ); +// returns true + +bool = isEqualUint16Array( x, new Uint16Array( [ 1, 3 ] ) ); +// returns false +``` + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var Uint16Array = require( '@stdlib/array/uint16' ); +var isEqualUint16Array = require( '@stdlib/assert/is-equal-uint16array' ); + +var x = new Uint16Array( [ 1, 2, 3 ] ); +var y = new Uint16Array( [ 1, 2, 3 ] ); +var out = isEqualUint16Array( x, y ); +// returns true + +x = new Uint16Array( [ 0, 0, 0 ] ); +y = [ 0, 0, 0 ]; +out = isEqualUint16Array( x, y ); +// returns false + +x = new Uint16Array( [ 1, 2, 3 ] ); +y = new Uint16Array( [ 1, 2, 4 ] ); +out = isEqualUint16Array( x, y ); +// returns false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint16array/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/assert/is-equal-uint16array/benchmark/benchmark.length.js new file mode 100644 index 000000000000..ccf866111a58 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint16array/benchmark/benchmark.length.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var zeroTo = require( '@stdlib/array/zero-to' ); +var pkg = require( './../package.json' ).name; +var isEqualUint16Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = zeroTo( len, 'uint16' ); + var y = zeroTo( len, 'uint16' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var bool; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isEqualUint16Array( x, y ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint16array/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-equal-uint16array/docs/repl.txt new file mode 100644 index 000000000000..6c44135daf80 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint16array/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( v1, v2 ) + Tests if two arguments are both Uint16Arrays and have equal values. + + Parameters + ---------- + v1: any + First input value. + + v2: any + Second input value. + + Returns + ------- + bool: boolean + Boolean indicating whether two arguments are equal. + + Examples + -------- + > var x = new {{alias:@stdlib/array/uint16}}( [ 1, 2, 3 ] ); + > var y = new {{alias:@stdlib/array/uint16}}( [ 1, 2, 3 ] ); + > var bool = {{alias}}( x, y ) + true + + > x = new {{alias:@stdlib/array/uint16}}( [ 1, 2, 3 ] ); + > y = new {{alias:@stdlib/array/uint16}}( [ 1, 2, 4 ] ); + > bool = {{alias}}( x, y ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint16array/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-equal-uint16array/docs/types/index.d.ts new file mode 100644 index 000000000000..fd0e628bd2fd --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint16array/docs/types/index.d.ts @@ -0,0 +1,51 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/** +* Tests if two arguments are both Uint16Arrays and have equal values. +* +* @param v1 - first input value +* @param v2 - second input value +* @returns boolean indicating whether two arguments are equal +* +* @example +* var Uint16Array = require( '@stdlib/array/uint16' ); +* +* var x = new Uint16Array( [ 1, 2, 3 ] ); +* var y = new Uint16Array( [ 1, 2, 3 ] ); +* +* var out = isEqualUint16Array( x, y ); +* // returns true +* +* @example +* var Uint16Array = require( '@stdlib/array/uint16' ); +* +* var x = new Uint16Array( [ 1, 2, 3 ] ); +* var y = new Uint16Array( [ 1, 2, 4 ] ); +* +* var out = isEqualUint16Array( x, y ); +* // returns false +*/ +declare function isEqualUint16Array( v1: any, v2: any ): boolean; + + +// EXPORTS // + +export = isEqualUint16Array; diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint16array/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-equal-uint16array/docs/types/test.ts new file mode 100644 index 000000000000..65b801377210 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint16array/docs/types/test.ts @@ -0,0 +1,36 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import isEqualUint16Array = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isEqualUint16Array( 3.14, 3.14 ); // $ExpectType boolean + isEqualUint16Array( null, null ); // $ExpectType boolean + isEqualUint16Array( 'beep', 'boop' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isEqualUint16Array(); // $ExpectError + isEqualUint16Array( 3.14 ); // $ExpectError + isEqualUint16Array( 'beep', 'beep', 3.14 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint16array/examples/index.js b/lib/node_modules/@stdlib/assert/is-equal-uint16array/examples/index.js new file mode 100644 index 000000000000..cce67c8c5e1f --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint16array/examples/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var Uint16Array = require( '@stdlib/array/uint16' ); +var isEqualUint16Array = require( './../lib' ); + +var x = new Uint16Array( [ 1, 2, 3 ] ); +var y = new Uint16Array( [ 1, 2, 3 ] ); +var out = isEqualUint16Array( x, y ); +console.log( out ); +// => true + +x = new Uint16Array( [ 0, 0, 0 ] ); +y = [ 0, 0, 0 ]; +out = isEqualUint16Array( x, y ); +console.log( out ); +// => false + +x = new Uint16Array( [ 1, 2, 3 ] ); +y = new Uint16Array( [ 1, 2, 4 ] ); +out = isEqualUint16Array( x, y ); +console.log( out ); +// => false diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint16array/lib/index.js b/lib/node_modules/@stdlib/assert/is-equal-uint16array/lib/index.js new file mode 100644 index 000000000000..3e711a4904f0 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint16array/lib/index.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Test if two arguments are both Uint16Arrays and have equal values. +* +* @module @stdlib/assert/is-equal-uint16array +* +* @example +* var Uint16Array = require( '@stdlib/array/uint16' ); +* var isEqualUint16Array = require( '@stdlib/assert/is-equal-uint16array' ); +* +* var x = new Uint16Array( [ 1, 2, 3 ] ); +* var y = new Uint16Array( [ 1, 2, 3 ] ); +* +* var out = isEqualUint16Array( x, y ); +* // returns true +* +* @example +* var Uint16Array = require( '@stdlib/array/uint16' ); +* var isEqualUint16Array = require( '@stdlib/assert/is-equal-uint16array' ); +* +* var x = new Uint16Array( [ 1, 2, 3 ] ); +* var y = new Uint16Array( [ 1, 2, 4 ] ); +* +* var out = isEqualUint16Array( x, y ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint16array/lib/main.js b/lib/node_modules/@stdlib/assert/is-equal-uint16array/lib/main.js new file mode 100644 index 000000000000..c23e3730fa46 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint16array/lib/main.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isUint16Array = require( '@stdlib/assert/is-uint16array' ); +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); + + +// MAIN // + +/** +* Tests if two arguments are both Uint16Arrays and have equal values. +* +* @param {*} v1 - first value +* @param {*} v2 - second value +* @returns {boolean} boolean result +* +* @example +* var Uint16Array = require( '@stdlib/array/uint16' ); +* +* var x = new Uint16Array( [ 1, 2, 3 ] ); +* var y = new Uint16Array( [ 1, 2, 3 ] ); +* +* var out = isEqualUint16Array( x, y ); +* // returns true +* +* @example +* var Uint16Array = require( '@stdlib/array/uint16' ); +* +* var x = new Uint16Array( [ 1, 2, 3 ] ); +* var y = new Uint16Array( [ 1, 2, 4 ] ); +* +* var out = isEqualUint16Array( x, y ); +* // returns false +*/ +function isEqualUint16Array( v1, v2 ) { + return ( isUint16Array( v1 ) && isUint16Array( v2 ) && hasEqualValues( v1, v2 ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = isEqualUint16Array; diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint16array/package.json b/lib/node_modules/@stdlib/assert/is-equal-uint16array/package.json new file mode 100644 index 000000000000..43836c160ad0 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint16array/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/assert/is-equal-uint16array", + "version": "0.0.0", + "description": "Test if two arguments are both Uint16Arrays and have equal values.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "equal", + "same", + "strict", + "is", + "isequal", + "isstrictequal", + "type", + "check", + "valid", + "validate", + "test", + "typed", + "array" + ] +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint16array/test/test.js b/lib/node_modules/@stdlib/assert/is-equal-uint16array/test/test.js new file mode 100644 index 000000000000..846ef79b77a9 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint16array/test/test.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Uint16Array = require( '@stdlib/array/uint16' ); +var typedarray = require( '@stdlib/array/typed' ); +var isEqualUint16Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isEqualUint16Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided two Uint16Arrays having equal values', function test( t ) { + var x; + var y; + + x = new Uint16Array( [ 1, 2, 3 ] ); + t.strictEqual( isEqualUint16Array( x, x ), true, 'returns expected value' ); + + x = new Uint16Array( [ 1, 2, 3 ] ); + y = new Uint16Array( [ 1, 2, 3 ] ); + t.strictEqual( isEqualUint16Array( x, y ), true, 'returns expected value' ); + + x = new Uint16Array( [ 0, 0, 0 ] ); + y = new Uint16Array( [ 0, 0, 0 ] ); + t.strictEqual( isEqualUint16Array( x, y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `false` if not provided two Uint16Arrays having equal values', function test( t ) { + var x; + var y; + var i; + + x = [ + '', + 'beep', + 5, + 3.14, + -3.14, + 0.0, + -0.0, + true, + false, + null, + void 0, + [ 1.0 ], + {}, + function noop() {}, + typedarray( 10, 'float64' ), + typedarray( 10, 'int32' ), + typedarray( 10, 'float32' ), + [ 1.0, 2.0, 3.0 ], + [ NaN, NaN, NaN ] + ]; + y = [ + 'abc', + 'boop', + -5, + -3.14, + 3.14, + -0.0, + 0.0, + false, + true, + void 0, + null, + [ -1.0 ], + {}, + function noop() {}, + typedarray( 10, 'float64' ), + typedarray( 10, 'uint16' ), + typedarray( 10, 'float64' ), + [ 2.0, 4.0, 6.0 ], + [ NaN, NaN, NaN ] + ]; + for ( i = 0; i < x.length; i++ ) { + t.strictEqual( isEqualUint16Array( x[ i ], y[ i ] ), false, 'returns expected value when provided '+x[ i ]+' and '+y[ i ] ); + } + t.end(); +}); From d26ebbe1b4d25462e268c36136af4ce96f537887 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 00:31:58 -0700 Subject: [PATCH 35/60] feat: add `isEqualUint16Array` to namespace --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/assert/lib/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/lib/index.js b/lib/node_modules/@stdlib/assert/lib/index.js index f6c0fead8f50..b0b722d3f100 100644 --- a/lib/node_modules/@stdlib/assert/lib/index.js +++ b/lib/node_modules/@stdlib/assert/lib/index.js @@ -1215,6 +1215,15 @@ setReadOnly( ns, 'isEqualInt16Array', require( '@stdlib/assert/is-equal-int16arr */ setReadOnly( ns, 'isEqualInt32Array', require( '@stdlib/assert/is-equal-int32array' ) ); +/** +* @name isEqualUint16Array +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-equal-uint16array} +*/ +setReadOnly( ns, 'isEqualUint16Array', require( '@stdlib/assert/is-equal-uint16array' ) ); + /** * @name isEqualUint32Array * @memberof ns From fc389aa17d8efb2bc951688f075a1db643398b8b Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 00:33:08 -0700 Subject: [PATCH 36/60] feat: add `assert/is-equal-uint8array` to namespace --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../assert/is-equal-uint8array/README.md | 103 +++++++++++++++++ .../benchmark/benchmark.length.js | 96 ++++++++++++++++ .../assert/is-equal-uint8array/docs/repl.txt | 32 ++++++ .../is-equal-uint8array/docs/types/index.d.ts | 51 +++++++++ .../is-equal-uint8array/docs/types/test.ts | 36 ++++++ .../is-equal-uint8array/examples/index.js | 40 +++++++ .../assert/is-equal-uint8array/lib/index.js | 54 +++++++++ .../assert/is-equal-uint8array/lib/main.js | 61 ++++++++++ .../assert/is-equal-uint8array/package.json | 74 ++++++++++++ .../assert/is-equal-uint8array/test/test.js | 106 ++++++++++++++++++ 10 files changed, 653 insertions(+) create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8array/README.md create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8array/benchmark/benchmark.length.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8array/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8array/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8array/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8array/examples/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8array/lib/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8array/lib/main.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8array/package.json create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8array/test/test.js diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8array/README.md b/lib/node_modules/@stdlib/assert/is-equal-uint8array/README.md new file mode 100644 index 000000000000..a9504d60dd39 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8array/README.md @@ -0,0 +1,103 @@ + + +# isEqualUint8Array + +> Test if two arguments are both Uint8Arrays and have equal values. + +
+ +## Usage + +```javascript +var isEqualUint8Array = require( '@stdlib/assert/is-equal-uint8array' ); +``` + +#### isEqualUint8Array( v1, v2 ) + +Tests if two arguments are both Uint8Arrays and have equal values. + +```javascript +var Uint8Array = require( '@stdlib/array/uint8' ); + +var x = new Uint8Array( [ 1, 2 ] ); +var y = new Uint8Array( [ 1, 2 ] ); +var bool = isEqualUint8Array( x, y ); +// returns true + +bool = isEqualUint8Array( x, new Uint8Array( [ 1, 3 ] ) ); +// returns false +``` + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var Uint8Array = require( '@stdlib/array/uint8' ); +var isEqualUint8Array = require( '@stdlib/assert/is-equal-uint8array' ); + +var x = new Uint8Array( [ 1, 2, 3 ] ); +var y = new Uint8Array( [ 1, 2, 3 ] ); +var out = isEqualUint8Array( x, y ); +// returns true + +x = new Uint8Array( [ 0, 0, 0 ] ); +y = [ 0, 0, 0 ]; +out = isEqualUint8Array( x, y ); +// returns false + +x = new Uint8Array( [ 1, 2, 3 ] ); +y = new Uint8Array( [ 1, 2, 4 ] ); +out = isEqualUint8Array( x, y ); +// returns false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8array/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/assert/is-equal-uint8array/benchmark/benchmark.length.js new file mode 100644 index 000000000000..29c3c8d6e6d9 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8array/benchmark/benchmark.length.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var zeroTo = require( '@stdlib/array/zero-to' ); +var pkg = require( './../package.json' ).name; +var isEqualUint8Array = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = zeroTo( len, 'uint8' ); + var y = zeroTo( len, 'uint8' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var bool; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isEqualUint8Array( x, y ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8array/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-equal-uint8array/docs/repl.txt new file mode 100644 index 000000000000..20c15c675847 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8array/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( v1, v2 ) + Tests if two arguments are both Uint8Arrays and have equal values. + + Parameters + ---------- + v1: any + First input value. + + v2: any + Second input value. + + Returns + ------- + bool: boolean + Boolean indicating whether two arguments are equal. + + Examples + -------- + > var x = new {{alias:@stdlib/array/uint8}}( [ 1, 2, 3 ] ); + > var y = new {{alias:@stdlib/array/uint8}}( [ 1, 2, 3 ] ); + > var bool = {{alias}}( x, y ) + true + + > x = new {{alias:@stdlib/array/uint8}}( [ 1, 2, 3 ] ); + > y = new {{alias:@stdlib/array/uint8}}( [ 1, 2, 4 ] ); + > bool = {{alias}}( x, y ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8array/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-equal-uint8array/docs/types/index.d.ts new file mode 100644 index 000000000000..a5da30131fb5 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8array/docs/types/index.d.ts @@ -0,0 +1,51 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/** +* Tests if two arguments are both Uint8Arrays and have equal values. +* +* @param v1 - first input value +* @param v2 - second input value +* @returns boolean indicating whether two arguments are equal +* +* @example +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* var x = new Uint8Array( [ 1, 2, 3 ] ); +* var y = new Uint8Array( [ 1, 2, 3 ] ); +* +* var out = isEqualUint8Array( x, y ); +* // returns true +* +* @example +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* var x = new Uint8Array( [ 1, 2, 3 ] ); +* var y = new Uint8Array( [ 1, 2, 4 ] ); +* +* var out = isEqualUint8Array( x, y ); +* // returns false +*/ +declare function isEqualUint8Array( v1: any, v2: any ): boolean; + + +// EXPORTS // + +export = isEqualUint8Array; diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8array/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-equal-uint8array/docs/types/test.ts new file mode 100644 index 000000000000..296006e8207a --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8array/docs/types/test.ts @@ -0,0 +1,36 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import isEqualUint8Array = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isEqualUint8Array( 3.14, 3.14 ); // $ExpectType boolean + isEqualUint8Array( null, null ); // $ExpectType boolean + isEqualUint8Array( 'beep', 'boop' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isEqualUint8Array(); // $ExpectError + isEqualUint8Array( 3.14 ); // $ExpectError + isEqualUint8Array( 'beep', 'beep', 3.14 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8array/examples/index.js b/lib/node_modules/@stdlib/assert/is-equal-uint8array/examples/index.js new file mode 100644 index 000000000000..154ea4fcdde4 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8array/examples/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var Uint8Array = require( '@stdlib/array/uint8' ); +var isEqualUint8Array = require( './../lib' ); + +var x = new Uint8Array( [ 1, 2, 3 ] ); +var y = new Uint8Array( [ 1, 2, 3 ] ); +var out = isEqualUint8Array( x, y ); +console.log( out ); +// => true + +x = new Uint8Array( [ 0, 0, 0 ] ); +y = [ 0, 0, 0 ]; +out = isEqualUint8Array( x, y ); +console.log( out ); +// => false + +x = new Uint8Array( [ 1, 2, 3 ] ); +y = new Uint8Array( [ 1, 2, 4 ] ); +out = isEqualUint8Array( x, y ); +console.log( out ); +// => false diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8array/lib/index.js b/lib/node_modules/@stdlib/assert/is-equal-uint8array/lib/index.js new file mode 100644 index 000000000000..dd7b0f76edb7 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8array/lib/index.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Test if two arguments are both Uint8Arrays and have equal values. +* +* @module @stdlib/assert/is-equal-uint8array +* +* @example +* var Uint8Array = require( '@stdlib/array/uint8' ); +* var isEqualUint8Array = require( '@stdlib/assert/is-equal-uint8array' ); +* +* var x = new Uint8Array( [ 1, 2, 3 ] ); +* var y = new Uint8Array( [ 1, 2, 3 ] ); +* +* var out = isEqualUint8Array( x, y ); +* // returns true +* +* @example +* var Uint8Array = require( '@stdlib/array/uint8' ); +* var isEqualUint8Array = require( '@stdlib/assert/is-equal-uint8array' ); +* +* var x = new Uint8Array( [ 1, 2, 3 ] ); +* var y = new Uint8Array( [ 1, 2, 4 ] ); +* +* var out = isEqualUint8Array( x, y ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8array/lib/main.js b/lib/node_modules/@stdlib/assert/is-equal-uint8array/lib/main.js new file mode 100644 index 000000000000..c4986c809877 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8array/lib/main.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isUint8Array = require( '@stdlib/assert/is-uint8array' ); +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); + + +// MAIN // + +/** +* Tests if two arguments are both Uint8Arrays and have equal values. +* +* @param {*} v1 - first value +* @param {*} v2 - second value +* @returns {boolean} boolean result +* +* @example +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* var x = new Uint8Array( [ 1, 2, 3 ] ); +* var y = new Uint8Array( [ 1, 2, 3 ] ); +* +* var out = isEqualUint8Array( x, y ); +* // returns true +* +* @example +* var Uint8Array = require( '@stdlib/array/uint8' ); +* +* var x = new Uint8Array( [ 1, 2, 3 ] ); +* var y = new Uint8Array( [ 1, 2, 4 ] ); +* +* var out = isEqualUint8Array( x, y ); +* // returns false +*/ +function isEqualUint8Array( v1, v2 ) { + return ( isUint8Array( v1 ) && isUint8Array( v2 ) && hasEqualValues( v1, v2 ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = isEqualUint8Array; diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8array/package.json b/lib/node_modules/@stdlib/assert/is-equal-uint8array/package.json new file mode 100644 index 000000000000..4cf9f49e50ab --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8array/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/assert/is-equal-uint8array", + "version": "0.0.0", + "description": "Test if two arguments are both Uint8Arrays and have equal values.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "equal", + "same", + "strict", + "is", + "isequal", + "isstrictequal", + "type", + "check", + "valid", + "validate", + "test", + "typed", + "array" + ] +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8array/test/test.js b/lib/node_modules/@stdlib/assert/is-equal-uint8array/test/test.js new file mode 100644 index 000000000000..1318e5003015 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8array/test/test.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Uint8Array = require( '@stdlib/array/uint8' ); +var typedarray = require( '@stdlib/array/typed' ); +var isEqualUint8Array = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isEqualUint8Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided two Uint8Arrays having equal values', function test( t ) { + var x; + var y; + + x = new Uint8Array( [ 1, 2, 3 ] ); + t.strictEqual( isEqualUint8Array( x, x ), true, 'returns expected value' ); + + x = new Uint8Array( [ 1, 2, 3 ] ); + y = new Uint8Array( [ 1, 2, 3 ] ); + t.strictEqual( isEqualUint8Array( x, y ), true, 'returns expected value' ); + + x = new Uint8Array( [ 0, 0, 0 ] ); + y = new Uint8Array( [ 0, 0, 0 ] ); + t.strictEqual( isEqualUint8Array( x, y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `false` if not provided two Uint8Arrays having equal values', function test( t ) { + var x; + var y; + var i; + + x = [ + '', + 'beep', + 5, + 3.14, + -3.14, + 0.0, + -0.0, + true, + false, + null, + void 0, + [ 1.0 ], + {}, + function noop() {}, + typedarray( 10, 'float64' ), + typedarray( 10, 'int32' ), + typedarray( 10, 'float32' ), + [ 1.0, 2.0, 3.0 ], + [ NaN, NaN, NaN ] + ]; + y = [ + 'abc', + 'boop', + -5, + -3.14, + 3.14, + -0.0, + 0.0, + false, + true, + void 0, + null, + [ -1.0 ], + {}, + function noop() {}, + typedarray( 10, 'float64' ), + typedarray( 10, 'uint8' ), + typedarray( 10, 'float64' ), + [ 2.0, 4.0, 6.0 ], + [ NaN, NaN, NaN ] + ]; + for ( i = 0; i < x.length; i++ ) { + t.strictEqual( isEqualUint8Array( x[ i ], y[ i ] ), false, 'returns expected value when provided '+x[ i ]+' and '+y[ i ] ); + } + t.end(); +}); From e16606740154f7fd9dc727918b3b1c91a4dabd1c Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 00:34:07 -0700 Subject: [PATCH 37/60] feat: add `isEqualUint8Array` to namespace --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/assert/lib/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/lib/index.js b/lib/node_modules/@stdlib/assert/lib/index.js index b0b722d3f100..d79ab722bd98 100644 --- a/lib/node_modules/@stdlib/assert/lib/index.js +++ b/lib/node_modules/@stdlib/assert/lib/index.js @@ -1215,6 +1215,15 @@ setReadOnly( ns, 'isEqualInt16Array', require( '@stdlib/assert/is-equal-int16arr */ setReadOnly( ns, 'isEqualInt32Array', require( '@stdlib/assert/is-equal-int32array' ) ); +/** +* @name isEqualUint8Array +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-equal-uint8array} +*/ +setReadOnly( ns, 'isEqualUint8Array', require( '@stdlib/assert/is-equal-uint8array' ) ); + /** * @name isEqualUint16Array * @memberof ns From b5c4b2caf155d22f1e18c3843294b8af70a30ce7 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 00:37:25 -0700 Subject: [PATCH 38/60] feat: add `assert/is-equal-uint8clampedarray` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../is-equal-uint8clampedarray/README.md | 103 +++++++++++++++++ .../benchmark/benchmark.length.js | 96 ++++++++++++++++ .../is-equal-uint8clampedarray/docs/repl.txt | 32 ++++++ .../docs/types/index.d.ts | 51 +++++++++ .../docs/types/test.ts | 36 ++++++ .../examples/index.js | 40 +++++++ .../is-equal-uint8clampedarray/lib/index.js | 54 +++++++++ .../is-equal-uint8clampedarray/lib/main.js | 61 ++++++++++ .../is-equal-uint8clampedarray/package.json | 74 ++++++++++++ .../is-equal-uint8clampedarray/test/test.js | 106 ++++++++++++++++++ 10 files changed, 653 insertions(+) create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/README.md create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/benchmark/benchmark.length.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/examples/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/lib/index.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/lib/main.js create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/package.json create mode 100644 lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/test/test.js diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/README.md b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/README.md new file mode 100644 index 000000000000..f1957f31aeaa --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/README.md @@ -0,0 +1,103 @@ + + +# isEqualUint8ClampedArray + +> Test if two arguments are both Uint8ClampedArrays and have equal values. + +
+ +## Usage + +```javascript +var isEqualUint8ClampedArray = require( '@stdlib/assert/is-equal-uint8clampedarray' ); +``` + +#### isEqualUint8ClampedArray( v1, v2 ) + +Tests if two arguments are both Uint8ClampedArrays and have equal values. + +```javascript +var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); + +var x = new Uint8ClampedArray( [ 1, 2 ] ); +var y = new Uint8ClampedArray( [ 1, 2 ] ); +var bool = isEqualUint8ClampedArray( x, y ); +// returns true + +bool = isEqualUint8ClampedArray( x, new Uint8ClampedArray( [ 1, 3 ] ) ); +// returns false +``` + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +var isEqualUint8ClampedArray = require( '@stdlib/assert/is-equal-uint8clampedarray' ); + +var x = new Uint8ClampedArray( [ 1, 2, 3 ] ); +var y = new Uint8ClampedArray( [ 1, 2, 3 ] ); +var out = isEqualUint8ClampedArray( x, y ); +// returns true + +x = new Uint8ClampedArray( [ 0, 0, 0 ] ); +y = [ 0, 0, 0 ]; +out = isEqualUint8ClampedArray( x, y ); +// returns false + +x = new Uint8ClampedArray( [ 1, 2, 3 ] ); +y = new Uint8ClampedArray( [ 1, 2, 4 ] ); +out = isEqualUint8ClampedArray( x, y ); +// returns false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/benchmark/benchmark.length.js new file mode 100644 index 000000000000..a0b125b44cb0 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/benchmark/benchmark.length.js @@ -0,0 +1,96 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pow = require( '@stdlib/math/base/special/pow' ); +var zeroTo = require( '@stdlib/array/zero-to' ); +var pkg = require( './../package.json' ).name; +var isEqualUint8ClampedArray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = zeroTo( len, 'uint8c' ); + var y = zeroTo( len, 'uint8c' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var bool; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isEqualUint8ClampedArray( x, y ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/docs/repl.txt new file mode 100644 index 000000000000..92acfbfbd251 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( v1, v2 ) + Tests if two arguments are both Uint8ClampedArrays and have equal values. + + Parameters + ---------- + v1: any + First input value. + + v2: any + Second input value. + + Returns + ------- + bool: boolean + Boolean indicating whether two arguments are equal. + + Examples + -------- + > var x = new {{alias:@stdlib/array/uint8c}}( [ 1, 2, 3 ] ); + > var y = new {{alias:@stdlib/array/uint8c}}( [ 1, 2, 3 ] ); + > var bool = {{alias}}( x, y ) + true + + > x = new {{alias:@stdlib/array/uint8c}}( [ 1, 2, 3 ] ); + > y = new {{alias:@stdlib/array/uint8c}}( [ 1, 2, 4 ] ); + > bool = {{alias}}( x, y ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/docs/types/index.d.ts new file mode 100644 index 000000000000..13d3b96d0e6d --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/docs/types/index.d.ts @@ -0,0 +1,51 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/** +* Tests if two arguments are both Uint8ClampedArrays and have equal values. +* +* @param v1 - first input value +* @param v2 - second input value +* @returns boolean indicating whether two arguments are equal +* +* @example +* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +* +* var x = new Uint8ClampedArray( [ 1, 2, 3 ] ); +* var y = new Uint8ClampedArray( [ 1, 2, 3 ] ); +* +* var out = isEqualUint8ClampedArray( x, y ); +* // returns true +* +* @example +* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +* +* var x = new Uint8ClampedArray( [ 1, 2, 3 ] ); +* var y = new Uint8ClampedArray( [ 1, 2, 4 ] ); +* +* var out = isEqualUint8ClampedArray( x, y ); +* // returns false +*/ +declare function isEqualUint8ClampedArray( v1: any, v2: any ): boolean; + + +// EXPORTS // + +export = isEqualUint8ClampedArray; diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/docs/types/test.ts new file mode 100644 index 000000000000..2d5538140eca --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/docs/types/test.ts @@ -0,0 +1,36 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import isEqualUint8ClampedArray = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isEqualUint8ClampedArray( 3.14, 3.14 ); // $ExpectType boolean + isEqualUint8ClampedArray( null, null ); // $ExpectType boolean + isEqualUint8ClampedArray( 'beep', 'boop' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isEqualUint8ClampedArray(); // $ExpectError + isEqualUint8ClampedArray( 3.14 ); // $ExpectError + isEqualUint8ClampedArray( 'beep', 'beep', 3.14 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/examples/index.js b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/examples/index.js new file mode 100644 index 000000000000..fba7f5ca5abd --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/examples/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +var isEqualUint8ClampedArray = require( './../lib' ); + +var x = new Uint8ClampedArray( [ 1, 2, 3 ] ); +var y = new Uint8ClampedArray( [ 1, 2, 3 ] ); +var out = isEqualUint8ClampedArray( x, y ); +console.log( out ); +// => true + +x = new Uint8ClampedArray( [ 0, 0, 0 ] ); +y = [ 0, 0, 0 ]; +out = isEqualUint8ClampedArray( x, y ); +console.log( out ); +// => false + +x = new Uint8ClampedArray( [ 1, 2, 3 ] ); +y = new Uint8ClampedArray( [ 1, 2, 4 ] ); +out = isEqualUint8ClampedArray( x, y ); +console.log( out ); +// => false diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/lib/index.js b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/lib/index.js new file mode 100644 index 000000000000..78bdf75131f0 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/lib/index.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Test if two arguments are both Uint8ClampedArrays and have equal values. +* +* @module @stdlib/assert/is-equal-uint8clampedarray +* +* @example +* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +* var isEqualUint8ClampedArray = require( '@stdlib/assert/is-equal-uint8clampedarray' ); +* +* var x = new Uint8ClampedArray( [ 1, 2, 3 ] ); +* var y = new Uint8ClampedArray( [ 1, 2, 3 ] ); +* +* var out = isEqualUint8ClampedArray( x, y ); +* // returns true +* +* @example +* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +* var isEqualUint8ClampedArray = require( '@stdlib/assert/is-equal-uint8clampedarray' ); +* +* var x = new Uint8ClampedArray( [ 1, 2, 3 ] ); +* var y = new Uint8ClampedArray( [ 1, 2, 4 ] ); +* +* var out = isEqualUint8ClampedArray( x, y ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/lib/main.js b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/lib/main.js new file mode 100644 index 000000000000..3350a0e949c9 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/lib/main.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); + + +// MAIN // + +/** +* Tests if two arguments are both Uint8ClampedArrays and have equal values. +* +* @param {*} v1 - first value +* @param {*} v2 - second value +* @returns {boolean} boolean result +* +* @example +* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +* +* var x = new Uint8ClampedArray( [ 1, 2, 3 ] ); +* var y = new Uint8ClampedArray( [ 1, 2, 3 ] ); +* +* var out = isEqualUint8ClampedArray( x, y ); +* // returns true +* +* @example +* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +* +* var x = new Uint8ClampedArray( [ 1, 2, 3 ] ); +* var y = new Uint8ClampedArray( [ 1, 2, 4 ] ); +* +* var out = isEqualUint8ClampedArray( x, y ); +* // returns false +*/ +function isEqualUint8ClampedArray( v1, v2 ) { + return ( isUint8ClampedArray( v1 ) && isUint8ClampedArray( v2 ) && hasEqualValues( v1, v2 ) ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = isEqualUint8ClampedArray; diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/package.json b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/package.json new file mode 100644 index 000000000000..ef84ddb203a9 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/assert/is-equal-uint8clampedarray", + "version": "0.0.0", + "description": "Test if two arguments are both Uint8ClampedArrays and have equal values.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "equal", + "same", + "strict", + "is", + "isequal", + "isstrictequal", + "type", + "check", + "valid", + "validate", + "test", + "typed", + "array" + ] +} diff --git a/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/test/test.js b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/test/test.js new file mode 100644 index 000000000000..241003183abb --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-equal-uint8clampedarray/test/test.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +var typedarray = require( '@stdlib/array/typed' ); +var isEqualUint8ClampedArray = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isEqualUint8ClampedArray, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided two Uint8ClampedArrays having equal values', function test( t ) { + var x; + var y; + + x = new Uint8ClampedArray( [ 1, 2, 3 ] ); + t.strictEqual( isEqualUint8ClampedArray( x, x ), true, 'returns expected value' ); + + x = new Uint8ClampedArray( [ 1, 2, 3 ] ); + y = new Uint8ClampedArray( [ 1, 2, 3 ] ); + t.strictEqual( isEqualUint8ClampedArray( x, y ), true, 'returns expected value' ); + + x = new Uint8ClampedArray( [ 0, 0, 0 ] ); + y = new Uint8ClampedArray( [ 0, 0, 0 ] ); + t.strictEqual( isEqualUint8ClampedArray( x, y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `false` if not provided two Uint8ClampedArrays having equal values', function test( t ) { + var x; + var y; + var i; + + x = [ + '', + 'beep', + 5, + 3.14, + -3.14, + 0.0, + -0.0, + true, + false, + null, + void 0, + [ 1.0 ], + {}, + function noop() {}, + typedarray( 10, 'float64' ), + typedarray( 10, 'int32' ), + typedarray( 10, 'float32' ), + [ 1.0, 2.0, 3.0 ], + [ NaN, NaN, NaN ] + ]; + y = [ + 'abc', + 'boop', + -5, + -3.14, + 3.14, + -0.0, + 0.0, + false, + true, + void 0, + null, + [ -1.0 ], + {}, + function noop() {}, + typedarray( 10, 'float64' ), + typedarray( 10, 'uint8c' ), + typedarray( 10, 'float64' ), + [ 2.0, 4.0, 6.0 ], + [ NaN, NaN, NaN ] + ]; + for ( i = 0; i < x.length; i++ ) { + t.strictEqual( isEqualUint8ClampedArray( x[ i ], y[ i ] ), false, 'returns expected value when provided '+x[ i ]+' and '+y[ i ] ); + } + t.end(); +}); From 25231ce28c32227f3514a468dd6b9b2ca494e53b Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 00:38:18 -0700 Subject: [PATCH 39/60] feat: add `isEqualUint8ClampedArray` to namespace --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/assert/lib/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/lib/index.js b/lib/node_modules/@stdlib/assert/lib/index.js index d79ab722bd98..f09b226d171e 100644 --- a/lib/node_modules/@stdlib/assert/lib/index.js +++ b/lib/node_modules/@stdlib/assert/lib/index.js @@ -1224,6 +1224,15 @@ setReadOnly( ns, 'isEqualInt32Array', require( '@stdlib/assert/is-equal-int32arr */ setReadOnly( ns, 'isEqualUint8Array', require( '@stdlib/assert/is-equal-uint8array' ) ); +/** +* @name isEqualUint8ClampedArray +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-equal-uint8clampedarray} +*/ +setReadOnly( ns, 'isEqualUint8ClampedArray', require( '@stdlib/assert/is-equal-uint8clampedarray' ) ); + /** * @name isEqualUint16Array * @memberof ns From 031fecf3ade6e37cf1cda50ea30303cd922310b3 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 00:47:20 -0700 Subject: [PATCH 40/60] feat: add `ndarray/vector/int32` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/ndarray/vector/int32/README.md | 196 ++++ .../vector/int32/benchmark/benchmark.js | 47 + .../vector/int32/benchmark/benchmark.size.js | 93 ++ .../ndarray/vector/int32/docs/repl.txt | 175 +++ .../vector/int32/docs/types/index.d.ts | 377 ++++++ .../ndarray/vector/int32/docs/types/test.ts | 86 ++ .../ndarray/vector/int32/examples/index.js | 43 + .../@stdlib/ndarray/vector/int32/lib/index.js | 100 ++ .../@stdlib/ndarray/vector/int32/lib/main.js | 109 ++ .../@stdlib/ndarray/vector/int32/package.json | 64 ++ .../@stdlib/ndarray/vector/int32/test/test.js | 1022 +++++++++++++++++ 11 files changed, 2312 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int32/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int32/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int32/benchmark/benchmark.size.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int32/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int32/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int32/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int32/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int32/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int32/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int32/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int32/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/vector/int32/README.md b/lib/node_modules/@stdlib/ndarray/vector/int32/README.md new file mode 100644 index 000000000000..f69aa50e4d7b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int32/README.md @@ -0,0 +1,196 @@ + + +# Int32Vector + +> Create a signed 32-bit integer vector (i.e., a one-dimensional [ndarray][@stdlib/ndarray/ctor]). + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var Int32Vector = require( '@stdlib/ndarray/vector/int32' ); +``` + +#### Int32Vector( \[options] ) + +Returns a one-dimensional signed 32-bit integer [ndarray][@stdlib/ndarray/ctor]. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Int32Vector(); +// returns + +var len = numel( arr ); +// returns 0 +``` + +The function accepts the following options: + +- **order**: specifies whether an [ndarray][@stdlib/ndarray/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). Default: `'row-major'`. +- **mode**: specifies how to handle indices which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). Default: `'throw'`. +- **readonly**: boolean indicating whether an array should be **read-only**. Default: `false`. + +#### Int32Vector( length\[, options] ) + +Returns a one-dimensional signed 32-bit integer [ndarray][@stdlib/ndarray/ctor] having a specified `length`. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Int32Vector( 5 ); +// returns + +var len1 = numel( arr ); +// returns 5 +``` + +#### Int32Vector( obj\[, options] ) + +Creates a one-dimensional signed 32-bit integer [ndarray][@stdlib/ndarray/ctor] from an array-like object or iterable. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Int32Vector( [ 1, 2, 3 ] ); +// returns + +var len1 = numel( arr ); +// returns 3 +``` + +#### Int32Vector( buffer\[, byteOffset\[, length]]\[, options] ) + +Returns a one-dimensional signed 32-bit integer [ndarray][@stdlib/ndarray/ctor] view of an [`ArrayBuffer`][@stdlib/array/buffer]. + +```javascript +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var numel = require( '@stdlib/ndarray/numel' ); + +var buf = new ArrayBuffer( 32 ); + +var arr1 = new Int32Vector( buf ); +// returns + +var len1 = numel( arr1 ); +// returns 8 + +var arr2 = new Int32Vector( buf, 16 ); +// returns + +var len2 = numel( arr2 ); +// returns 4 + +var arr3 = new Int32Vector( buf, 16, 1 ); +// returns + +var len3 = numel( arr3 ); +// returns 1 +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sum = require( '@stdlib/blas/ext/sum' ); +var map = require( '@stdlib/ndarray/map' ); +var Int32Vector = require( '@stdlib/ndarray/vector/int32' ); + +// Create a vector containing random values: +var x = new Int32Vector( discreteUniform( 10, 0, 100 ) ); + +// Compute the sum: +var v = sum( x ); +console.log( v.get() ); + +// Define a function which applies a threshold to individual values: +function threshold( v ) { + return ( v > 10 ) ? v : 0; +} + +// Apply threshold: +var y = map( x, threshold ); + +// Recompute the sum: +v = sum( y ); +console.log( v.get() ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/vector/int32/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/vector/int32/benchmark/benchmark.js new file mode 100644 index 000000000000..47902139a39e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int32/benchmark/benchmark.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var Int32Vector = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Int32Vector( 0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/vector/int32/benchmark/benchmark.size.js b/lib/node_modules/@stdlib/ndarray/vector/int32/benchmark/benchmark.size.js new file mode 100644 index 000000000000..37fd93d43763 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int32/benchmark/benchmark.size.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var Int32Vector = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Int32Vector( len ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + 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( pkg+':size='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/vector/int32/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/vector/int32/docs/repl.txt new file mode 100644 index 000000000000..ebf0175f9b21 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int32/docs/repl.txt @@ -0,0 +1,175 @@ + +{{alias}}( [options] ) + Returns a one-dimensional signed 32-bit integer ndarray. + + Parameters + ---------- + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}() + + + +{{alias}}( length[, options] ) + Returns a one-dimensional signed 32-bit integer ndarray having a specified + length. + + Parameters + ---------- + length: integer + Number of elements. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}( 5 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 5 + + +{{alias}}( obj[, options] ) + Creates a one-dimensional signed 32-bit integer ndarray from an array-like + object or iterable. + + Parameters + ---------- + obj: Object + Array-like object or iterable from which to generate an ndarray. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var v = [ 1, 2, 3 ]; + > var arr = {{alias}}( v ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 3 + + +{{alias}}( buffer[, byteOffset[, length]][, options] ) + Returns a one-dimensional signed 32-bit integer ndarray view of an + ArrayBuffer. + + Parameters + ---------- + buffer: ArrayBuffer + Underlying ArrayBuffer. + + byteOffset: integer (optional) + Integer byte offset specifying the location of the first indexed + element. Default: 0. + + length: integer (optional) + View length. If not provided, the view spans from the byteOffset to + the end of the underlying ArrayBuffer. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var buf = new {{alias:@stdlib/array/buffer}}( 32 ); + > var arr = {{alias}}( buf, 0, 4 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 4 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/vector/int32/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/vector/int32/docs/types/index.d.ts new file mode 100644 index 000000000000..7ace37931d94 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int32/docs/types/index.d.ts @@ -0,0 +1,377 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/* eslint-disable @typescript-eslint/unified-signatures */ + +/// + +import { Order, Mode, int32ndarray } from '@stdlib/types/ndarray'; +import { Collection, AccessorArrayLike } from '@stdlib/types/array'; +import ArrayBuffer = require( '@stdlib/array/buffer' ); + +/** +* Interface describing function options. +*/ +interface Options { + /** + * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). + */ + order?: Order; + + /** + * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). + */ + mode?: Mode; + + /** + * Boolean indicating whether an array should be read-only (default: false). + */ + readonly?: boolean; +} + +/** +* Interface defining a typed vector constructor which is both "newable" and "callable". +*/ +interface Int32Vector { + /** + * Creates a signed 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int32Vector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + new ( options?: Options ): int32ndarray; + + /** + * Creates a signed 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int32Vector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( length: number, options?: Options ): int32ndarray; + + /** + * Creates a signed 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int32Vector( [ 1, 2 ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): int32ndarray; + + /** + * Creates a signed 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Int32Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 8 + */ + new ( buffer: ArrayBuffer, options?: Options ): int32ndarray; + + /** + * Creates a signed 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new Int32Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 6 + */ + new ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): int32ndarray; + + /** + * Creates a signed 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new Int32Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): int32ndarray; + + /** + * Creates a signed 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int32Vector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + ( options?: Options ): int32ndarray; + + /** + * Creates a signed 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int32Vector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( length: number, options?: Options ): int32ndarray; + + /** + * Creates a signed 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int32Vector( [ 1, 2 ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): int32ndarray; + + /** + * Creates a signed 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Int32Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 8 + */ + ( buffer: ArrayBuffer, options?: Options ): int32ndarray; + + /** + * Creates a signed 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new Int32Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 6 + */ + ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): int32ndarray; + + /** + * Creates a signed 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new Int32Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): int32ndarray; +} + +/** +* Creates a signed 32-bit integer vector (i.e., a one-dimensional ndarray). +* +* @param arg - length, typed array, array-like object, buffer, or iterable +* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) +* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer +* @param options - function options +* @param options.readonly - boolean indicating whether to return a read-only vector +* @param options.mode - specifies how to handle indices which exceed vector dimensions +* @param options.order - memory layout (either row-major or column-major) +* @returns one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int32Vector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int32Vector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int32Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Int32Vector( buf, 8, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +declare var ctor: Int32Vector; + + +// EXPORTS // + +export = ctor; diff --git a/lib/node_modules/@stdlib/ndarray/vector/int32/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/vector/int32/docs/types/test.ts new file mode 100644 index 000000000000..244d2a3d2c44 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int32/docs/types/test.ts @@ -0,0 +1,86 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import ArrayBuffer = require( '@stdlib/array/buffer' ); +import Int32Vector = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + new Int32Vector(); // $ExpectType int32ndarray + new Int32Vector( {} ); // $ExpectType int32ndarray + + new Int32Vector( 10 ); // $ExpectType int32ndarray + new Int32Vector( 10, {} ); // $ExpectType int32ndarray + + new Int32Vector( [ 1, 2, 3 ] ); // $ExpectType int32ndarray + new Int32Vector( [ 1, 2, 3 ], {} ); // $ExpectType int32ndarray + + new Int32Vector( new ArrayBuffer( 10 ) ); // $ExpectType int32ndarray + new Int32Vector( new ArrayBuffer( 10 ), {} ); // $ExpectType int32ndarray + + new Int32Vector( new ArrayBuffer( 10 ), 8 ); // $ExpectType int32ndarray + new Int32Vector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType int32ndarray + + new Int32Vector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType int32ndarray + new Int32Vector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType int32ndarray + + const vector = Int32Vector; + vector(); // $ExpectType int32ndarray + vector( {} ); // $ExpectType int32ndarray + + vector( 10 ); // $ExpectType int32ndarray + vector( 10, {} ); // $ExpectType int32ndarray + + vector( [ 1, 2, 3 ] ); // $ExpectType int32ndarray + vector( [ 1, 2, 3 ], {} ); // $ExpectType int32ndarray + + vector( new ArrayBuffer( 10 ) ); // $ExpectType int32ndarray + vector( new ArrayBuffer( 10 ), {} ); // $ExpectType int32ndarray + + vector( new ArrayBuffer( 10 ), 8 ); // $ExpectType int32ndarray + vector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType int32ndarray + + vector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType int32ndarray + vector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType int32ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not a number, array-like object, iterable, or options object... +{ + new Int32Vector( true ); // $ExpectError + new Int32Vector( false ); // $ExpectError + new Int32Vector( null ); // $ExpectError + new Int32Vector( ( x: number ): number => x ); // $ExpectError + + const vector = Int32Vector; + vector( true ); // $ExpectError + vector( false ); // $ExpectError + vector( null ); // $ExpectError + vector( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const buf = new ArrayBuffer( 32 ); + new Int32Vector( buf, 8, 2, {}, {} ); // $ExpectError + + const vector = Int32Vector; + vector( buf, 8, 2, {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/int32/examples/index.js b/lib/node_modules/@stdlib/ndarray/vector/int32/examples/index.js new file mode 100644 index 000000000000..0e4c76671cf8 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int32/examples/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sum = require( '@stdlib/blas/ext/sum' ); +var map = require( '@stdlib/ndarray/map' ); +var Int32Vector = require( './../lib' ); + +// Create a vector containing random values: +var x = new Int32Vector( discreteUniform( 10, 0, 100 ) ); + +// Compute the sum: +var v = sum( x ); +console.log( v.get() ); + +// Define a function which applies a threshold to individual values: +function threshold( v ) { + return ( v > 10 ) ? v : 0; +} + +// Apply threshold: +var y = map( x, threshold ); + +// Recompute the sum: +v = sum( y ); +console.log( v.get() ); diff --git a/lib/node_modules/@stdlib/ndarray/vector/int32/lib/index.js b/lib/node_modules/@stdlib/ndarray/vector/int32/lib/index.js new file mode 100644 index 000000000000..f9402a99e1d2 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int32/lib/index.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Create a signed 32-bit integer vector (i.e., a one-dimensional ndarray). +* +* @module @stdlib/ndarray/vector/int32 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int32Vector = require( '@stdlib/ndarray/vector/int32' ); +* +* var v = new Int32Vector(); +* // returns +* +* var len = numel( v ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int32Vector = require( '@stdlib/ndarray/vector/int32' ); +* +* var v = new Int32Vector( 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int32Vector = require( '@stdlib/ndarray/vector/int32' ); +* +* var v = new Int32Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int32Vector = require( '@stdlib/ndarray/vector/int32' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new Int32Vector( buf ); +* // returns +* +* var len = numel( v ); +* // returns 8 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int32Vector = require( '@stdlib/ndarray/vector/int32' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new Int32Vector( buf, 16 ); +* // returns +* +* var len = numel( v ); +* // returns 4 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int32Vector = require( '@stdlib/ndarray/vector/int32' ); +* +* var buf = new ArrayBuffer( 64 ); +* var v = new Int32Vector( buf, 16, 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/vector/int32/lib/main.js b/lib/node_modules/@stdlib/ndarray/vector/int32/lib/main.js new file mode 100644 index 000000000000..e31f7f6dc663 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int32/lib/main.js @@ -0,0 +1,109 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 factory = require( '@stdlib/ndarray/vector/ctor' ).factory; + + +// MAIN // + +/** +* Returns a signed 32-bit integer vector (i.e., a one-dimensional ndarray). +* +* @name Int32Vector +* @type {Function} +* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable +* @param {NonNegativeInteger} [byteOffset=0] - byte offset +* @param {NonNegativeInteger} [length] - view length +* @param {Options} [options] - function options +* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only vector +* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed vector dimensions +* @param {string} [options.order='row-major'] - memory layout (either row-major or column-major) +* @throws {TypeError} first argument must be either a length, typed array, array-like object, buffer, iterable, or options object +* @throws {TypeError} must provide valid options +* @returns {ndarray} one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int32Vector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int32Vector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int32Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Int32Vector( buf ); +* // returns +* +* var len = numel( arr ); +* // returns 8 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Int32Vector( buf, 16 ); +* // returns +* +* var len = numel( arr ); +* // returns 4 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 64 ); +* var arr = new Int32Vector( buf, 16, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +var Int32Vector = factory( 'int32' ); + + +// EXPORTS // + +module.exports = Int32Vector; diff --git a/lib/node_modules/@stdlib/ndarray/vector/int32/package.json b/lib/node_modules/@stdlib/ndarray/vector/int32/package.json new file mode 100644 index 000000000000..2ff5d5373ced --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int32/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/ndarray/vector/int32", + "version": "0.0.0", + "description": "Create a signed 32-bit integer vector (i.e., a one-dimensional ndarray).", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdtypes", + "types", + "data", + "structure", + "vector", + "vec", + "ndarray", + "constructor", + "ctor", + "int32" + ] +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/int32/test/test.js b/lib/node_modules/@stdlib/ndarray/vector/int32/test/test.js new file mode 100644 index 000000000000..d2a34ed56b81 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int32/test/test.js @@ -0,0 +1,1022 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* eslint-disable no-new */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isndarrayLikeWithDataType = require( '@stdlib/assert/is-ndarray-like-with-data-type' ); +var isEqualInt32Array = require( '@stdlib/assert/is-equal-int32array' ); +var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' ); +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var array2buffer = require( '@stdlib/buffer/from-array' ); +var Int32Vector = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Int32Vector, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int32Vector( value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int32Vector( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int32Vector( value, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int32Vector( value, 0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int32Vector( value, 0, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int32Vector( value, 0, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int32Vector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int32Vector( new ArrayBuffer( 8 ), value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int32Vector( new ArrayBuffer( 8 ), value, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int32Vector( new ArrayBuffer( 8 ), value, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int32Vector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int32Vector( new ArrayBuffer( 8 ), 0, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (length)', function test( t ) { + var values; + var i; + + 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() { + new Int32Vector( 10, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { + var values; + var i; + + 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() { + new Int32Vector( [], value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new Int32Vector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new Int32Vector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset, length)', function test( t ) { + var values; + var i; + + 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() { + new Int32Vector( new ArrayBuffer( 8 ), 0, 1, value ); + }; + } +}); + +tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'ROW', + 'row', + 'col-major', + 'col', + 'major', + 'minor', + null + ]; + + 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() { + new Int32Vector({ + 'order': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'THROW', + 5, + null, + true, + false, + [], + {} + ]; + + 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() { + new Int32Vector({ + 'mode': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + 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() { + new Int32Vector({ + 'readonly': value + }); + }; + } +}); + +tape( 'the function returns a one-dimensional ndarray', function test( t ) { + var arr; + + arr = new Int32Vector(); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + arr = new Int32Vector( {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (length)', function test( t ) { + var arr; + + arr = new Int32Vector( 10 ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + arr = new Int32Vector( 10, {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (array)', function test( t ) { + var arr; + var out; + + arr = [ 1, 2, 3, 4 ]; + + out = new Int32Vector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt32Array( getData( out ), new Int32Array( arr ) ), true, 'returns expected value' ); + + out = new Int32Vector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt32Array( getData( out ), new Int32Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (typed array)', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + out = new Int32Vector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt32Array( getData( out ), new Int32Array( arr ) ), true, 'returns expected value' ); + + out = new Int32Vector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt32Array( getData( out ), new Int32Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (buffer)', function test( t ) { + var arr; + var out; + var buf; + + arr = [ 1, 2, 3, 4 ]; + buf = array2buffer( arr ); + + out = new Int32Vector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt32Array( getData( out ), new Int32Array( arr ) ), true, 'returns expected value' ); + + out = new Int32Vector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt32Array( getData( out ), new Int32Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 8 ); + + out = new Int32Vector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualInt32Array( getData( out ), new Int32Array( buf ) ), true, 'returns expected value' ); + + out = new Int32Vector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualInt32Array( getData( out ), new Int32Array( buf ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new Int32Vector( buf, 8 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 6, 'returns expected value' ); + t.strictEqual( isEqualInt32Array( getData( out ), new Int32Array( buf, 8 ) ), true, 'returns expected value' ); + + out = new Int32Vector( buf, 8, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 6, 'returns expected value' ); + t.strictEqual( isEqualInt32Array( getData( out ), new Int32Array( buf, 8 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset, length)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new Int32Vector( buf, 8, 2 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualInt32Array( getData( out ), new Int32Array( buf, 8, 2 ) ), true, 'returns expected value' ); + + out = new Int32Vector( buf, 8, 2, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualInt32Array( getData( out ), new Int32Array( buf, 8, 2 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout', function test( t ) { + var arr; + + arr = new Int32Vector({ + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int32Vector({ + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (length)', function test( t ) { + var arr; + + arr = new Int32Vector( 10, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int32Vector( 10, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (array)', function test( t ) { + var arr; + + arr = new Int32Vector( [ 1, 2, 3, 4 ], { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int32Vector( [ 1, 2, 3, 4 ], { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer)', function test( t ) { + var arr; + + arr = new Int32Vector( new ArrayBuffer( 32 ), { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 8, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int32Vector( new ArrayBuffer( 32 ), { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 8, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Int32Vector( new ArrayBuffer( 32 ), 8, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 6, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int32Vector( new ArrayBuffer( 32 ), 8, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 6, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Int32Vector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int32Vector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays', function test( t ) { + var arr; + + arr = new Int32Vector({ + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (length)', function test( t ) { + var arr; + + arr = new Int32Vector( 10, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (array)', function test( t ) { + var arr; + + arr = new Int32Vector( [ 1, 2, 3, 4 ], { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new Int32Vector( new ArrayBuffer( 32 ), { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 8, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Int32Vector( new ArrayBuffer( 32 ), 8, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 6, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Int32Vector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays', function test( t ) { + var arr; + + arr = new Int32Vector({ + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (length)', function test( t ) { + var arr; + + arr = new Int32Vector( 10, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (array)', function test( t ) { + var arr; + + arr = new Int32Vector( [ 1, 2, 3, 4 ], { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new Int32Vector( new ArrayBuffer( 32 ), { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 8, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Int32Vector( new ArrayBuffer( 32 ), 8, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 6, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Int32Vector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); From ea3f7afc1eed9b9d6c7964b8e984dd1e205bcd24 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 01:01:06 -0700 Subject: [PATCH 41/60] feat: add `ndarray/vector/int16` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/ndarray/vector/int16/README.md | 196 ++++ .../vector/int16/benchmark/benchmark.js | 47 + .../vector/int16/benchmark/benchmark.size.js | 93 ++ .../ndarray/vector/int16/docs/repl.txt | 175 +++ .../vector/int16/docs/types/index.d.ts | 377 ++++++ .../ndarray/vector/int16/docs/types/test.ts | 86 ++ .../ndarray/vector/int16/examples/index.js | 43 + .../@stdlib/ndarray/vector/int16/lib/index.js | 100 ++ .../@stdlib/ndarray/vector/int16/lib/main.js | 109 ++ .../@stdlib/ndarray/vector/int16/package.json | 64 ++ .../@stdlib/ndarray/vector/int16/test/test.js | 1022 +++++++++++++++++ 11 files changed, 2312 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int16/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int16/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int16/benchmark/benchmark.size.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int16/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int16/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int16/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int16/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int16/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int16/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int16/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int16/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/vector/int16/README.md b/lib/node_modules/@stdlib/ndarray/vector/int16/README.md new file mode 100644 index 000000000000..d0530f89516e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int16/README.md @@ -0,0 +1,196 @@ + + +# Int16Vector + +> Create a signed 16-bit integer vector (i.e., a one-dimensional [ndarray][@stdlib/ndarray/ctor]). + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var Int16Vector = require( '@stdlib/ndarray/vector/int16' ); +``` + +#### Int16Vector( \[options] ) + +Returns a one-dimensional signed 16-bit integer [ndarray][@stdlib/ndarray/ctor]. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Int16Vector(); +// returns + +var len = numel( arr ); +// returns 0 +``` + +The function accepts the following options: + +- **order**: specifies whether an [ndarray][@stdlib/ndarray/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). Default: `'row-major'`. +- **mode**: specifies how to handle indices which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). Default: `'throw'`. +- **readonly**: boolean indicating whether an array should be **read-only**. Default: `false`. + +#### Int16Vector( length\[, options] ) + +Returns a one-dimensional signed 16-bit integer [ndarray][@stdlib/ndarray/ctor] having a specified `length`. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Int16Vector( 5 ); +// returns + +var len1 = numel( arr ); +// returns 5 +``` + +#### Int16Vector( obj\[, options] ) + +Creates a one-dimensional signed 16-bit integer [ndarray][@stdlib/ndarray/ctor] from an array-like object or iterable. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Int16Vector( [ 1, 2, 3 ] ); +// returns + +var len1 = numel( arr ); +// returns 3 +``` + +#### Int16Vector( buffer\[, byteOffset\[, length]]\[, options] ) + +Returns a one-dimensional signed 16-bit integer [ndarray][@stdlib/ndarray/ctor] view of an [`ArrayBuffer`][@stdlib/array/buffer]. + +```javascript +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var numel = require( '@stdlib/ndarray/numel' ); + +var buf = new ArrayBuffer( 32 ); + +var arr1 = new Int16Vector( buf ); +// returns + +var len1 = numel( arr1 ); +// returns 16 + +var arr2 = new Int16Vector( buf, 16 ); +// returns + +var len2 = numel( arr2 ); +// returns 8 + +var arr3 = new Int16Vector( buf, 16, 1 ); +// returns + +var len3 = numel( arr3 ); +// returns 1 +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sum = require( '@stdlib/blas/ext/sum' ); +var map = require( '@stdlib/ndarray/map' ); +var Int16Vector = require( '@stdlib/ndarray/vector/int16' ); + +// Create a vector containing random values: +var x = new Int16Vector( discreteUniform( 10, 0, 100 ) ); + +// Compute the sum: +var v = sum( x ); +console.log( v.get() ); + +// Define a function which applies a threshold to individual values: +function threshold( v ) { + return ( v > 10 ) ? v : 0; +} + +// Apply threshold: +var y = map( x, threshold ); + +// Recompute the sum: +v = sum( y ); +console.log( v.get() ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/vector/int16/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/vector/int16/benchmark/benchmark.js new file mode 100644 index 000000000000..08ad96fbcff0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int16/benchmark/benchmark.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var Int16Vector = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Int16Vector( 0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/vector/int16/benchmark/benchmark.size.js b/lib/node_modules/@stdlib/ndarray/vector/int16/benchmark/benchmark.size.js new file mode 100644 index 000000000000..9e74d92772b8 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int16/benchmark/benchmark.size.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var Int16Vector = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Int16Vector( len ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + 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( pkg+':size='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/vector/int16/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/vector/int16/docs/repl.txt new file mode 100644 index 000000000000..8ef849be732f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int16/docs/repl.txt @@ -0,0 +1,175 @@ + +{{alias}}( [options] ) + Returns a one-dimensional signed 16-bit integer ndarray. + + Parameters + ---------- + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}() + + + +{{alias}}( length[, options] ) + Returns a one-dimensional signed 16-bit integer ndarray having a specified + length. + + Parameters + ---------- + length: integer + Number of elements. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}( 5 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 5 + + +{{alias}}( obj[, options] ) + Creates a one-dimensional signed 16-bit integer ndarray from an array-like + object or iterable. + + Parameters + ---------- + obj: Object + Array-like object or iterable from which to generate an ndarray. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var v = [ 1, 2, 3 ]; + > var arr = {{alias}}( v ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 3 + + +{{alias}}( buffer[, byteOffset[, length]][, options] ) + Returns a one-dimensional signed 16-bit integer ndarray view of an + ArrayBuffer. + + Parameters + ---------- + buffer: ArrayBuffer + Underlying ArrayBuffer. + + byteOffset: integer (optional) + Integer byte offset specifying the location of the first indexed + element. Default: 0. + + length: integer (optional) + View length. If not provided, the view spans from the byteOffset to + the end of the underlying ArrayBuffer. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var buf = new {{alias:@stdlib/array/buffer}}( 32 ); + > var arr = {{alias}}( buf, 0, 4 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 4 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/vector/int16/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/vector/int16/docs/types/index.d.ts new file mode 100644 index 000000000000..b7d746f9f3b0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int16/docs/types/index.d.ts @@ -0,0 +1,377 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/* eslint-disable @typescript-eslint/unified-signatures */ + +/// + +import { Order, Mode, int16ndarray } from '@stdlib/types/ndarray'; +import { Collection, AccessorArrayLike } from '@stdlib/types/array'; +import ArrayBuffer = require( '@stdlib/array/buffer' ); + +/** +* Interface describing function options. +*/ +interface Options { + /** + * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). + */ + order?: Order; + + /** + * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). + */ + mode?: Mode; + + /** + * Boolean indicating whether an array should be read-only (default: false). + */ + readonly?: boolean; +} + +/** +* Interface defining a typed vector constructor which is both "newable" and "callable". +*/ +interface Int16Vector { + /** + * Creates a signed 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int16Vector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + new ( options?: Options ): int16ndarray; + + /** + * Creates a signed 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int16Vector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( length: number, options?: Options ): int16ndarray; + + /** + * Creates a signed 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int16Vector( [ 1, 2 ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): int16ndarray; + + /** + * Creates a signed 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Int16Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 16 + */ + new ( buffer: ArrayBuffer, options?: Options ): int16ndarray; + + /** + * Creates a signed 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new Int16Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 12 + */ + new ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): int16ndarray; + + /** + * Creates a signed 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new Int16Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): int16ndarray; + + /** + * Creates a signed 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int16Vector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + ( options?: Options ): int16ndarray; + + /** + * Creates a signed 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int16Vector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( length: number, options?: Options ): int16ndarray; + + /** + * Creates a signed 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int16Vector( [ 1, 2 ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): int16ndarray; + + /** + * Creates a signed 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Int16Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 16 + */ + ( buffer: ArrayBuffer, options?: Options ): int16ndarray; + + /** + * Creates a signed 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new Int16Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 12 + */ + ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): int16ndarray; + + /** + * Creates a signed 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new Int16Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): int16ndarray; +} + +/** +* Creates a signed 16-bit integer vector (i.e., a one-dimensional ndarray). +* +* @param arg - length, typed array, array-like object, buffer, or iterable +* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) +* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer +* @param options - function options +* @param options.readonly - boolean indicating whether to return a read-only vector +* @param options.mode - specifies how to handle indices which exceed vector dimensions +* @param options.order - memory layout (either row-major or column-major) +* @returns one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int16Vector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int16Vector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int16Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Int16Vector( buf, 8, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +declare var ctor: Int16Vector; + + +// EXPORTS // + +export = ctor; diff --git a/lib/node_modules/@stdlib/ndarray/vector/int16/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/vector/int16/docs/types/test.ts new file mode 100644 index 000000000000..36b8fb269c33 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int16/docs/types/test.ts @@ -0,0 +1,86 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import ArrayBuffer = require( '@stdlib/array/buffer' ); +import Int16Vector = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + new Int16Vector(); // $ExpectType int16ndarray + new Int16Vector( {} ); // $ExpectType int16ndarray + + new Int16Vector( 10 ); // $ExpectType int16ndarray + new Int16Vector( 10, {} ); // $ExpectType int16ndarray + + new Int16Vector( [ 1, 2, 3 ] ); // $ExpectType int16ndarray + new Int16Vector( [ 1, 2, 3 ], {} ); // $ExpectType int16ndarray + + new Int16Vector( new ArrayBuffer( 10 ) ); // $ExpectType int16ndarray + new Int16Vector( new ArrayBuffer( 10 ), {} ); // $ExpectType int16ndarray + + new Int16Vector( new ArrayBuffer( 10 ), 8 ); // $ExpectType int16ndarray + new Int16Vector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType int16ndarray + + new Int16Vector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType int16ndarray + new Int16Vector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType int16ndarray + + const vector = Int16Vector; + vector(); // $ExpectType int16ndarray + vector( {} ); // $ExpectType int16ndarray + + vector( 10 ); // $ExpectType int16ndarray + vector( 10, {} ); // $ExpectType int16ndarray + + vector( [ 1, 2, 3 ] ); // $ExpectType int16ndarray + vector( [ 1, 2, 3 ], {} ); // $ExpectType int16ndarray + + vector( new ArrayBuffer( 10 ) ); // $ExpectType int16ndarray + vector( new ArrayBuffer( 10 ), {} ); // $ExpectType int16ndarray + + vector( new ArrayBuffer( 10 ), 8 ); // $ExpectType int16ndarray + vector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType int16ndarray + + vector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType int16ndarray + vector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType int16ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not a number, array-like object, iterable, or options object... +{ + new Int16Vector( true ); // $ExpectError + new Int16Vector( false ); // $ExpectError + new Int16Vector( null ); // $ExpectError + new Int16Vector( ( x: number ): number => x ); // $ExpectError + + const vector = Int16Vector; + vector( true ); // $ExpectError + vector( false ); // $ExpectError + vector( null ); // $ExpectError + vector( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const buf = new ArrayBuffer( 32 ); + new Int16Vector( buf, 8, 2, {}, {} ); // $ExpectError + + const vector = Int16Vector; + vector( buf, 8, 2, {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/int16/examples/index.js b/lib/node_modules/@stdlib/ndarray/vector/int16/examples/index.js new file mode 100644 index 000000000000..0d5c44751982 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int16/examples/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sum = require( '@stdlib/blas/ext/sum' ); +var map = require( '@stdlib/ndarray/map' ); +var Int16Vector = require( './../lib' ); + +// Create a vector containing random values: +var x = new Int16Vector( discreteUniform( 10, 0, 100 ) ); + +// Compute the sum: +var v = sum( x ); +console.log( v.get() ); + +// Define a function which applies a threshold to individual values: +function threshold( v ) { + return ( v > 10 ) ? v : 0; +} + +// Apply threshold: +var y = map( x, threshold ); + +// Recompute the sum: +v = sum( y ); +console.log( v.get() ); diff --git a/lib/node_modules/@stdlib/ndarray/vector/int16/lib/index.js b/lib/node_modules/@stdlib/ndarray/vector/int16/lib/index.js new file mode 100644 index 000000000000..9af7e848bfec --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int16/lib/index.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Create a signed 16-bit integer vector (i.e., a one-dimensional ndarray). +* +* @module @stdlib/ndarray/vector/int16 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int16Vector = require( '@stdlib/ndarray/vector/int16' ); +* +* var v = new Int16Vector(); +* // returns +* +* var len = numel( v ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int16Vector = require( '@stdlib/ndarray/vector/int16' ); +* +* var v = new Int16Vector( 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int16Vector = require( '@stdlib/ndarray/vector/int16' ); +* +* var v = new Int16Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int16Vector = require( '@stdlib/ndarray/vector/int16' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new Int16Vector( buf ); +* // returns +* +* var len = numel( v ); +* // returns 16 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int16Vector = require( '@stdlib/ndarray/vector/int16' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new Int16Vector( buf, 16 ); +* // returns +* +* var len = numel( v ); +* // returns 8 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int16Vector = require( '@stdlib/ndarray/vector/int16' ); +* +* var buf = new ArrayBuffer( 64 ); +* var v = new Int16Vector( buf, 16, 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/vector/int16/lib/main.js b/lib/node_modules/@stdlib/ndarray/vector/int16/lib/main.js new file mode 100644 index 000000000000..133042f32372 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int16/lib/main.js @@ -0,0 +1,109 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 factory = require( '@stdlib/ndarray/vector/ctor' ).factory; + + +// MAIN // + +/** +* Returns a signed 16-bit integer vector (i.e., a one-dimensional ndarray). +* +* @name Int16Vector +* @type {Function} +* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable +* @param {NonNegativeInteger} [byteOffset=0] - byte offset +* @param {NonNegativeInteger} [length] - view length +* @param {Options} [options] - function options +* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only vector +* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed vector dimensions +* @param {string} [options.order='row-major'] - memory layout (either row-major or column-major) +* @throws {TypeError} first argument must be either a length, typed array, array-like object, buffer, iterable, or options object +* @throws {TypeError} must provide valid options +* @returns {ndarray} one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int16Vector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int16Vector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int16Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Int16Vector( buf ); +* // returns +* +* var len = numel( arr ); +* // returns 16 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Int16Vector( buf, 16 ); +* // returns +* +* var len = numel( arr ); +* // returns 8 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 64 ); +* var arr = new Int16Vector( buf, 16, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +var Int16Vector = factory( 'int16' ); + + +// EXPORTS // + +module.exports = Int16Vector; diff --git a/lib/node_modules/@stdlib/ndarray/vector/int16/package.json b/lib/node_modules/@stdlib/ndarray/vector/int16/package.json new file mode 100644 index 000000000000..f408ca2a6f73 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int16/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/ndarray/vector/int16", + "version": "0.0.0", + "description": "Create a signed 16-bit integer vector (i.e., a one-dimensional ndarray).", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdtypes", + "types", + "data", + "structure", + "vector", + "vec", + "ndarray", + "constructor", + "ctor", + "int16" + ] +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/int16/test/test.js b/lib/node_modules/@stdlib/ndarray/vector/int16/test/test.js new file mode 100644 index 000000000000..597d94984741 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int16/test/test.js @@ -0,0 +1,1022 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* eslint-disable no-new */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isndarrayLikeWithDataType = require( '@stdlib/assert/is-ndarray-like-with-data-type' ); +var isEqualInt16Array = require( '@stdlib/assert/is-equal-int16array' ); +var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' ); +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Int16Array = require( '@stdlib/array/int16' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var array2buffer = require( '@stdlib/buffer/from-array' ); +var Int16Vector = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Int16Vector, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int16Vector( value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int16Vector( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int16Vector( value, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int16Vector( value, 0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int16Vector( value, 0, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int16Vector( value, 0, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int16Vector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int16Vector( new ArrayBuffer( 8 ), value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int16Vector( new ArrayBuffer( 8 ), value, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int16Vector( new ArrayBuffer( 8 ), value, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int16Vector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int16Vector( new ArrayBuffer( 8 ), 0, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (length)', function test( t ) { + var values; + var i; + + 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() { + new Int16Vector( 10, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { + var values; + var i; + + 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() { + new Int16Vector( [], value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new Int16Vector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new Int16Vector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset, length)', function test( t ) { + var values; + var i; + + 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() { + new Int16Vector( new ArrayBuffer( 8 ), 0, 1, value ); + }; + } +}); + +tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'ROW', + 'row', + 'col-major', + 'col', + 'major', + 'minor', + null + ]; + + 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() { + new Int16Vector({ + 'order': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'THROW', + 5, + null, + true, + false, + [], + {} + ]; + + 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() { + new Int16Vector({ + 'mode': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + 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() { + new Int16Vector({ + 'readonly': value + }); + }; + } +}); + +tape( 'the function returns a one-dimensional ndarray', function test( t ) { + var arr; + + arr = new Int16Vector(); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + arr = new Int16Vector( {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (length)', function test( t ) { + var arr; + + arr = new Int16Vector( 10 ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + arr = new Int16Vector( 10, {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (array)', function test( t ) { + var arr; + var out; + + arr = [ 1, 2, 3, 4 ]; + + out = new Int16Vector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt16Array( getData( out ), new Int16Array( arr ) ), true, 'returns expected value' ); + + out = new Int16Vector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt16Array( getData( out ), new Int16Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (typed array)', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + out = new Int16Vector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt16Array( getData( out ), new Int16Array( arr ) ), true, 'returns expected value' ); + + out = new Int16Vector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt16Array( getData( out ), new Int16Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (buffer)', function test( t ) { + var arr; + var out; + var buf; + + arr = [ 1, 2, 3, 4 ]; + buf = array2buffer( arr ); + + out = new Int16Vector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt16Array( getData( out ), new Int16Array( arr ) ), true, 'returns expected value' ); + + out = new Int16Vector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt16Array( getData( out ), new Int16Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 8 ); + + out = new Int16Vector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt16Array( getData( out ), new Int16Array( buf ) ), true, 'returns expected value' ); + + out = new Int16Vector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt16Array( getData( out ), new Int16Array( buf ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new Int16Vector( buf, 8 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 12, 'returns expected value' ); + t.strictEqual( isEqualInt16Array( getData( out ), new Int16Array( buf, 8 ) ), true, 'returns expected value' ); + + out = new Int16Vector( buf, 8, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 12, 'returns expected value' ); + t.strictEqual( isEqualInt16Array( getData( out ), new Int16Array( buf, 8 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset, length)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new Int16Vector( buf, 8, 2 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualInt16Array( getData( out ), new Int16Array( buf, 8, 2 ) ), true, 'returns expected value' ); + + out = new Int16Vector( buf, 8, 2, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualInt16Array( getData( out ), new Int16Array( buf, 8, 2 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout', function test( t ) { + var arr; + + arr = new Int16Vector({ + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int16Vector({ + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (length)', function test( t ) { + var arr; + + arr = new Int16Vector( 10, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int16Vector( 10, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (array)', function test( t ) { + var arr; + + arr = new Int16Vector( [ 1, 2, 3, 4 ], { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int16Vector( [ 1, 2, 3, 4 ], { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer)', function test( t ) { + var arr; + + arr = new Int16Vector( new ArrayBuffer( 32 ), { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 16, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int16Vector( new ArrayBuffer( 32 ), { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 16, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Int16Vector( new ArrayBuffer( 32 ), 8, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 12, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int16Vector( new ArrayBuffer( 32 ), 8, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 12, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Int16Vector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int16Vector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays', function test( t ) { + var arr; + + arr = new Int16Vector({ + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (length)', function test( t ) { + var arr; + + arr = new Int16Vector( 10, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (array)', function test( t ) { + var arr; + + arr = new Int16Vector( [ 1, 2, 3, 4 ], { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new Int16Vector( new ArrayBuffer( 32 ), { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 16, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Int16Vector( new ArrayBuffer( 32 ), 8, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 12, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Int16Vector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays', function test( t ) { + var arr; + + arr = new Int16Vector({ + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (length)', function test( t ) { + var arr; + + arr = new Int16Vector( 10, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (array)', function test( t ) { + var arr; + + arr = new Int16Vector( [ 1, 2, 3, 4 ], { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new Int16Vector( new ArrayBuffer( 32 ), { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 16, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Int16Vector( new ArrayBuffer( 32 ), 8, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 12, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Int16Vector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); From 3e6bb9d2c5d0977b0e101d89d6db13772aabb17c Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 01:07:24 -0700 Subject: [PATCH 42/60] feat: add `ndarray/vector/int8` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/ndarray/vector/int8/README.md | 196 ++++ .../vector/int8/benchmark/benchmark.js | 47 + .../vector/int8/benchmark/benchmark.size.js | 93 ++ .../@stdlib/ndarray/vector/int8/docs/repl.txt | 175 +++ .../ndarray/vector/int8/docs/types/index.d.ts | 377 ++++++ .../ndarray/vector/int8/docs/types/test.ts | 86 ++ .../ndarray/vector/int8/examples/index.js | 43 + .../@stdlib/ndarray/vector/int8/lib/index.js | 100 ++ .../@stdlib/ndarray/vector/int8/lib/main.js | 109 ++ .../@stdlib/ndarray/vector/int8/package.json | 64 ++ .../@stdlib/ndarray/vector/int8/test/test.js | 1022 +++++++++++++++++ 11 files changed, 2312 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int8/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int8/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int8/benchmark/benchmark.size.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int8/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int8/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int8/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int8/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int8/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int8/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int8/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/vector/int8/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/vector/int8/README.md b/lib/node_modules/@stdlib/ndarray/vector/int8/README.md new file mode 100644 index 000000000000..e41dbc71fb48 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int8/README.md @@ -0,0 +1,196 @@ + + +# Int8Vector + +> Create a signed 8-bit integer vector (i.e., a one-dimensional [ndarray][@stdlib/ndarray/ctor]). + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var Int8Vector = require( '@stdlib/ndarray/vector/int8' ); +``` + +#### Int8Vector( \[options] ) + +Returns a one-dimensional signed 8-bit integer [ndarray][@stdlib/ndarray/ctor]. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Int8Vector(); +// returns + +var len = numel( arr ); +// returns 0 +``` + +The function accepts the following options: + +- **order**: specifies whether an [ndarray][@stdlib/ndarray/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). Default: `'row-major'`. +- **mode**: specifies how to handle indices which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). Default: `'throw'`. +- **readonly**: boolean indicating whether an array should be **read-only**. Default: `false`. + +#### Int8Vector( length\[, options] ) + +Returns a one-dimensional signed 8-bit integer [ndarray][@stdlib/ndarray/ctor] having a specified `length`. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Int8Vector( 5 ); +// returns + +var len1 = numel( arr ); +// returns 5 +``` + +#### Int8Vector( obj\[, options] ) + +Creates a one-dimensional signed 8-bit integer [ndarray][@stdlib/ndarray/ctor] from an array-like object or iterable. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Int8Vector( [ 1, 2, 3 ] ); +// returns + +var len1 = numel( arr ); +// returns 3 +``` + +#### Int8Vector( buffer\[, byteOffset\[, length]]\[, options] ) + +Returns a one-dimensional signed 8-bit integer [ndarray][@stdlib/ndarray/ctor] view of an [`ArrayBuffer`][@stdlib/array/buffer]. + +```javascript +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var numel = require( '@stdlib/ndarray/numel' ); + +var buf = new ArrayBuffer( 32 ); + +var arr1 = new Int8Vector( buf ); +// returns + +var len1 = numel( arr1 ); +// returns 32 + +var arr2 = new Int8Vector( buf, 16 ); +// returns + +var len2 = numel( arr2 ); +// returns 16 + +var arr3 = new Int8Vector( buf, 16, 1 ); +// returns + +var len3 = numel( arr3 ); +// returns 1 +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sum = require( '@stdlib/blas/ext/sum' ); +var map = require( '@stdlib/ndarray/map' ); +var Int8Vector = require( '@stdlib/ndarray/vector/int8' ); + +// Create a vector containing random values: +var x = new Int8Vector( discreteUniform( 10, 0, 100 ) ); + +// Compute the sum: +var v = sum( x ); +console.log( v.get() ); + +// Define a function which applies a threshold to individual values: +function threshold( v ) { + return ( v > 10 ) ? v : 0; +} + +// Apply threshold: +var y = map( x, threshold ); + +// Recompute the sum: +v = sum( y ); +console.log( v.get() ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/vector/int8/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/vector/int8/benchmark/benchmark.js new file mode 100644 index 000000000000..7794872e9282 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int8/benchmark/benchmark.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var Int8Vector = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Int8Vector( 0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/vector/int8/benchmark/benchmark.size.js b/lib/node_modules/@stdlib/ndarray/vector/int8/benchmark/benchmark.size.js new file mode 100644 index 000000000000..d4ad1ba01554 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int8/benchmark/benchmark.size.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var Int8Vector = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Int8Vector( len ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + 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( pkg+':size='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/vector/int8/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/vector/int8/docs/repl.txt new file mode 100644 index 000000000000..b88b70ddea19 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int8/docs/repl.txt @@ -0,0 +1,175 @@ + +{{alias}}( [options] ) + Returns a one-dimensional signed 8-bit integer ndarray. + + Parameters + ---------- + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}() + + + +{{alias}}( length[, options] ) + Returns a one-dimensional signed 8-bit integer ndarray having a specified + length. + + Parameters + ---------- + length: integer + Number of elements. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}( 5 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 5 + + +{{alias}}( obj[, options] ) + Creates a one-dimensional signed 8-bit integer ndarray from an array-like + object or iterable. + + Parameters + ---------- + obj: Object + Array-like object or iterable from which to generate an ndarray. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var v = [ 1, 2, 3 ]; + > var arr = {{alias}}( v ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 3 + + +{{alias}}( buffer[, byteOffset[, length]][, options] ) + Returns a one-dimensional signed 8-bit integer ndarray view of an + ArrayBuffer. + + Parameters + ---------- + buffer: ArrayBuffer + Underlying ArrayBuffer. + + byteOffset: integer (optional) + Integer byte offset specifying the location of the first indexed + element. Default: 0. + + length: integer (optional) + View length. If not provided, the view spans from the byteOffset to + the end of the underlying ArrayBuffer. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var buf = new {{alias:@stdlib/array/buffer}}( 32 ); + > var arr = {{alias}}( buf, 0, 4 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 4 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/vector/int8/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/vector/int8/docs/types/index.d.ts new file mode 100644 index 000000000000..0824a1fbb11b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int8/docs/types/index.d.ts @@ -0,0 +1,377 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/* eslint-disable @typescript-eslint/unified-signatures */ + +/// + +import { Order, Mode, int8ndarray } from '@stdlib/types/ndarray'; +import { Collection, AccessorArrayLike } from '@stdlib/types/array'; +import ArrayBuffer = require( '@stdlib/array/buffer' ); + +/** +* Interface describing function options. +*/ +interface Options { + /** + * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). + */ + order?: Order; + + /** + * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). + */ + mode?: Mode; + + /** + * Boolean indicating whether an array should be read-only (default: false). + */ + readonly?: boolean; +} + +/** +* Interface defining a typed vector constructor which is both "newable" and "callable". +*/ +interface Int8Vector { + /** + * Creates a signed 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int8Vector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + new ( options?: Options ): int8ndarray; + + /** + * Creates a signed 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int8Vector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( length: number, options?: Options ): int8ndarray; + + /** + * Creates a signed 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int8Vector( [ 1, 2 ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): int8ndarray; + + /** + * Creates a signed 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Int8Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 32 + */ + new ( buffer: ArrayBuffer, options?: Options ): int8ndarray; + + /** + * Creates a signed 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new Int8Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 24 + */ + new ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): int8ndarray; + + /** + * Creates a signed 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new Int8Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): int8ndarray; + + /** + * Creates a signed 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int8Vector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + ( options?: Options ): int8ndarray; + + /** + * Creates a signed 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int8Vector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( length: number, options?: Options ): int8ndarray; + + /** + * Creates a signed 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Int8Vector( [ 1, 2 ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): int8ndarray; + + /** + * Creates a signed 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Int8Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 32 + */ + ( buffer: ArrayBuffer, options?: Options ): int8ndarray; + + /** + * Creates a signed 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new Int8Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 24 + */ + ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): int8ndarray; + + /** + * Creates a signed 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new Int8Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): int8ndarray; +} + +/** +* Creates a signed 8-bit integer vector (i.e., a one-dimensional ndarray). +* +* @param arg - length, typed array, array-like object, buffer, or iterable +* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) +* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer +* @param options - function options +* @param options.readonly - boolean indicating whether to return a read-only vector +* @param options.mode - specifies how to handle indices which exceed vector dimensions +* @param options.order - memory layout (either row-major or column-major) +* @returns one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int8Vector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int8Vector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int8Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Int8Vector( buf, 8, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +declare var ctor: Int8Vector; + + +// EXPORTS // + +export = ctor; diff --git a/lib/node_modules/@stdlib/ndarray/vector/int8/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/vector/int8/docs/types/test.ts new file mode 100644 index 000000000000..667a6d9ed770 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int8/docs/types/test.ts @@ -0,0 +1,86 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import ArrayBuffer = require( '@stdlib/array/buffer' ); +import Int8Vector = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + new Int8Vector(); // $ExpectType int8ndarray + new Int8Vector( {} ); // $ExpectType int8ndarray + + new Int8Vector( 10 ); // $ExpectType int8ndarray + new Int8Vector( 10, {} ); // $ExpectType int8ndarray + + new Int8Vector( [ 1, 2, 3 ] ); // $ExpectType int8ndarray + new Int8Vector( [ 1, 2, 3 ], {} ); // $ExpectType int8ndarray + + new Int8Vector( new ArrayBuffer( 10 ) ); // $ExpectType int8ndarray + new Int8Vector( new ArrayBuffer( 10 ), {} ); // $ExpectType int8ndarray + + new Int8Vector( new ArrayBuffer( 10 ), 8 ); // $ExpectType int8ndarray + new Int8Vector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType int8ndarray + + new Int8Vector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType int8ndarray + new Int8Vector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType int8ndarray + + const vector = Int8Vector; + vector(); // $ExpectType int8ndarray + vector( {} ); // $ExpectType int8ndarray + + vector( 10 ); // $ExpectType int8ndarray + vector( 10, {} ); // $ExpectType int8ndarray + + vector( [ 1, 2, 3 ] ); // $ExpectType int8ndarray + vector( [ 1, 2, 3 ], {} ); // $ExpectType int8ndarray + + vector( new ArrayBuffer( 10 ) ); // $ExpectType int8ndarray + vector( new ArrayBuffer( 10 ), {} ); // $ExpectType int8ndarray + + vector( new ArrayBuffer( 10 ), 8 ); // $ExpectType int8ndarray + vector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType int8ndarray + + vector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType int8ndarray + vector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType int8ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not a number, array-like object, iterable, or options object... +{ + new Int8Vector( true ); // $ExpectError + new Int8Vector( false ); // $ExpectError + new Int8Vector( null ); // $ExpectError + new Int8Vector( ( x: number ): number => x ); // $ExpectError + + const vector = Int8Vector; + vector( true ); // $ExpectError + vector( false ); // $ExpectError + vector( null ); // $ExpectError + vector( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const buf = new ArrayBuffer( 32 ); + new Int8Vector( buf, 8, 2, {}, {} ); // $ExpectError + + const vector = Int8Vector; + vector( buf, 8, 2, {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/int8/examples/index.js b/lib/node_modules/@stdlib/ndarray/vector/int8/examples/index.js new file mode 100644 index 000000000000..f741e9bf4930 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int8/examples/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sum = require( '@stdlib/blas/ext/sum' ); +var map = require( '@stdlib/ndarray/map' ); +var Int8Vector = require( './../lib' ); + +// Create a vector containing random values: +var x = new Int8Vector( discreteUniform( 10, 0, 100 ) ); + +// Compute the sum: +var v = sum( x ); +console.log( v.get() ); + +// Define a function which applies a threshold to individual values: +function threshold( v ) { + return ( v > 10 ) ? v : 0; +} + +// Apply threshold: +var y = map( x, threshold ); + +// Recompute the sum: +v = sum( y ); +console.log( v.get() ); diff --git a/lib/node_modules/@stdlib/ndarray/vector/int8/lib/index.js b/lib/node_modules/@stdlib/ndarray/vector/int8/lib/index.js new file mode 100644 index 000000000000..3abc5b23d5da --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int8/lib/index.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Create a signed 8-bit integer vector (i.e., a one-dimensional ndarray). +* +* @module @stdlib/ndarray/vector/int8 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int8Vector = require( '@stdlib/ndarray/vector/int8' ); +* +* var v = new Int8Vector(); +* // returns +* +* var len = numel( v ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int8Vector = require( '@stdlib/ndarray/vector/int8' ); +* +* var v = new Int8Vector( 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int8Vector = require( '@stdlib/ndarray/vector/int8' ); +* +* var v = new Int8Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int8Vector = require( '@stdlib/ndarray/vector/int8' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new Int8Vector( buf ); +* // returns +* +* var len = numel( v ); +* // returns 32 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int8Vector = require( '@stdlib/ndarray/vector/int8' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new Int8Vector( buf, 16 ); +* // returns +* +* var len = numel( v ); +* // returns 16 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Int8Vector = require( '@stdlib/ndarray/vector/int8' ); +* +* var buf = new ArrayBuffer( 64 ); +* var v = new Int8Vector( buf, 16, 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/vector/int8/lib/main.js b/lib/node_modules/@stdlib/ndarray/vector/int8/lib/main.js new file mode 100644 index 000000000000..bffe3eb92359 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int8/lib/main.js @@ -0,0 +1,109 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 factory = require( '@stdlib/ndarray/vector/ctor' ).factory; + + +// MAIN // + +/** +* Returns a signed 8-bit integer vector (i.e., a one-dimensional ndarray). +* +* @name Int8Vector +* @type {Function} +* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable +* @param {NonNegativeInteger} [byteOffset=0] - byte offset +* @param {NonNegativeInteger} [length] - view length +* @param {Options} [options] - function options +* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only vector +* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed vector dimensions +* @param {string} [options.order='row-major'] - memory layout (either row-major or column-major) +* @throws {TypeError} first argument must be either a length, typed array, array-like object, buffer, iterable, or options object +* @throws {TypeError} must provide valid options +* @returns {ndarray} one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int8Vector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int8Vector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Int8Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Int8Vector( buf ); +* // returns +* +* var len = numel( arr ); +* // returns 32 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Int8Vector( buf, 16 ); +* // returns +* +* var len = numel( arr ); +* // returns 16 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 64 ); +* var arr = new Int8Vector( buf, 16, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +var Int8Vector = factory( 'int8' ); + + +// EXPORTS // + +module.exports = Int8Vector; diff --git a/lib/node_modules/@stdlib/ndarray/vector/int8/package.json b/lib/node_modules/@stdlib/ndarray/vector/int8/package.json new file mode 100644 index 000000000000..5683e19fe05c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int8/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/ndarray/vector/int8", + "version": "0.0.0", + "description": "Create a signed 8-bit integer vector (i.e., a one-dimensional ndarray).", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdtypes", + "types", + "data", + "structure", + "vector", + "vec", + "ndarray", + "constructor", + "ctor", + "int8" + ] +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/int8/test/test.js b/lib/node_modules/@stdlib/ndarray/vector/int8/test/test.js new file mode 100644 index 000000000000..d87727ce29ad --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/int8/test/test.js @@ -0,0 +1,1022 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* eslint-disable no-new */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isndarrayLikeWithDataType = require( '@stdlib/assert/is-ndarray-like-with-data-type' ); +var isEqualInt8Array = require( '@stdlib/assert/is-equal-int8array' ); +var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' ); +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Int8Array = require( '@stdlib/array/int8' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var array2buffer = require( '@stdlib/buffer/from-array' ); +var Int8Vector = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Int8Vector, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int8Vector( value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int8Vector( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int8Vector( value, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int8Vector( value, 0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int8Vector( value, 0, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int8Vector( value, 0, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int8Vector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int8Vector( new ArrayBuffer( 8 ), value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int8Vector( new ArrayBuffer( 8 ), value, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int8Vector( new ArrayBuffer( 8 ), value, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int8Vector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Int8Vector( new ArrayBuffer( 8 ), 0, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (length)', function test( t ) { + var values; + var i; + + 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() { + new Int8Vector( 10, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { + var values; + var i; + + 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() { + new Int8Vector( [], value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new Int8Vector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new Int8Vector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset, length)', function test( t ) { + var values; + var i; + + 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() { + new Int8Vector( new ArrayBuffer( 8 ), 0, 1, value ); + }; + } +}); + +tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'ROW', + 'row', + 'col-major', + 'col', + 'major', + 'minor', + null + ]; + + 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() { + new Int8Vector({ + 'order': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'THROW', + 5, + null, + true, + false, + [], + {} + ]; + + 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() { + new Int8Vector({ + 'mode': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + 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() { + new Int8Vector({ + 'readonly': value + }); + }; + } +}); + +tape( 'the function returns a one-dimensional ndarray', function test( t ) { + var arr; + + arr = new Int8Vector(); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + arr = new Int8Vector( {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (length)', function test( t ) { + var arr; + + arr = new Int8Vector( 10 ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + arr = new Int8Vector( 10, {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (array)', function test( t ) { + var arr; + var out; + + arr = [ 1, 2, 3, 4 ]; + + out = new Int8Vector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt8Array( getData( out ), new Int8Array( arr ) ), true, 'returns expected value' ); + + out = new Int8Vector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt8Array( getData( out ), new Int8Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (typed array)', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + out = new Int8Vector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt8Array( getData( out ), new Int8Array( arr ) ), true, 'returns expected value' ); + + out = new Int8Vector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt8Array( getData( out ), new Int8Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (buffer)', function test( t ) { + var arr; + var out; + var buf; + + arr = [ 1, 2, 3, 4 ]; + buf = array2buffer( arr ); + + out = new Int8Vector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt8Array( getData( out ), new Int8Array( arr ) ), true, 'returns expected value' ); + + out = new Int8Vector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualInt8Array( getData( out ), new Int8Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 8 ); + + out = new Int8Vector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 8, 'returns expected value' ); + t.strictEqual( isEqualInt8Array( getData( out ), new Int8Array( buf ) ), true, 'returns expected value' ); + + out = new Int8Vector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 8, 'returns expected value' ); + t.strictEqual( isEqualInt8Array( getData( out ), new Int8Array( buf ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new Int8Vector( buf, 8 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 24, 'returns expected value' ); + t.strictEqual( isEqualInt8Array( getData( out ), new Int8Array( buf, 8 ) ), true, 'returns expected value' ); + + out = new Int8Vector( buf, 8, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 24, 'returns expected value' ); + t.strictEqual( isEqualInt8Array( getData( out ), new Int8Array( buf, 8 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset, length)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new Int8Vector( buf, 8, 2 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualInt8Array( getData( out ), new Int8Array( buf, 8, 2 ) ), true, 'returns expected value' ); + + out = new Int8Vector( buf, 8, 2, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'int8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualInt8Array( getData( out ), new Int8Array( buf, 8, 2 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout', function test( t ) { + var arr; + + arr = new Int8Vector({ + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int8Vector({ + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (length)', function test( t ) { + var arr; + + arr = new Int8Vector( 10, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int8Vector( 10, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (array)', function test( t ) { + var arr; + + arr = new Int8Vector( [ 1, 2, 3, 4 ], { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int8Vector( [ 1, 2, 3, 4 ], { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer)', function test( t ) { + var arr; + + arr = new Int8Vector( new ArrayBuffer( 32 ), { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int8Vector( new ArrayBuffer( 32 ), { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Int8Vector( new ArrayBuffer( 32 ), 8, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int8Vector( new ArrayBuffer( 32 ), 8, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Int8Vector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Int8Vector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays', function test( t ) { + var arr; + + arr = new Int8Vector({ + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (length)', function test( t ) { + var arr; + + arr = new Int8Vector( 10, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (array)', function test( t ) { + var arr; + + arr = new Int8Vector( [ 1, 2, 3, 4 ], { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new Int8Vector( new ArrayBuffer( 32 ), { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Int8Vector( new ArrayBuffer( 32 ), 8, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Int8Vector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays', function test( t ) { + var arr; + + arr = new Int8Vector({ + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (length)', function test( t ) { + var arr; + + arr = new Int8Vector( 10, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (array)', function test( t ) { + var arr; + + arr = new Int8Vector( [ 1, 2, 3, 4 ], { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new Int8Vector( new ArrayBuffer( 32 ), { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Int8Vector( new ArrayBuffer( 32 ), 8, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Int8Vector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'int8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); From b7c276b5d4e32dd0409afb946319d4581b8f6ff1 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 01:12:20 -0700 Subject: [PATCH 43/60] feat: add `ndarray/vector/uint32` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/ndarray/vector/uint32/README.md | 196 ++++ .../vector/uint32/benchmark/benchmark.js | 47 + .../vector/uint32/benchmark/benchmark.size.js | 93 ++ .../ndarray/vector/uint32/docs/repl.txt | 175 +++ .../vector/uint32/docs/types/index.d.ts | 377 ++++++ .../ndarray/vector/uint32/docs/types/test.ts | 86 ++ .../ndarray/vector/uint32/examples/index.js | 43 + .../ndarray/vector/uint32/lib/index.js | 100 ++ .../@stdlib/ndarray/vector/uint32/lib/main.js | 109 ++ .../ndarray/vector/uint32/package.json | 64 ++ .../ndarray/vector/uint32/test/test.js | 1022 +++++++++++++++++ 11 files changed, 2312 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint32/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint32/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint32/benchmark/benchmark.size.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint32/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint32/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint32/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint32/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint32/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint32/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint32/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint32/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint32/README.md b/lib/node_modules/@stdlib/ndarray/vector/uint32/README.md new file mode 100644 index 000000000000..9702ddc6f3ae --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint32/README.md @@ -0,0 +1,196 @@ + + +# Uint32Vector + +> Create an unsigned 32-bit integer vector (i.e., a one-dimensional [ndarray][@stdlib/ndarray/ctor]). + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var Uint32Vector = require( '@stdlib/ndarray/vector/uint32' ); +``` + +#### Uint32Vector( \[options] ) + +Returns a one-dimensional unsigned 32-bit integer [ndarray][@stdlib/ndarray/ctor]. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Uint32Vector(); +// returns + +var len = numel( arr ); +// returns 0 +``` + +The function accepts the following options: + +- **order**: specifies whether an [ndarray][@stdlib/ndarray/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). Default: `'row-major'`. +- **mode**: specifies how to handle indices which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). Default: `'throw'`. +- **readonly**: boolean indicating whether an array should be **read-only**. Default: `false`. + +#### Uint32Vector( length\[, options] ) + +Returns a one-dimensional unsigned 32-bit integer [ndarray][@stdlib/ndarray/ctor] having a specified `length`. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Uint32Vector( 5 ); +// returns + +var len1 = numel( arr ); +// returns 5 +``` + +#### Uint32Vector( obj\[, options] ) + +Creates a one-dimensional unsigned 32-bit integer [ndarray][@stdlib/ndarray/ctor] from an array-like object or iterable. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Uint32Vector( [ 1, 2, 3 ] ); +// returns + +var len1 = numel( arr ); +// returns 3 +``` + +#### Uint32Vector( buffer\[, byteOffset\[, length]]\[, options] ) + +Returns a one-dimensional unsigned 32-bit integer [ndarray][@stdlib/ndarray/ctor] view of an [`ArrayBuffer`][@stdlib/array/buffer]. + +```javascript +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var numel = require( '@stdlib/ndarray/numel' ); + +var buf = new ArrayBuffer( 32 ); + +var arr1 = new Uint32Vector( buf ); +// returns + +var len1 = numel( arr1 ); +// returns 8 + +var arr2 = new Uint32Vector( buf, 16 ); +// returns + +var len2 = numel( arr2 ); +// returns 4 + +var arr3 = new Uint32Vector( buf, 16, 1 ); +// returns + +var len3 = numel( arr3 ); +// returns 1 +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sum = require( '@stdlib/blas/ext/sum' ); +var map = require( '@stdlib/ndarray/map' ); +var Uint32Vector = require( '@stdlib/ndarray/vector/uint32' ); + +// Create a vector containing random values: +var x = new Uint32Vector( discreteUniform( 10, 0, 100 ) ); + +// Compute the sum: +var v = sum( x ); +console.log( v.get() ); + +// Define a function which applies a threshold to individual values: +function threshold( v ) { + return ( v > 10 ) ? v : 0; +} + +// Apply threshold: +var y = map( x, threshold ); + +// Recompute the sum: +v = sum( y ); +console.log( v.get() ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint32/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/vector/uint32/benchmark/benchmark.js new file mode 100644 index 000000000000..2446df2de392 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint32/benchmark/benchmark.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var Uint32Vector = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Uint32Vector( 0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint32/benchmark/benchmark.size.js b/lib/node_modules/@stdlib/ndarray/vector/uint32/benchmark/benchmark.size.js new file mode 100644 index 000000000000..3c387d5e2b56 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint32/benchmark/benchmark.size.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var Uint32Vector = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Uint32Vector( len ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + 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( pkg+':size='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint32/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/vector/uint32/docs/repl.txt new file mode 100644 index 000000000000..e9fd505be4cb --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint32/docs/repl.txt @@ -0,0 +1,175 @@ + +{{alias}}( [options] ) + Returns a one-dimensional unsigned 32-bit integer ndarray. + + Parameters + ---------- + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}() + + + +{{alias}}( length[, options] ) + Returns a one-dimensional unsigned 32-bit integer ndarray having a specified + length. + + Parameters + ---------- + length: integer + Number of elements. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}( 5 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 5 + + +{{alias}}( obj[, options] ) + Creates a one-dimensional unsigned 32-bit integer ndarray from an array-like + object or iterable. + + Parameters + ---------- + obj: Object + Array-like object or iterable from which to generate an ndarray. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var v = [ 1, 2, 3 ]; + > var arr = {{alias}}( v ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 3 + + +{{alias}}( buffer[, byteOffset[, length]][, options] ) + Returns a one-dimensional unsigned 32-bit integer ndarray view of an + ArrayBuffer. + + Parameters + ---------- + buffer: ArrayBuffer + Underlying ArrayBuffer. + + byteOffset: integer (optional) + Integer byte offset specifying the location of the first indexed + element. Default: 0. + + length: integer (optional) + View length. If not provided, the view spans from the byteOffset to + the end of the underlying ArrayBuffer. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var buf = new {{alias:@stdlib/array/buffer}}( 32 ); + > var arr = {{alias}}( buf, 0, 4 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 4 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint32/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/vector/uint32/docs/types/index.d.ts new file mode 100644 index 000000000000..711068c3e51a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint32/docs/types/index.d.ts @@ -0,0 +1,377 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/* eslint-disable @typescript-eslint/unified-signatures */ + +/// + +import { Order, Mode, uint32ndarray } from '@stdlib/types/ndarray'; +import { Collection, AccessorArrayLike } from '@stdlib/types/array'; +import ArrayBuffer = require( '@stdlib/array/buffer' ); + +/** +* Interface describing function options. +*/ +interface Options { + /** + * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). + */ + order?: Order; + + /** + * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). + */ + mode?: Mode; + + /** + * Boolean indicating whether an array should be read-only (default: false). + */ + readonly?: boolean; +} + +/** +* Interface defining a typed vector constructor which is both "newable" and "callable". +*/ +interface Uint32Vector { + /** + * Creates an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint32Vector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + new ( options?: Options ): uint32ndarray; + + /** + * Creates an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint32Vector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( length: number, options?: Options ): uint32ndarray; + + /** + * Creates an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint32Vector( [ 1, 2 ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): uint32ndarray; + + /** + * Creates an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Uint32Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 8 + */ + new ( buffer: ArrayBuffer, options?: Options ): uint32ndarray; + + /** + * Creates an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new Uint32Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 6 + */ + new ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): uint32ndarray; + + /** + * Creates an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new Uint32Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): uint32ndarray; + + /** + * Creates an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint32Vector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + ( options?: Options ): uint32ndarray; + + /** + * Creates an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint32Vector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( length: number, options?: Options ): uint32ndarray; + + /** + * Creates an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint32Vector( [ 1, 2 ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): uint32ndarray; + + /** + * Creates an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Uint32Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 8 + */ + ( buffer: ArrayBuffer, options?: Options ): uint32ndarray; + + /** + * Creates an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new Uint32Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 6 + */ + ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): uint32ndarray; + + /** + * Creates an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new Uint32Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): uint32ndarray; +} + +/** +* Creates an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray). +* +* @param arg - length, typed array, array-like object, buffer, or iterable +* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) +* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer +* @param options - function options +* @param options.readonly - boolean indicating whether to return a read-only vector +* @param options.mode - specifies how to handle indices which exceed vector dimensions +* @param options.order - memory layout (either row-major or column-major) +* @returns one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint32Vector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint32Vector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint32Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Uint32Vector( buf, 8, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +declare var ctor: Uint32Vector; + + +// EXPORTS // + +export = ctor; diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint32/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/vector/uint32/docs/types/test.ts new file mode 100644 index 000000000000..a7175addd878 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint32/docs/types/test.ts @@ -0,0 +1,86 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import ArrayBuffer = require( '@stdlib/array/buffer' ); +import Uint32Vector = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + new Uint32Vector(); // $ExpectType uint32ndarray + new Uint32Vector( {} ); // $ExpectType uint32ndarray + + new Uint32Vector( 10 ); // $ExpectType uint32ndarray + new Uint32Vector( 10, {} ); // $ExpectType uint32ndarray + + new Uint32Vector( [ 1, 2, 3 ] ); // $ExpectType uint32ndarray + new Uint32Vector( [ 1, 2, 3 ], {} ); // $ExpectType uint32ndarray + + new Uint32Vector( new ArrayBuffer( 10 ) ); // $ExpectType uint32ndarray + new Uint32Vector( new ArrayBuffer( 10 ), {} ); // $ExpectType uint32ndarray + + new Uint32Vector( new ArrayBuffer( 10 ), 8 ); // $ExpectType uint32ndarray + new Uint32Vector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType uint32ndarray + + new Uint32Vector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType uint32ndarray + new Uint32Vector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType uint32ndarray + + const vector = Uint32Vector; + vector(); // $ExpectType uint32ndarray + vector( {} ); // $ExpectType uint32ndarray + + vector( 10 ); // $ExpectType uint32ndarray + vector( 10, {} ); // $ExpectType uint32ndarray + + vector( [ 1, 2, 3 ] ); // $ExpectType uint32ndarray + vector( [ 1, 2, 3 ], {} ); // $ExpectType uint32ndarray + + vector( new ArrayBuffer( 10 ) ); // $ExpectType uint32ndarray + vector( new ArrayBuffer( 10 ), {} ); // $ExpectType uint32ndarray + + vector( new ArrayBuffer( 10 ), 8 ); // $ExpectType uint32ndarray + vector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType uint32ndarray + + vector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType uint32ndarray + vector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType uint32ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not a number, array-like object, iterable, or options object... +{ + new Uint32Vector( true ); // $ExpectError + new Uint32Vector( false ); // $ExpectError + new Uint32Vector( null ); // $ExpectError + new Uint32Vector( ( x: number ): number => x ); // $ExpectError + + const vector = Uint32Vector; + vector( true ); // $ExpectError + vector( false ); // $ExpectError + vector( null ); // $ExpectError + vector( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const buf = new ArrayBuffer( 32 ); + new Uint32Vector( buf, 8, 2, {}, {} ); // $ExpectError + + const vector = Uint32Vector; + vector( buf, 8, 2, {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint32/examples/index.js b/lib/node_modules/@stdlib/ndarray/vector/uint32/examples/index.js new file mode 100644 index 000000000000..6f46858dc019 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint32/examples/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sum = require( '@stdlib/blas/ext/sum' ); +var map = require( '@stdlib/ndarray/map' ); +var Uint32Vector = require( './../lib' ); + +// Create a vector containing random values: +var x = new Uint32Vector( discreteUniform( 10, 0, 100 ) ); + +// Compute the sum: +var v = sum( x ); +console.log( v.get() ); + +// Define a function which applies a threshold to individual values: +function threshold( v ) { + return ( v > 10 ) ? v : 0; +} + +// Apply threshold: +var y = map( x, threshold ); + +// Recompute the sum: +v = sum( y ); +console.log( v.get() ); diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint32/lib/index.js b/lib/node_modules/@stdlib/ndarray/vector/uint32/lib/index.js new file mode 100644 index 000000000000..724968a0615d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint32/lib/index.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Create an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray). +* +* @module @stdlib/ndarray/vector/uint32 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint32Vector = require( '@stdlib/ndarray/vector/uint32' ); +* +* var v = new Uint32Vector(); +* // returns +* +* var len = numel( v ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint32Vector = require( '@stdlib/ndarray/vector/uint32' ); +* +* var v = new Uint32Vector( 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint32Vector = require( '@stdlib/ndarray/vector/uint32' ); +* +* var v = new Uint32Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint32Vector = require( '@stdlib/ndarray/vector/uint32' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new Uint32Vector( buf ); +* // returns +* +* var len = numel( v ); +* // returns 8 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint32Vector = require( '@stdlib/ndarray/vector/uint32' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new Uint32Vector( buf, 16 ); +* // returns +* +* var len = numel( v ); +* // returns 4 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint32Vector = require( '@stdlib/ndarray/vector/uint32' ); +* +* var buf = new ArrayBuffer( 64 ); +* var v = new Uint32Vector( buf, 16, 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint32/lib/main.js b/lib/node_modules/@stdlib/ndarray/vector/uint32/lib/main.js new file mode 100644 index 000000000000..84f0a64d896a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint32/lib/main.js @@ -0,0 +1,109 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 factory = require( '@stdlib/ndarray/vector/ctor' ).factory; + + +// MAIN // + +/** +* Returns an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray). +* +* @name Uint32Vector +* @type {Function} +* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable +* @param {NonNegativeInteger} [byteOffset=0] - byte offset +* @param {NonNegativeInteger} [length] - view length +* @param {Options} [options] - function options +* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only vector +* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed vector dimensions +* @param {string} [options.order='row-major'] - memory layout (either row-major or column-major) +* @throws {TypeError} first argument must be either a length, typed array, array-like object, buffer, iterable, or options object +* @throws {TypeError} must provide valid options +* @returns {ndarray} one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint32Vector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint32Vector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint32Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Uint32Vector( buf ); +* // returns +* +* var len = numel( arr ); +* // returns 8 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Uint32Vector( buf, 16 ); +* // returns +* +* var len = numel( arr ); +* // returns 4 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 64 ); +* var arr = new Uint32Vector( buf, 16, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +var Uint32Vector = factory( 'uint32' ); + + +// EXPORTS // + +module.exports = Uint32Vector; diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint32/package.json b/lib/node_modules/@stdlib/ndarray/vector/uint32/package.json new file mode 100644 index 000000000000..2f86eb88f9e5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint32/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/ndarray/vector/uint32", + "version": "0.0.0", + "description": "Create an unsigned 32-bit integer vector (i.e., a one-dimensional ndarray).", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdtypes", + "types", + "data", + "structure", + "vector", + "vec", + "ndarray", + "constructor", + "ctor", + "uint32" + ] +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint32/test/test.js b/lib/node_modules/@stdlib/ndarray/vector/uint32/test/test.js new file mode 100644 index 000000000000..ce7c8b968ffa --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint32/test/test.js @@ -0,0 +1,1022 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* eslint-disable no-new */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isndarrayLikeWithDataType = require( '@stdlib/assert/is-ndarray-like-with-data-type' ); +var isEqualUint32Array = require( '@stdlib/assert/is-equal-uint32array' ); +var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' ); +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint32Array = require( '@stdlib/array/uint32' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var array2buffer = require( '@stdlib/buffer/from-array' ); +var Uint32Vector = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint32Vector, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint32Vector( value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint32Vector( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint32Vector( value, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint32Vector( value, 0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint32Vector( value, 0, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint32Vector( value, 0, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint32Vector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint32Vector( new ArrayBuffer( 8 ), value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint32Vector( new ArrayBuffer( 8 ), value, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint32Vector( new ArrayBuffer( 8 ), value, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint32Vector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint32Vector( new ArrayBuffer( 8 ), 0, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (length)', function test( t ) { + var values; + var i; + + 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() { + new Uint32Vector( 10, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { + var values; + var i; + + 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() { + new Uint32Vector( [], value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new Uint32Vector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new Uint32Vector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset, length)', function test( t ) { + var values; + var i; + + 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() { + new Uint32Vector( new ArrayBuffer( 8 ), 0, 1, value ); + }; + } +}); + +tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'ROW', + 'row', + 'col-major', + 'col', + 'major', + 'minor', + null + ]; + + 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() { + new Uint32Vector({ + 'order': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'THROW', + 5, + null, + true, + false, + [], + {} + ]; + + 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() { + new Uint32Vector({ + 'mode': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + 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() { + new Uint32Vector({ + 'readonly': value + }); + }; + } +}); + +tape( 'the function returns a one-dimensional ndarray', function test( t ) { + var arr; + + arr = new Uint32Vector(); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + arr = new Uint32Vector( {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (length)', function test( t ) { + var arr; + + arr = new Uint32Vector( 10 ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + arr = new Uint32Vector( 10, {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (array)', function test( t ) { + var arr; + var out; + + arr = [ 1, 2, 3, 4 ]; + + out = new Uint32Vector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint32Array( getData( out ), new Uint32Array( arr ) ), true, 'returns expected value' ); + + out = new Uint32Vector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint32Array( getData( out ), new Uint32Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (typed array)', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + out = new Uint32Vector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint32Array( getData( out ), new Uint32Array( arr ) ), true, 'returns expected value' ); + + out = new Uint32Vector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint32Array( getData( out ), new Uint32Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (buffer)', function test( t ) { + var arr; + var out; + var buf; + + arr = [ 1, 2, 3, 4 ]; + buf = array2buffer( arr ); + + out = new Uint32Vector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint32Array( getData( out ), new Uint32Array( arr ) ), true, 'returns expected value' ); + + out = new Uint32Vector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint32Array( getData( out ), new Uint32Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 8 ); + + out = new Uint32Vector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualUint32Array( getData( out ), new Uint32Array( buf ) ), true, 'returns expected value' ); + + out = new Uint32Vector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualUint32Array( getData( out ), new Uint32Array( buf ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new Uint32Vector( buf, 8 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 6, 'returns expected value' ); + t.strictEqual( isEqualUint32Array( getData( out ), new Uint32Array( buf, 8 ) ), true, 'returns expected value' ); + + out = new Uint32Vector( buf, 8, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 6, 'returns expected value' ); + t.strictEqual( isEqualUint32Array( getData( out ), new Uint32Array( buf, 8 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset, length)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new Uint32Vector( buf, 8, 2 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualUint32Array( getData( out ), new Uint32Array( buf, 8, 2 ) ), true, 'returns expected value' ); + + out = new Uint32Vector( buf, 8, 2, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualUint32Array( getData( out ), new Uint32Array( buf, 8, 2 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout', function test( t ) { + var arr; + + arr = new Uint32Vector({ + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint32Vector({ + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (length)', function test( t ) { + var arr; + + arr = new Uint32Vector( 10, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint32Vector( 10, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (array)', function test( t ) { + var arr; + + arr = new Uint32Vector( [ 1, 2, 3, 4 ], { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint32Vector( [ 1, 2, 3, 4 ], { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer)', function test( t ) { + var arr; + + arr = new Uint32Vector( new ArrayBuffer( 32 ), { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 8, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint32Vector( new ArrayBuffer( 32 ), { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 8, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Uint32Vector( new ArrayBuffer( 32 ), 8, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 6, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint32Vector( new ArrayBuffer( 32 ), 8, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 6, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Uint32Vector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint32Vector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays', function test( t ) { + var arr; + + arr = new Uint32Vector({ + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (length)', function test( t ) { + var arr; + + arr = new Uint32Vector( 10, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (array)', function test( t ) { + var arr; + + arr = new Uint32Vector( [ 1, 2, 3, 4 ], { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new Uint32Vector( new ArrayBuffer( 32 ), { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 8, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Uint32Vector( new ArrayBuffer( 32 ), 8, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 6, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Uint32Vector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays', function test( t ) { + var arr; + + arr = new Uint32Vector({ + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (length)', function test( t ) { + var arr; + + arr = new Uint32Vector( 10, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (array)', function test( t ) { + var arr; + + arr = new Uint32Vector( [ 1, 2, 3, 4 ], { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new Uint32Vector( new ArrayBuffer( 32 ), { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 8, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Uint32Vector( new ArrayBuffer( 32 ), 8, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 6, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Uint32Vector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint32' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); From f9923b3b975f3fe14767d24dbd696bc704da762c Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 01:15:42 -0700 Subject: [PATCH 44/60] feat: add `ndarray/vector/uint16` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/ndarray/vector/uint16/README.md | 196 ++++ .../vector/uint16/benchmark/benchmark.js | 47 + .../vector/uint16/benchmark/benchmark.size.js | 93 ++ .../ndarray/vector/uint16/docs/repl.txt | 175 +++ .../vector/uint16/docs/types/index.d.ts | 377 ++++++ .../ndarray/vector/uint16/docs/types/test.ts | 86 ++ .../ndarray/vector/uint16/examples/index.js | 43 + .../ndarray/vector/uint16/lib/index.js | 100 ++ .../@stdlib/ndarray/vector/uint16/lib/main.js | 109 ++ .../ndarray/vector/uint16/package.json | 64 ++ .../ndarray/vector/uint16/test/test.js | 1022 +++++++++++++++++ 11 files changed, 2312 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint16/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint16/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint16/benchmark/benchmark.size.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint16/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint16/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint16/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint16/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint16/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint16/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint16/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint16/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint16/README.md b/lib/node_modules/@stdlib/ndarray/vector/uint16/README.md new file mode 100644 index 000000000000..3fd2df7eb553 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint16/README.md @@ -0,0 +1,196 @@ + + +# Uint16Vector + +> Create an unsigned 16-bit integer vector (i.e., a one-dimensional [ndarray][@stdlib/ndarray/ctor]). + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var Uint16Vector = require( '@stdlib/ndarray/vector/uint16' ); +``` + +#### Uint16Vector( \[options] ) + +Returns a one-dimensional unsigned 16-bit integer [ndarray][@stdlib/ndarray/ctor]. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Uint16Vector(); +// returns + +var len = numel( arr ); +// returns 0 +``` + +The function accepts the following options: + +- **order**: specifies whether an [ndarray][@stdlib/ndarray/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). Default: `'row-major'`. +- **mode**: specifies how to handle indices which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). Default: `'throw'`. +- **readonly**: boolean indicating whether an array should be **read-only**. Default: `false`. + +#### Uint16Vector( length\[, options] ) + +Returns a one-dimensional unsigned 16-bit integer [ndarray][@stdlib/ndarray/ctor] having a specified `length`. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Uint16Vector( 5 ); +// returns + +var len1 = numel( arr ); +// returns 5 +``` + +#### Uint16Vector( obj\[, options] ) + +Creates a one-dimensional unsigned 16-bit integer [ndarray][@stdlib/ndarray/ctor] from an array-like object or iterable. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Uint16Vector( [ 1, 2, 3 ] ); +// returns + +var len1 = numel( arr ); +// returns 3 +``` + +#### Uint16Vector( buffer\[, byteOffset\[, length]]\[, options] ) + +Returns a one-dimensional unsigned 16-bit integer [ndarray][@stdlib/ndarray/ctor] view of an [`ArrayBuffer`][@stdlib/array/buffer]. + +```javascript +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var numel = require( '@stdlib/ndarray/numel' ); + +var buf = new ArrayBuffer( 32 ); + +var arr1 = new Uint16Vector( buf ); +// returns + +var len1 = numel( arr1 ); +// returns 16 + +var arr2 = new Uint16Vector( buf, 16 ); +// returns + +var len2 = numel( arr2 ); +// returns 8 + +var arr3 = new Uint16Vector( buf, 16, 1 ); +// returns + +var len3 = numel( arr3 ); +// returns 1 +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sum = require( '@stdlib/blas/ext/sum' ); +var map = require( '@stdlib/ndarray/map' ); +var Uint16Vector = require( '@stdlib/ndarray/vector/uint16' ); + +// Create a vector containing random values: +var x = new Uint16Vector( discreteUniform( 10, 0, 100 ) ); + +// Compute the sum: +var v = sum( x ); +console.log( v.get() ); + +// Define a function which applies a threshold to individual values: +function threshold( v ) { + return ( v > 10 ) ? v : 0; +} + +// Apply threshold: +var y = map( x, threshold ); + +// Recompute the sum: +v = sum( y ); +console.log( v.get() ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint16/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/vector/uint16/benchmark/benchmark.js new file mode 100644 index 000000000000..91d7fdcb821a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint16/benchmark/benchmark.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var Uint16Vector = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Uint16Vector( 0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint16/benchmark/benchmark.size.js b/lib/node_modules/@stdlib/ndarray/vector/uint16/benchmark/benchmark.size.js new file mode 100644 index 000000000000..0b0e3959beed --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint16/benchmark/benchmark.size.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var Uint16Vector = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Uint16Vector( len ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + 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( pkg+':size='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint16/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/vector/uint16/docs/repl.txt new file mode 100644 index 000000000000..5f230350d154 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint16/docs/repl.txt @@ -0,0 +1,175 @@ + +{{alias}}( [options] ) + Returns a one-dimensional unsigned 16-bit integer ndarray. + + Parameters + ---------- + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}() + + + +{{alias}}( length[, options] ) + Returns a one-dimensional unsigned 16-bit integer ndarray having a specified + length. + + Parameters + ---------- + length: integer + Number of elements. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}( 5 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 5 + + +{{alias}}( obj[, options] ) + Creates a one-dimensional unsigned 16-bit integer ndarray from an array-like + object or iterable. + + Parameters + ---------- + obj: Object + Array-like object or iterable from which to generate an ndarray. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var v = [ 1, 2, 3 ]; + > var arr = {{alias}}( v ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 3 + + +{{alias}}( buffer[, byteOffset[, length]][, options] ) + Returns a one-dimensional unsigned 16-bit integer ndarray view of an + ArrayBuffer. + + Parameters + ---------- + buffer: ArrayBuffer + Underlying ArrayBuffer. + + byteOffset: integer (optional) + Integer byte offset specifying the location of the first indexed + element. Default: 0. + + length: integer (optional) + View length. If not provided, the view spans from the byteOffset to + the end of the underlying ArrayBuffer. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var buf = new {{alias:@stdlib/array/buffer}}( 32 ); + > var arr = {{alias}}( buf, 0, 4 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 4 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint16/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/vector/uint16/docs/types/index.d.ts new file mode 100644 index 000000000000..e333b7e17ab4 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint16/docs/types/index.d.ts @@ -0,0 +1,377 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/* eslint-disable @typescript-eslint/unified-signatures */ + +/// + +import { Order, Mode, uint16ndarray } from '@stdlib/types/ndarray'; +import { Collection, AccessorArrayLike } from '@stdlib/types/array'; +import ArrayBuffer = require( '@stdlib/array/buffer' ); + +/** +* Interface describing function options. +*/ +interface Options { + /** + * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). + */ + order?: Order; + + /** + * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). + */ + mode?: Mode; + + /** + * Boolean indicating whether an array should be read-only (default: false). + */ + readonly?: boolean; +} + +/** +* Interface defining a typed vector constructor which is both "newable" and "callable". +*/ +interface Uint16Vector { + /** + * Creates an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint16Vector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + new ( options?: Options ): uint16ndarray; + + /** + * Creates an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint16Vector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( length: number, options?: Options ): uint16ndarray; + + /** + * Creates an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint16Vector( [ 1, 2 ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): uint16ndarray; + + /** + * Creates an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Uint16Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 16 + */ + new ( buffer: ArrayBuffer, options?: Options ): uint16ndarray; + + /** + * Creates an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new Uint16Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 12 + */ + new ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): uint16ndarray; + + /** + * Creates an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new Uint16Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): uint16ndarray; + + /** + * Creates an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint16Vector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + ( options?: Options ): uint16ndarray; + + /** + * Creates an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint16Vector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( length: number, options?: Options ): uint16ndarray; + + /** + * Creates an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint16Vector( [ 1, 2 ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): uint16ndarray; + + /** + * Creates an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Uint16Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 16 + */ + ( buffer: ArrayBuffer, options?: Options ): uint16ndarray; + + /** + * Creates an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new Uint16Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 12 + */ + ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): uint16ndarray; + + /** + * Creates an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new Uint16Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): uint16ndarray; +} + +/** +* Creates an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray). +* +* @param arg - length, typed array, array-like object, buffer, or iterable +* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) +* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer +* @param options - function options +* @param options.readonly - boolean indicating whether to return a read-only vector +* @param options.mode - specifies how to handle indices which exceed vector dimensions +* @param options.order - memory layout (either row-major or column-major) +* @returns one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint16Vector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint16Vector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint16Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Uint16Vector( buf, 8, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +declare var ctor: Uint16Vector; + + +// EXPORTS // + +export = ctor; diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint16/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/vector/uint16/docs/types/test.ts new file mode 100644 index 000000000000..13f0ff8befa7 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint16/docs/types/test.ts @@ -0,0 +1,86 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import ArrayBuffer = require( '@stdlib/array/buffer' ); +import Uint16Vector = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + new Uint16Vector(); // $ExpectType uint16ndarray + new Uint16Vector( {} ); // $ExpectType uint16ndarray + + new Uint16Vector( 10 ); // $ExpectType uint16ndarray + new Uint16Vector( 10, {} ); // $ExpectType uint16ndarray + + new Uint16Vector( [ 1, 2, 3 ] ); // $ExpectType uint16ndarray + new Uint16Vector( [ 1, 2, 3 ], {} ); // $ExpectType uint16ndarray + + new Uint16Vector( new ArrayBuffer( 10 ) ); // $ExpectType uint16ndarray + new Uint16Vector( new ArrayBuffer( 10 ), {} ); // $ExpectType uint16ndarray + + new Uint16Vector( new ArrayBuffer( 10 ), 8 ); // $ExpectType uint16ndarray + new Uint16Vector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType uint16ndarray + + new Uint16Vector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType uint16ndarray + new Uint16Vector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType uint16ndarray + + const vector = Uint16Vector; + vector(); // $ExpectType uint16ndarray + vector( {} ); // $ExpectType uint16ndarray + + vector( 10 ); // $ExpectType uint16ndarray + vector( 10, {} ); // $ExpectType uint16ndarray + + vector( [ 1, 2, 3 ] ); // $ExpectType uint16ndarray + vector( [ 1, 2, 3 ], {} ); // $ExpectType uint16ndarray + + vector( new ArrayBuffer( 10 ) ); // $ExpectType uint16ndarray + vector( new ArrayBuffer( 10 ), {} ); // $ExpectType uint16ndarray + + vector( new ArrayBuffer( 10 ), 8 ); // $ExpectType uint16ndarray + vector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType uint16ndarray + + vector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType uint16ndarray + vector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType uint16ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not a number, array-like object, iterable, or options object... +{ + new Uint16Vector( true ); // $ExpectError + new Uint16Vector( false ); // $ExpectError + new Uint16Vector( null ); // $ExpectError + new Uint16Vector( ( x: number ): number => x ); // $ExpectError + + const vector = Uint16Vector; + vector( true ); // $ExpectError + vector( false ); // $ExpectError + vector( null ); // $ExpectError + vector( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const buf = new ArrayBuffer( 32 ); + new Uint16Vector( buf, 8, 2, {}, {} ); // $ExpectError + + const vector = Uint16Vector; + vector( buf, 8, 2, {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint16/examples/index.js b/lib/node_modules/@stdlib/ndarray/vector/uint16/examples/index.js new file mode 100644 index 000000000000..fa68e29461af --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint16/examples/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sum = require( '@stdlib/blas/ext/sum' ); +var map = require( '@stdlib/ndarray/map' ); +var Uint16Vector = require( './../lib' ); + +// Create a vector containing random values: +var x = new Uint16Vector( discreteUniform( 10, 0, 100 ) ); + +// Compute the sum: +var v = sum( x ); +console.log( v.get() ); + +// Define a function which applies a threshold to individual values: +function threshold( v ) { + return ( v > 10 ) ? v : 0; +} + +// Apply threshold: +var y = map( x, threshold ); + +// Recompute the sum: +v = sum( y ); +console.log( v.get() ); diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint16/lib/index.js b/lib/node_modules/@stdlib/ndarray/vector/uint16/lib/index.js new file mode 100644 index 000000000000..93135b8af343 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint16/lib/index.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Create an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray). +* +* @module @stdlib/ndarray/vector/uint16 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint16Vector = require( '@stdlib/ndarray/vector/uint16' ); +* +* var v = new Uint16Vector(); +* // returns +* +* var len = numel( v ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint16Vector = require( '@stdlib/ndarray/vector/uint16' ); +* +* var v = new Uint16Vector( 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint16Vector = require( '@stdlib/ndarray/vector/uint16' ); +* +* var v = new Uint16Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint16Vector = require( '@stdlib/ndarray/vector/uint16' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new Uint16Vector( buf ); +* // returns +* +* var len = numel( v ); +* // returns 16 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint16Vector = require( '@stdlib/ndarray/vector/uint16' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new Uint16Vector( buf, 16 ); +* // returns +* +* var len = numel( v ); +* // returns 8 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint16Vector = require( '@stdlib/ndarray/vector/uint16' ); +* +* var buf = new ArrayBuffer( 64 ); +* var v = new Uint16Vector( buf, 16, 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint16/lib/main.js b/lib/node_modules/@stdlib/ndarray/vector/uint16/lib/main.js new file mode 100644 index 000000000000..0269b76bfa12 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint16/lib/main.js @@ -0,0 +1,109 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 factory = require( '@stdlib/ndarray/vector/ctor' ).factory; + + +// MAIN // + +/** +* Returns an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray). +* +* @name Uint16Vector +* @type {Function} +* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable +* @param {NonNegativeInteger} [byteOffset=0] - byte offset +* @param {NonNegativeInteger} [length] - view length +* @param {Options} [options] - function options +* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only vector +* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed vector dimensions +* @param {string} [options.order='row-major'] - memory layout (either row-major or column-major) +* @throws {TypeError} first argument must be either a length, typed array, array-like object, buffer, iterable, or options object +* @throws {TypeError} must provide valid options +* @returns {ndarray} one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint16Vector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint16Vector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint16Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Uint16Vector( buf ); +* // returns +* +* var len = numel( arr ); +* // returns 16 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Uint16Vector( buf, 16 ); +* // returns +* +* var len = numel( arr ); +* // returns 8 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 64 ); +* var arr = new Uint16Vector( buf, 16, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +var Uint16Vector = factory( 'uint16' ); + + +// EXPORTS // + +module.exports = Uint16Vector; diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint16/package.json b/lib/node_modules/@stdlib/ndarray/vector/uint16/package.json new file mode 100644 index 000000000000..1f43cf307541 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint16/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/ndarray/vector/uint16", + "version": "0.0.0", + "description": "Create an unsigned 16-bit integer vector (i.e., a one-dimensional ndarray).", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdtypes", + "types", + "data", + "structure", + "vector", + "vec", + "ndarray", + "constructor", + "ctor", + "uint16" + ] +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint16/test/test.js b/lib/node_modules/@stdlib/ndarray/vector/uint16/test/test.js new file mode 100644 index 000000000000..96ee0cb9e3ac --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint16/test/test.js @@ -0,0 +1,1022 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* eslint-disable no-new */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isndarrayLikeWithDataType = require( '@stdlib/assert/is-ndarray-like-with-data-type' ); +var isEqualUint16Array = require( '@stdlib/assert/is-equal-uint16array' ); +var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' ); +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint16Array = require( '@stdlib/array/uint16' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var array2buffer = require( '@stdlib/buffer/from-array' ); +var Uint16Vector = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint16Vector, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint16Vector( value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint16Vector( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint16Vector( value, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint16Vector( value, 0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint16Vector( value, 0, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint16Vector( value, 0, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint16Vector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint16Vector( new ArrayBuffer( 8 ), value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint16Vector( new ArrayBuffer( 8 ), value, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint16Vector( new ArrayBuffer( 8 ), value, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint16Vector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint16Vector( new ArrayBuffer( 8 ), 0, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (length)', function test( t ) { + var values; + var i; + + 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() { + new Uint16Vector( 10, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { + var values; + var i; + + 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() { + new Uint16Vector( [], value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new Uint16Vector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new Uint16Vector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset, length)', function test( t ) { + var values; + var i; + + 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() { + new Uint16Vector( new ArrayBuffer( 8 ), 0, 1, value ); + }; + } +}); + +tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'ROW', + 'row', + 'col-major', + 'col', + 'major', + 'minor', + null + ]; + + 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() { + new Uint16Vector({ + 'order': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'THROW', + 5, + null, + true, + false, + [], + {} + ]; + + 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() { + new Uint16Vector({ + 'mode': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + 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() { + new Uint16Vector({ + 'readonly': value + }); + }; + } +}); + +tape( 'the function returns a one-dimensional ndarray', function test( t ) { + var arr; + + arr = new Uint16Vector(); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + arr = new Uint16Vector( {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (length)', function test( t ) { + var arr; + + arr = new Uint16Vector( 10 ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + arr = new Uint16Vector( 10, {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (array)', function test( t ) { + var arr; + var out; + + arr = [ 1, 2, 3, 4 ]; + + out = new Uint16Vector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint16Array( getData( out ), new Uint16Array( arr ) ), true, 'returns expected value' ); + + out = new Uint16Vector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint16Array( getData( out ), new Uint16Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (typed array)', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + out = new Uint16Vector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint16Array( getData( out ), new Uint16Array( arr ) ), true, 'returns expected value' ); + + out = new Uint16Vector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint16Array( getData( out ), new Uint16Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (buffer)', function test( t ) { + var arr; + var out; + var buf; + + arr = [ 1, 2, 3, 4 ]; + buf = array2buffer( arr ); + + out = new Uint16Vector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint16Array( getData( out ), new Uint16Array( arr ) ), true, 'returns expected value' ); + + out = new Uint16Vector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint16Array( getData( out ), new Uint16Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 8 ); + + out = new Uint16Vector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint16Array( getData( out ), new Uint16Array( buf ) ), true, 'returns expected value' ); + + out = new Uint16Vector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint16Array( getData( out ), new Uint16Array( buf ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new Uint16Vector( buf, 8 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 12, 'returns expected value' ); + t.strictEqual( isEqualUint16Array( getData( out ), new Uint16Array( buf, 8 ) ), true, 'returns expected value' ); + + out = new Uint16Vector( buf, 8, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 12, 'returns expected value' ); + t.strictEqual( isEqualUint16Array( getData( out ), new Uint16Array( buf, 8 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset, length)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new Uint16Vector( buf, 8, 2 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualUint16Array( getData( out ), new Uint16Array( buf, 8, 2 ) ), true, 'returns expected value' ); + + out = new Uint16Vector( buf, 8, 2, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualUint16Array( getData( out ), new Uint16Array( buf, 8, 2 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout', function test( t ) { + var arr; + + arr = new Uint16Vector({ + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint16Vector({ + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (length)', function test( t ) { + var arr; + + arr = new Uint16Vector( 10, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint16Vector( 10, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (array)', function test( t ) { + var arr; + + arr = new Uint16Vector( [ 1, 2, 3, 4 ], { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint16Vector( [ 1, 2, 3, 4 ], { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer)', function test( t ) { + var arr; + + arr = new Uint16Vector( new ArrayBuffer( 32 ), { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 16, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint16Vector( new ArrayBuffer( 32 ), { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 16, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Uint16Vector( new ArrayBuffer( 32 ), 8, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 12, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint16Vector( new ArrayBuffer( 32 ), 8, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 12, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Uint16Vector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint16Vector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays', function test( t ) { + var arr; + + arr = new Uint16Vector({ + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (length)', function test( t ) { + var arr; + + arr = new Uint16Vector( 10, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (array)', function test( t ) { + var arr; + + arr = new Uint16Vector( [ 1, 2, 3, 4 ], { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new Uint16Vector( new ArrayBuffer( 32 ), { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 16, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Uint16Vector( new ArrayBuffer( 32 ), 8, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 12, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Uint16Vector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays', function test( t ) { + var arr; + + arr = new Uint16Vector({ + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (length)', function test( t ) { + var arr; + + arr = new Uint16Vector( 10, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (array)', function test( t ) { + var arr; + + arr = new Uint16Vector( [ 1, 2, 3, 4 ], { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new Uint16Vector( new ArrayBuffer( 32 ), { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 16, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Uint16Vector( new ArrayBuffer( 32 ), 8, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 12, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Uint16Vector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint16' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); From 1456ea8d4f5a3519811261ebbaf4760600a4bc6e Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 01:18:36 -0700 Subject: [PATCH 45/60] feat: add `ndarray/vector/uint8` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/ndarray/vector/uint8/README.md | 196 ++++ .../vector/uint8/benchmark/benchmark.js | 47 + .../vector/uint8/benchmark/benchmark.size.js | 93 ++ .../ndarray/vector/uint8/docs/repl.txt | 175 +++ .../vector/uint8/docs/types/index.d.ts | 377 ++++++ .../ndarray/vector/uint8/docs/types/test.ts | 86 ++ .../ndarray/vector/uint8/examples/index.js | 43 + .../@stdlib/ndarray/vector/uint8/lib/index.js | 100 ++ .../@stdlib/ndarray/vector/uint8/lib/main.js | 109 ++ .../@stdlib/ndarray/vector/uint8/package.json | 64 ++ .../@stdlib/ndarray/vector/uint8/test/test.js | 1022 +++++++++++++++++ 11 files changed, 2312 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8/benchmark/benchmark.size.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8/README.md b/lib/node_modules/@stdlib/ndarray/vector/uint8/README.md new file mode 100644 index 000000000000..b2fe99f51bb6 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8/README.md @@ -0,0 +1,196 @@ + + +# Uint8Vector + +> Create an unsigned 8-bit integer vector (i.e., a one-dimensional [ndarray][@stdlib/ndarray/ctor]). + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var Uint8Vector = require( '@stdlib/ndarray/vector/uint8' ); +``` + +#### Uint8Vector( \[options] ) + +Returns a one-dimensional unsigned 8-bit integer [ndarray][@stdlib/ndarray/ctor]. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Uint8Vector(); +// returns + +var len = numel( arr ); +// returns 0 +``` + +The function accepts the following options: + +- **order**: specifies whether an [ndarray][@stdlib/ndarray/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). Default: `'row-major'`. +- **mode**: specifies how to handle indices which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). Default: `'throw'`. +- **readonly**: boolean indicating whether an array should be **read-only**. Default: `false`. + +#### Uint8Vector( length\[, options] ) + +Returns a one-dimensional unsigned 8-bit integer [ndarray][@stdlib/ndarray/ctor] having a specified `length`. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Uint8Vector( 5 ); +// returns + +var len1 = numel( arr ); +// returns 5 +``` + +#### Uint8Vector( obj\[, options] ) + +Creates a one-dimensional unsigned 8-bit integer [ndarray][@stdlib/ndarray/ctor] from an array-like object or iterable. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Uint8Vector( [ 1, 2, 3 ] ); +// returns + +var len1 = numel( arr ); +// returns 3 +``` + +#### Uint8Vector( buffer\[, byteOffset\[, length]]\[, options] ) + +Returns a one-dimensional unsigned 8-bit integer [ndarray][@stdlib/ndarray/ctor] view of an [`ArrayBuffer`][@stdlib/array/buffer]. + +```javascript +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var numel = require( '@stdlib/ndarray/numel' ); + +var buf = new ArrayBuffer( 32 ); + +var arr1 = new Uint8Vector( buf ); +// returns + +var len1 = numel( arr1 ); +// returns 32 + +var arr2 = new Uint8Vector( buf, 16 ); +// returns + +var len2 = numel( arr2 ); +// returns 16 + +var arr3 = new Uint8Vector( buf, 16, 1 ); +// returns + +var len3 = numel( arr3 ); +// returns 1 +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sum = require( '@stdlib/blas/ext/sum' ); +var map = require( '@stdlib/ndarray/map' ); +var Uint8Vector = require( '@stdlib/ndarray/vector/uint8' ); + +// Create a vector containing random values: +var x = new Uint8Vector( discreteUniform( 10, 0, 100 ) ); + +// Compute the sum: +var v = sum( x ); +console.log( v.get() ); + +// Define a function which applies a threshold to individual values: +function threshold( v ) { + return ( v > 10 ) ? v : 0; +} + +// Apply threshold: +var y = map( x, threshold ); + +// Recompute the sum: +v = sum( y ); +console.log( v.get() ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/vector/uint8/benchmark/benchmark.js new file mode 100644 index 000000000000..ab585760ea7b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8/benchmark/benchmark.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var Uint8Vector = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Uint8Vector( 0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8/benchmark/benchmark.size.js b/lib/node_modules/@stdlib/ndarray/vector/uint8/benchmark/benchmark.size.js new file mode 100644 index 000000000000..3d376ac97a42 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8/benchmark/benchmark.size.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var Uint8Vector = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Uint8Vector( len ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + 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( pkg+':size='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/vector/uint8/docs/repl.txt new file mode 100644 index 000000000000..310c9157d061 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8/docs/repl.txt @@ -0,0 +1,175 @@ + +{{alias}}( [options] ) + Returns a one-dimensional unsigned 8-bit integer ndarray. + + Parameters + ---------- + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}() + + + +{{alias}}( length[, options] ) + Returns a one-dimensional unsigned 8-bit integer ndarray having a specified + length. + + Parameters + ---------- + length: integer + Number of elements. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}( 5 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 5 + + +{{alias}}( obj[, options] ) + Creates a one-dimensional unsigned 8-bit integer ndarray from an array-like + object or iterable. + + Parameters + ---------- + obj: Object + Array-like object or iterable from which to generate an ndarray. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var v = [ 1, 2, 3 ]; + > var arr = {{alias}}( v ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 3 + + +{{alias}}( buffer[, byteOffset[, length]][, options] ) + Returns a one-dimensional unsigned 8-bit integer ndarray view of an + ArrayBuffer. + + Parameters + ---------- + buffer: ArrayBuffer + Underlying ArrayBuffer. + + byteOffset: integer (optional) + Integer byte offset specifying the location of the first indexed + element. Default: 0. + + length: integer (optional) + View length. If not provided, the view spans from the byteOffset to + the end of the underlying ArrayBuffer. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var buf = new {{alias:@stdlib/array/buffer}}( 32 ); + > var arr = {{alias}}( buf, 0, 4 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 4 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/vector/uint8/docs/types/index.d.ts new file mode 100644 index 000000000000..374b947536e2 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8/docs/types/index.d.ts @@ -0,0 +1,377 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/* eslint-disable @typescript-eslint/unified-signatures */ + +/// + +import { Order, Mode, uint8ndarray } from '@stdlib/types/ndarray'; +import { Collection, AccessorArrayLike } from '@stdlib/types/array'; +import ArrayBuffer = require( '@stdlib/array/buffer' ); + +/** +* Interface describing function options. +*/ +interface Options { + /** + * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). + */ + order?: Order; + + /** + * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). + */ + mode?: Mode; + + /** + * Boolean indicating whether an array should be read-only (default: false). + */ + readonly?: boolean; +} + +/** +* Interface defining a typed vector constructor which is both "newable" and "callable". +*/ +interface Uint8Vector { + /** + * Creates an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint8Vector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + new ( options?: Options ): uint8ndarray; + + /** + * Creates an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint8Vector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( length: number, options?: Options ): uint8ndarray; + + /** + * Creates an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint8Vector( [ 1, 2 ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): uint8ndarray; + + /** + * Creates an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Uint8Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 32 + */ + new ( buffer: ArrayBuffer, options?: Options ): uint8ndarray; + + /** + * Creates an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new Uint8Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 24 + */ + new ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): uint8ndarray; + + /** + * Creates an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new Uint8Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): uint8ndarray; + + /** + * Creates an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint8Vector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + ( options?: Options ): uint8ndarray; + + /** + * Creates an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint8Vector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( length: number, options?: Options ): uint8ndarray; + + /** + * Creates an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint8Vector( [ 1, 2 ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): uint8ndarray; + + /** + * Creates an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Uint8Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 32 + */ + ( buffer: ArrayBuffer, options?: Options ): uint8ndarray; + + /** + * Creates an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new Uint8Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 24 + */ + ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): uint8ndarray; + + /** + * Creates an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new Uint8Vector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): uint8ndarray; +} + +/** +* Creates an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). +* +* @param arg - length, typed array, array-like object, buffer, or iterable +* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) +* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer +* @param options - function options +* @param options.readonly - boolean indicating whether to return a read-only vector +* @param options.mode - specifies how to handle indices which exceed vector dimensions +* @param options.order - memory layout (either row-major or column-major) +* @returns one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint8Vector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint8Vector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint8Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Uint8Vector( buf, 8, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +declare var ctor: Uint8Vector; + + +// EXPORTS // + +export = ctor; diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/vector/uint8/docs/types/test.ts new file mode 100644 index 000000000000..b578ba30440b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8/docs/types/test.ts @@ -0,0 +1,86 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import ArrayBuffer = require( '@stdlib/array/buffer' ); +import Uint8Vector = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + new Uint8Vector(); // $ExpectType uint8ndarray + new Uint8Vector( {} ); // $ExpectType uint8ndarray + + new Uint8Vector( 10 ); // $ExpectType uint8ndarray + new Uint8Vector( 10, {} ); // $ExpectType uint8ndarray + + new Uint8Vector( [ 1, 2, 3 ] ); // $ExpectType uint8ndarray + new Uint8Vector( [ 1, 2, 3 ], {} ); // $ExpectType uint8ndarray + + new Uint8Vector( new ArrayBuffer( 10 ) ); // $ExpectType uint8ndarray + new Uint8Vector( new ArrayBuffer( 10 ), {} ); // $ExpectType uint8ndarray + + new Uint8Vector( new ArrayBuffer( 10 ), 8 ); // $ExpectType uint8ndarray + new Uint8Vector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType uint8ndarray + + new Uint8Vector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType uint8ndarray + new Uint8Vector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType uint8ndarray + + const vector = Uint8Vector; + vector(); // $ExpectType uint8ndarray + vector( {} ); // $ExpectType uint8ndarray + + vector( 10 ); // $ExpectType uint8ndarray + vector( 10, {} ); // $ExpectType uint8ndarray + + vector( [ 1, 2, 3 ] ); // $ExpectType uint8ndarray + vector( [ 1, 2, 3 ], {} ); // $ExpectType uint8ndarray + + vector( new ArrayBuffer( 10 ) ); // $ExpectType uint8ndarray + vector( new ArrayBuffer( 10 ), {} ); // $ExpectType uint8ndarray + + vector( new ArrayBuffer( 10 ), 8 ); // $ExpectType uint8ndarray + vector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType uint8ndarray + + vector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType uint8ndarray + vector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType uint8ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not a number, array-like object, iterable, or options object... +{ + new Uint8Vector( true ); // $ExpectError + new Uint8Vector( false ); // $ExpectError + new Uint8Vector( null ); // $ExpectError + new Uint8Vector( ( x: number ): number => x ); // $ExpectError + + const vector = Uint8Vector; + vector( true ); // $ExpectError + vector( false ); // $ExpectError + vector( null ); // $ExpectError + vector( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const buf = new ArrayBuffer( 32 ); + new Uint8Vector( buf, 8, 2, {}, {} ); // $ExpectError + + const vector = Uint8Vector; + vector( buf, 8, 2, {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8/examples/index.js b/lib/node_modules/@stdlib/ndarray/vector/uint8/examples/index.js new file mode 100644 index 000000000000..36fd4fac71c5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8/examples/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sum = require( '@stdlib/blas/ext/sum' ); +var map = require( '@stdlib/ndarray/map' ); +var Uint8Vector = require( './../lib' ); + +// Create a vector containing random values: +var x = new Uint8Vector( discreteUniform( 10, 0, 100 ) ); + +// Compute the sum: +var v = sum( x ); +console.log( v.get() ); + +// Define a function which applies a threshold to individual values: +function threshold( v ) { + return ( v > 10 ) ? v : 0; +} + +// Apply threshold: +var y = map( x, threshold ); + +// Recompute the sum: +v = sum( y ); +console.log( v.get() ); diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8/lib/index.js b/lib/node_modules/@stdlib/ndarray/vector/uint8/lib/index.js new file mode 100644 index 000000000000..e1e7a6764662 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8/lib/index.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Create an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). +* +* @module @stdlib/ndarray/vector/uint8 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint8Vector = require( '@stdlib/ndarray/vector/uint8' ); +* +* var v = new Uint8Vector(); +* // returns +* +* var len = numel( v ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint8Vector = require( '@stdlib/ndarray/vector/uint8' ); +* +* var v = new Uint8Vector( 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint8Vector = require( '@stdlib/ndarray/vector/uint8' ); +* +* var v = new Uint8Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint8Vector = require( '@stdlib/ndarray/vector/uint8' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new Uint8Vector( buf ); +* // returns +* +* var len = numel( v ); +* // returns 32 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint8Vector = require( '@stdlib/ndarray/vector/uint8' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new Uint8Vector( buf, 16 ); +* // returns +* +* var len = numel( v ); +* // returns 16 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint8Vector = require( '@stdlib/ndarray/vector/uint8' ); +* +* var buf = new ArrayBuffer( 64 ); +* var v = new Uint8Vector( buf, 16, 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8/lib/main.js b/lib/node_modules/@stdlib/ndarray/vector/uint8/lib/main.js new file mode 100644 index 000000000000..af4b1d18bbb4 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8/lib/main.js @@ -0,0 +1,109 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 factory = require( '@stdlib/ndarray/vector/ctor' ).factory; + + +// MAIN // + +/** +* Returns an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). +* +* @name Uint8Vector +* @type {Function} +* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable +* @param {NonNegativeInteger} [byteOffset=0] - byte offset +* @param {NonNegativeInteger} [length] - view length +* @param {Options} [options] - function options +* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only vector +* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed vector dimensions +* @param {string} [options.order='row-major'] - memory layout (either row-major or column-major) +* @throws {TypeError} first argument must be either a length, typed array, array-like object, buffer, iterable, or options object +* @throws {TypeError} must provide valid options +* @returns {ndarray} one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint8Vector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint8Vector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint8Vector( [ 1, 2 ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Uint8Vector( buf ); +* // returns +* +* var len = numel( arr ); +* // returns 32 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Uint8Vector( buf, 16 ); +* // returns +* +* var len = numel( arr ); +* // returns 16 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 64 ); +* var arr = new Uint8Vector( buf, 16, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +var Uint8Vector = factory( 'uint8' ); + + +// EXPORTS // + +module.exports = Uint8Vector; diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8/package.json b/lib/node_modules/@stdlib/ndarray/vector/uint8/package.json new file mode 100644 index 000000000000..4ab44f059163 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/ndarray/vector/uint8", + "version": "0.0.0", + "description": "Create an unsigned 8-bit integer vector (i.e., a one-dimensional ndarray).", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdtypes", + "types", + "data", + "structure", + "vector", + "vec", + "ndarray", + "constructor", + "ctor", + "uint8" + ] +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8/test/test.js b/lib/node_modules/@stdlib/ndarray/vector/uint8/test/test.js new file mode 100644 index 000000000000..aacd794eb4ee --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8/test/test.js @@ -0,0 +1,1022 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* eslint-disable no-new */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isndarrayLikeWithDataType = require( '@stdlib/assert/is-ndarray-like-with-data-type' ); +var isEqualUint8Array = require( '@stdlib/assert/is-equal-uint8array' ); +var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' ); +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var array2buffer = require( '@stdlib/buffer/from-array' ); +var Uint8Vector = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint8Vector, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8Vector( value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8Vector( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8Vector( value, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8Vector( value, 0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8Vector( value, 0, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8Vector( value, 0, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8Vector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8Vector( new ArrayBuffer( 8 ), value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8Vector( new ArrayBuffer( 8 ), value, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8Vector( new ArrayBuffer( 8 ), value, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8Vector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8Vector( new ArrayBuffer( 8 ), 0, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (length)', function test( t ) { + var values; + var i; + + 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() { + new Uint8Vector( 10, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { + var values; + var i; + + 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() { + new Uint8Vector( [], value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new Uint8Vector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new Uint8Vector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset, length)', function test( t ) { + var values; + var i; + + 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() { + new Uint8Vector( new ArrayBuffer( 8 ), 0, 1, value ); + }; + } +}); + +tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'ROW', + 'row', + 'col-major', + 'col', + 'major', + 'minor', + null + ]; + + 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() { + new Uint8Vector({ + 'order': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'THROW', + 5, + null, + true, + false, + [], + {} + ]; + + 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() { + new Uint8Vector({ + 'mode': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + 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() { + new Uint8Vector({ + 'readonly': value + }); + }; + } +}); + +tape( 'the function returns a one-dimensional ndarray', function test( t ) { + var arr; + + arr = new Uint8Vector(); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + arr = new Uint8Vector( {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (length)', function test( t ) { + var arr; + + arr = new Uint8Vector( 10 ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + arr = new Uint8Vector( 10, {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (array)', function test( t ) { + var arr; + var out; + + arr = [ 1, 2, 3, 4 ]; + + out = new Uint8Vector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint8Array( getData( out ), new Uint8Array( arr ) ), true, 'returns expected value' ); + + out = new Uint8Vector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint8Array( getData( out ), new Uint8Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (typed array)', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + out = new Uint8Vector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint8Array( getData( out ), new Uint8Array( arr ) ), true, 'returns expected value' ); + + out = new Uint8Vector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint8Array( getData( out ), new Uint8Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (buffer)', function test( t ) { + var arr; + var out; + var buf; + + arr = [ 1, 2, 3, 4 ]; + buf = array2buffer( arr ); + + out = new Uint8Vector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint8Array( getData( out ), new Uint8Array( arr ) ), true, 'returns expected value' ); + + out = new Uint8Vector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint8Array( getData( out ), new Uint8Array( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 8 ); + + out = new Uint8Vector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 8, 'returns expected value' ); + t.strictEqual( isEqualUint8Array( getData( out ), new Uint8Array( buf ) ), true, 'returns expected value' ); + + out = new Uint8Vector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 8, 'returns expected value' ); + t.strictEqual( isEqualUint8Array( getData( out ), new Uint8Array( buf ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new Uint8Vector( buf, 8 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 24, 'returns expected value' ); + t.strictEqual( isEqualUint8Array( getData( out ), new Uint8Array( buf, 8 ) ), true, 'returns expected value' ); + + out = new Uint8Vector( buf, 8, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 24, 'returns expected value' ); + t.strictEqual( isEqualUint8Array( getData( out ), new Uint8Array( buf, 8 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset, length)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new Uint8Vector( buf, 8, 2 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualUint8Array( getData( out ), new Uint8Array( buf, 8, 2 ) ), true, 'returns expected value' ); + + out = new Uint8Vector( buf, 8, 2, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualUint8Array( getData( out ), new Uint8Array( buf, 8, 2 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout', function test( t ) { + var arr; + + arr = new Uint8Vector({ + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint8Vector({ + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (length)', function test( t ) { + var arr; + + arr = new Uint8Vector( 10, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint8Vector( 10, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (array)', function test( t ) { + var arr; + + arr = new Uint8Vector( [ 1, 2, 3, 4 ], { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint8Vector( [ 1, 2, 3, 4 ], { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer)', function test( t ) { + var arr; + + arr = new Uint8Vector( new ArrayBuffer( 32 ), { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint8Vector( new ArrayBuffer( 32 ), { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Uint8Vector( new ArrayBuffer( 32 ), 8, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint8Vector( new ArrayBuffer( 32 ), 8, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Uint8Vector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint8Vector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays', function test( t ) { + var arr; + + arr = new Uint8Vector({ + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (length)', function test( t ) { + var arr; + + arr = new Uint8Vector( 10, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (array)', function test( t ) { + var arr; + + arr = new Uint8Vector( [ 1, 2, 3, 4 ], { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new Uint8Vector( new ArrayBuffer( 32 ), { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Uint8Vector( new ArrayBuffer( 32 ), 8, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Uint8Vector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays', function test( t ) { + var arr; + + arr = new Uint8Vector({ + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (length)', function test( t ) { + var arr; + + arr = new Uint8Vector( 10, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (array)', function test( t ) { + var arr; + + arr = new Uint8Vector( [ 1, 2, 3, 4 ], { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new Uint8Vector( new ArrayBuffer( 32 ), { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Uint8Vector( new ArrayBuffer( 32 ), 8, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Uint8Vector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); From 34aa08963d038cffbee304f6142f10dadfbf3d74 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 01:25:34 -0700 Subject: [PATCH 46/60] feat: add `ndarray/vector/uint8c` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/ndarray/vector/uint8c/README.md | 196 ++++ .../vector/uint8c/benchmark/benchmark.js | 47 + .../vector/uint8c/benchmark/benchmark.size.js | 93 ++ .../ndarray/vector/uint8c/docs/repl.txt | 175 +++ .../vector/uint8c/docs/types/index.d.ts | 377 ++++++ .../ndarray/vector/uint8c/docs/types/test.ts | 86 ++ .../ndarray/vector/uint8c/examples/index.js | 43 + .../ndarray/vector/uint8c/lib/index.js | 100 ++ .../@stdlib/ndarray/vector/uint8c/lib/main.js | 109 ++ .../ndarray/vector/uint8c/package.json | 64 ++ .../ndarray/vector/uint8c/test/test.js | 1022 +++++++++++++++++ 11 files changed, 2312 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8c/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8c/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8c/benchmark/benchmark.size.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8c/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8c/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8c/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8c/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8c/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8c/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8c/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/vector/uint8c/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8c/README.md b/lib/node_modules/@stdlib/ndarray/vector/uint8c/README.md new file mode 100644 index 000000000000..3b36eb899f9b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8c/README.md @@ -0,0 +1,196 @@ + + +# Uint8ClampedVector + +> Create a clamped unsigned 8-bit integer vector (i.e., a one-dimensional [ndarray][@stdlib/ndarray/ctor]). + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var Uint8ClampedVector = require( '@stdlib/ndarray/vector/uint8c' ); +``` + +#### Uint8ClampedVector( \[options] ) + +Returns a one-dimensional clamped unsigned 8-bit integer [ndarray][@stdlib/ndarray/ctor]. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Uint8ClampedVector(); +// returns + +var len = numel( arr ); +// returns 0 +``` + +The function accepts the following options: + +- **order**: specifies whether an [ndarray][@stdlib/ndarray/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). Default: `'row-major'`. +- **mode**: specifies how to handle indices which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). Default: `'throw'`. +- **readonly**: boolean indicating whether an array should be **read-only**. Default: `false`. + +#### Uint8ClampedVector( length\[, options] ) + +Returns a one-dimensional clamped unsigned 8-bit integer [ndarray][@stdlib/ndarray/ctor] having a specified `length`. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Uint8ClampedVector( 5 ); +// returns + +var len1 = numel( arr ); +// returns 5 +``` + +#### Uint8ClampedVector( obj\[, options] ) + +Creates a one-dimensional clamped unsigned 8-bit integer [ndarray][@stdlib/ndarray/ctor] from an array-like object or iterable. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new Uint8ClampedVector( [ 1, 2, 3 ] ); +// returns + +var len1 = numel( arr ); +// returns 3 +``` + +#### Uint8ClampedVector( buffer\[, byteOffset\[, length]]\[, options] ) + +Returns a one-dimensional clamped unsigned 8-bit integer [ndarray][@stdlib/ndarray/ctor] view of an [`ArrayBuffer`][@stdlib/array/buffer]. + +```javascript +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var numel = require( '@stdlib/ndarray/numel' ); + +var buf = new ArrayBuffer( 32 ); + +var arr1 = new Uint8ClampedVector( buf ); +// returns + +var len1 = numel( arr1 ); +// returns 32 + +var arr2 = new Uint8ClampedVector( buf, 16 ); +// returns + +var len2 = numel( arr2 ); +// returns 16 + +var arr3 = new Uint8ClampedVector( buf, 16, 1 ); +// returns + +var len3 = numel( arr3 ); +// returns 1 +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sum = require( '@stdlib/blas/ext/sum' ); +var map = require( '@stdlib/ndarray/map' ); +var Uint8ClampedVector = require( '@stdlib/ndarray/vector/uint8c' ); + +// Create a vector containing random values: +var x = new Uint8ClampedVector( discreteUniform( 10, 0, 100 ) ); + +// Compute the sum: +var v = sum( x ); +console.log( v.get() ); + +// Define a function which applies a threshold to individual values: +function threshold( v ) { + return ( v > 10 ) ? v : 0; +} + +// Apply threshold: +var y = map( x, threshold ); + +// Recompute the sum: +v = sum( y ); +console.log( v.get() ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8c/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/vector/uint8c/benchmark/benchmark.js new file mode 100644 index 000000000000..bf3f7ba66748 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8c/benchmark/benchmark.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var Uint8ClampedVector = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Uint8ClampedVector( 0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8c/benchmark/benchmark.size.js b/lib/node_modules/@stdlib/ndarray/vector/uint8c/benchmark/benchmark.size.js new file mode 100644 index 000000000000..bd9bb51b9ddc --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8c/benchmark/benchmark.size.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var Uint8ClampedVector = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new Uint8ClampedVector( len ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + 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( pkg+':size='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8c/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/vector/uint8c/docs/repl.txt new file mode 100644 index 000000000000..985fe2f8fba9 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8c/docs/repl.txt @@ -0,0 +1,175 @@ + +{{alias}}( [options] ) + Returns a one-dimensional clamped unsigned 8-bit integer ndarray. + + Parameters + ---------- + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}() + + + +{{alias}}( length[, options] ) + Returns a one-dimensional clamped unsigned 8-bit integer ndarray having a + specified length. + + Parameters + ---------- + length: integer + Number of elements. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}( 5 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 5 + + +{{alias}}( obj[, options] ) + Creates a one-dimensional clamped unsigned 8-bit integer ndarray from an + array-like object or iterable. + + Parameters + ---------- + obj: Object + Array-like object or iterable from which to generate an ndarray. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var v = [ 1, 2, 3 ]; + > var arr = {{alias}}( v ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 3 + + +{{alias}}( buffer[, byteOffset[, length]][, options] ) + Returns a one-dimensional clamped unsigned 8-bit integer ndarray view of an + ArrayBuffer. + + Parameters + ---------- + buffer: ArrayBuffer + Underlying ArrayBuffer. + + byteOffset: integer (optional) + Integer byte offset specifying the location of the first indexed + element. Default: 0. + + length: integer (optional) + View length. If not provided, the view spans from the byteOffset to + the end of the underlying ArrayBuffer. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var buf = new {{alias:@stdlib/array/buffer}}( 32 ); + > var arr = {{alias}}( buf, 0, 4 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 4 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8c/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/vector/uint8c/docs/types/index.d.ts new file mode 100644 index 000000000000..3ba18d72e36e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8c/docs/types/index.d.ts @@ -0,0 +1,377 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/* eslint-disable @typescript-eslint/unified-signatures */ + +/// + +import { Order, Mode, uint8cndarray } from '@stdlib/types/ndarray'; +import { Collection, AccessorArrayLike } from '@stdlib/types/array'; +import ArrayBuffer = require( '@stdlib/array/buffer' ); + +/** +* Interface describing function options. +*/ +interface Options { + /** + * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). + */ + order?: Order; + + /** + * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). + */ + mode?: Mode; + + /** + * Boolean indicating whether an array should be read-only (default: false). + */ + readonly?: boolean; +} + +/** +* Interface defining a typed vector constructor which is both "newable" and "callable". +*/ +interface Uint8ClampedVector { + /** + * Creates a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint8ClampedVector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + new ( options?: Options ): uint8cndarray; + + /** + * Creates a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint8ClampedVector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( length: number, options?: Options ): uint8cndarray; + + /** + * Creates a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint8ClampedVector( [ 1, 2 ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): uint8cndarray; + + /** + * Creates a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Uint8ClampedVector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 32 + */ + new ( buffer: ArrayBuffer, options?: Options ): uint8cndarray; + + /** + * Creates a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new Uint8ClampedVector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 24 + */ + new ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): uint8cndarray; + + /** + * Creates a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new Uint8ClampedVector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): uint8cndarray; + + /** + * Creates a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint8ClampedVector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + ( options?: Options ): uint8cndarray; + + /** + * Creates a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint8ClampedVector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( length: number, options?: Options ): uint8cndarray; + + /** + * Creates a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new Uint8ClampedVector( [ 1, 2 ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): uint8cndarray; + + /** + * Creates a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new Uint8ClampedVector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 32 + */ + ( buffer: ArrayBuffer, options?: Options ): uint8cndarray; + + /** + * Creates a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new Uint8ClampedVector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 24 + */ + ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): uint8cndarray; + + /** + * Creates a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new Uint8ClampedVector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): uint8cndarray; +} + +/** +* Creates a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). +* +* @param arg - length, typed array, array-like object, buffer, or iterable +* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) +* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer +* @param options - function options +* @param options.readonly - boolean indicating whether to return a read-only vector +* @param options.mode - specifies how to handle indices which exceed vector dimensions +* @param options.order - memory layout (either row-major or column-major) +* @returns one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint8ClampedVector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint8ClampedVector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint8ClampedVector( [ 1, 2 ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Uint8ClampedVector( buf, 8, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +declare var ctor: Uint8ClampedVector; + + +// EXPORTS // + +export = ctor; diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8c/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/vector/uint8c/docs/types/test.ts new file mode 100644 index 000000000000..80d663ecfe1f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8c/docs/types/test.ts @@ -0,0 +1,86 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import ArrayBuffer = require( '@stdlib/array/buffer' ); +import Uint8ClampedVector = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + new Uint8ClampedVector(); // $ExpectType uint8cndarray + new Uint8ClampedVector( {} ); // $ExpectType uint8cndarray + + new Uint8ClampedVector( 10 ); // $ExpectType uint8cndarray + new Uint8ClampedVector( 10, {} ); // $ExpectType uint8cndarray + + new Uint8ClampedVector( [ 1, 2, 3 ] ); // $ExpectType uint8cndarray + new Uint8ClampedVector( [ 1, 2, 3 ], {} ); // $ExpectType uint8cndarray + + new Uint8ClampedVector( new ArrayBuffer( 10 ) ); // $ExpectType uint8cndarray + new Uint8ClampedVector( new ArrayBuffer( 10 ), {} ); // $ExpectType uint8cndarray + + new Uint8ClampedVector( new ArrayBuffer( 10 ), 8 ); // $ExpectType uint8cndarray + new Uint8ClampedVector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType uint8cndarray + + new Uint8ClampedVector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType uint8cndarray + new Uint8ClampedVector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType uint8cndarray + + const vector = Uint8ClampedVector; + vector(); // $ExpectType uint8cndarray + vector( {} ); // $ExpectType uint8cndarray + + vector( 10 ); // $ExpectType uint8cndarray + vector( 10, {} ); // $ExpectType uint8cndarray + + vector( [ 1, 2, 3 ] ); // $ExpectType uint8cndarray + vector( [ 1, 2, 3 ], {} ); // $ExpectType uint8cndarray + + vector( new ArrayBuffer( 10 ) ); // $ExpectType uint8cndarray + vector( new ArrayBuffer( 10 ), {} ); // $ExpectType uint8cndarray + + vector( new ArrayBuffer( 10 ), 8 ); // $ExpectType uint8cndarray + vector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType uint8cndarray + + vector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType uint8cndarray + vector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType uint8cndarray +} + +// The compiler throws an error if the function is provided a first argument which is not a number, array-like object, iterable, or options object... +{ + new Uint8ClampedVector( true ); // $ExpectError + new Uint8ClampedVector( false ); // $ExpectError + new Uint8ClampedVector( null ); // $ExpectError + new Uint8ClampedVector( ( x: number ): number => x ); // $ExpectError + + const vector = Uint8ClampedVector; + vector( true ); // $ExpectError + vector( false ); // $ExpectError + vector( null ); // $ExpectError + vector( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const buf = new ArrayBuffer( 32 ); + new Uint8ClampedVector( buf, 8, 2, {}, {} ); // $ExpectError + + const vector = Uint8ClampedVector; + vector( buf, 8, 2, {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8c/examples/index.js b/lib/node_modules/@stdlib/ndarray/vector/uint8c/examples/index.js new file mode 100644 index 000000000000..fcc0411c2ebc --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8c/examples/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sum = require( '@stdlib/blas/ext/sum' ); +var map = require( '@stdlib/ndarray/map' ); +var Uint8ClampedVector = require( './../lib' ); + +// Create a vector containing random values: +var x = new Uint8ClampedVector( discreteUniform( 10, 0, 100 ) ); + +// Compute the sum: +var v = sum( x ); +console.log( v.get() ); + +// Define a function which applies a threshold to individual values: +function threshold( v ) { + return ( v > 10 ) ? v : 0; +} + +// Apply threshold: +var y = map( x, threshold ); + +// Recompute the sum: +v = sum( y ); +console.log( v.get() ); diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8c/lib/index.js b/lib/node_modules/@stdlib/ndarray/vector/uint8c/lib/index.js new file mode 100644 index 000000000000..d34bd4c0f8e5 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8c/lib/index.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Create a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). +* +* @module @stdlib/ndarray/vector/uint8c +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint8ClampedVector = require( '@stdlib/ndarray/vector/uint8c' ); +* +* var v = new Uint8ClampedVector(); +* // returns +* +* var len = numel( v ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint8ClampedVector = require( '@stdlib/ndarray/vector/uint8c' ); +* +* var v = new Uint8ClampedVector( 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint8ClampedVector = require( '@stdlib/ndarray/vector/uint8c' ); +* +* var v = new Uint8ClampedVector( [ 1, 2 ] ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint8ClampedVector = require( '@stdlib/ndarray/vector/uint8c' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new Uint8ClampedVector( buf ); +* // returns +* +* var len = numel( v ); +* // returns 32 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint8ClampedVector = require( '@stdlib/ndarray/vector/uint8c' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new Uint8ClampedVector( buf, 16 ); +* // returns +* +* var len = numel( v ); +* // returns 16 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var Uint8ClampedVector = require( '@stdlib/ndarray/vector/uint8c' ); +* +* var buf = new ArrayBuffer( 64 ); +* var v = new Uint8ClampedVector( buf, 16, 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8c/lib/main.js b/lib/node_modules/@stdlib/ndarray/vector/uint8c/lib/main.js new file mode 100644 index 000000000000..bf442d052657 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8c/lib/main.js @@ -0,0 +1,109 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 factory = require( '@stdlib/ndarray/vector/ctor' ).factory; + + +// MAIN // + +/** +* Returns a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray). +* +* @name Uint8ClampedVector +* @type {Function} +* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable +* @param {NonNegativeInteger} [byteOffset=0] - byte offset +* @param {NonNegativeInteger} [length] - view length +* @param {Options} [options] - function options +* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only vector +* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed vector dimensions +* @param {string} [options.order='row-major'] - memory layout (either row-major or column-major) +* @throws {TypeError} first argument must be either a length, typed array, array-like object, buffer, iterable, or options object +* @throws {TypeError} must provide valid options +* @returns {ndarray} one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint8ClampedVector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint8ClampedVector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new Uint8ClampedVector( [ 1, 2 ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Uint8ClampedVector( buf ); +* // returns +* +* var len = numel( arr ); +* // returns 32 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new Uint8ClampedVector( buf, 16 ); +* // returns +* +* var len = numel( arr ); +* // returns 16 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 64 ); +* var arr = new Uint8ClampedVector( buf, 16, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +var Uint8ClampedVector = factory( 'uint8c' ); + + +// EXPORTS // + +module.exports = Uint8ClampedVector; diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8c/package.json b/lib/node_modules/@stdlib/ndarray/vector/uint8c/package.json new file mode 100644 index 000000000000..efa822629865 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8c/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/ndarray/vector/uint8c", + "version": "0.0.0", + "description": "Create a clamped unsigned 8-bit integer vector (i.e., a one-dimensional ndarray).", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdtypes", + "types", + "data", + "structure", + "vector", + "vec", + "ndarray", + "constructor", + "ctor", + "uint8c" + ] +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/uint8c/test/test.js b/lib/node_modules/@stdlib/ndarray/vector/uint8c/test/test.js new file mode 100644 index 000000000000..ea58fd6848cc --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/uint8c/test/test.js @@ -0,0 +1,1022 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* eslint-disable no-new */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isndarrayLikeWithDataType = require( '@stdlib/assert/is-ndarray-like-with-data-type' ); +var isEqualUint8ClampedArray = require( '@stdlib/assert/is-equal-uint8clampedarray' ); +var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' ); +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var array2buffer = require( '@stdlib/buffer/from-array' ); +var Uint8ClampedVector = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Uint8ClampedVector, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8ClampedVector( value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8ClampedVector( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8ClampedVector( value, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8ClampedVector( value, 0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8ClampedVector( value, 0, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8ClampedVector( value, 0, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8ClampedVector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8ClampedVector( new ArrayBuffer( 8 ), value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8ClampedVector( new ArrayBuffer( 8 ), value, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8ClampedVector( new ArrayBuffer( 8 ), value, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8ClampedVector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new Uint8ClampedVector( new ArrayBuffer( 8 ), 0, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (length)', function test( t ) { + var values; + var i; + + 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() { + new Uint8ClampedVector( 10, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { + var values; + var i; + + 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() { + new Uint8ClampedVector( [], value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new Uint8ClampedVector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new Uint8ClampedVector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset, length)', function test( t ) { + var values; + var i; + + 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() { + new Uint8ClampedVector( new ArrayBuffer( 8 ), 0, 1, value ); + }; + } +}); + +tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'ROW', + 'row', + 'col-major', + 'col', + 'major', + 'minor', + null + ]; + + 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() { + new Uint8ClampedVector({ + 'order': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'THROW', + 5, + null, + true, + false, + [], + {} + ]; + + 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() { + new Uint8ClampedVector({ + 'mode': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + 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() { + new Uint8ClampedVector({ + 'readonly': value + }); + }; + } +}); + +tape( 'the function returns a one-dimensional ndarray', function test( t ) { + var arr; + + arr = new Uint8ClampedVector(); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + arr = new Uint8ClampedVector( {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (length)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( 10 ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + arr = new Uint8ClampedVector( 10, {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (array)', function test( t ) { + var arr; + var out; + + arr = [ 1, 2, 3, 4 ]; + + out = new Uint8ClampedVector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint8ClampedArray( getData( out ), new Uint8ClampedArray( arr ) ), true, 'returns expected value' ); + + out = new Uint8ClampedVector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint8ClampedArray( getData( out ), new Uint8ClampedArray( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (typed array)', function test( t ) { + var arr; + var out; + + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + out = new Uint8ClampedVector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint8ClampedArray( getData( out ), new Uint8ClampedArray( arr ) ), true, 'returns expected value' ); + + out = new Uint8ClampedVector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint8ClampedArray( getData( out ), new Uint8ClampedArray( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (buffer)', function test( t ) { + var arr; + var out; + var buf; + + arr = [ 1, 2, 3, 4 ]; + buf = array2buffer( arr ); + + out = new Uint8ClampedVector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint8ClampedArray( getData( out ), new Uint8ClampedArray( arr ) ), true, 'returns expected value' ); + + out = new Uint8ClampedVector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualUint8ClampedArray( getData( out ), new Uint8ClampedArray( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 8 ); + + out = new Uint8ClampedVector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( out.length, 8, 'returns expected value' ); + t.strictEqual( isEqualUint8ClampedArray( getData( out ), new Uint8ClampedArray( buf ) ), true, 'returns expected value' ); + + out = new Uint8ClampedVector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( out.length, 8, 'returns expected value' ); + t.strictEqual( isEqualUint8ClampedArray( getData( out ), new Uint8ClampedArray( buf ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new Uint8ClampedVector( buf, 8 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( out.length, 24, 'returns expected value' ); + t.strictEqual( isEqualUint8ClampedArray( getData( out ), new Uint8ClampedArray( buf, 8 ) ), true, 'returns expected value' ); + + out = new Uint8ClampedVector( buf, 8, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( out.length, 24, 'returns expected value' ); + t.strictEqual( isEqualUint8ClampedArray( getData( out ), new Uint8ClampedArray( buf, 8 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset, length)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new Uint8ClampedVector( buf, 8, 2 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualUint8ClampedArray( getData( out ), new Uint8ClampedArray( buf, 8, 2 ) ), true, 'returns expected value' ); + + out = new Uint8ClampedVector( buf, 8, 2, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualUint8ClampedArray( getData( out ), new Uint8ClampedArray( buf, 8, 2 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout', function test( t ) { + var arr; + + arr = new Uint8ClampedVector({ + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint8ClampedVector({ + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (length)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( 10, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint8ClampedVector( 10, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (array)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( [ 1, 2, 3, 4 ], { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint8ClampedVector( [ 1, 2, 3, 4 ], { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( new ArrayBuffer( 32 ), { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint8ClampedVector( new ArrayBuffer( 32 ), { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( new ArrayBuffer( 32 ), 8, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint8ClampedVector( new ArrayBuffer( 32 ), 8, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new Uint8ClampedVector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays', function test( t ) { + var arr; + + arr = new Uint8ClampedVector({ + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (length)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( 10, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (array)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( [ 1, 2, 3, 4 ], { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( new ArrayBuffer( 32 ), { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( new ArrayBuffer( 32 ), 8, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays', function test( t ) { + var arr; + + arr = new Uint8ClampedVector({ + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (length)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( 10, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (array)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( [ 1, 2, 3, 4 ], { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( new ArrayBuffer( 32 ), { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( new ArrayBuffer( 32 ), 8, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new Uint8ClampedVector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'uint8c' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); From c08c18d74faca63932755275c9f9bc08742f1fe6 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 01:36:20 -0700 Subject: [PATCH 47/60] feat: add `ndarray/vector/bool` --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/ndarray/vector/bool/README.md | 196 ++++ .../vector/bool/benchmark/benchmark.js | 47 + .../vector/bool/benchmark/benchmark.size.js | 93 ++ .../@stdlib/ndarray/vector/bool/docs/repl.txt | 173 +++ .../ndarray/vector/bool/docs/types/index.d.ts | 377 ++++++ .../ndarray/vector/bool/docs/types/test.ts | 86 ++ .../ndarray/vector/bool/examples/index.js | 43 + .../@stdlib/ndarray/vector/bool/lib/index.js | 100 ++ .../@stdlib/ndarray/vector/bool/lib/main.js | 109 ++ .../@stdlib/ndarray/vector/bool/package.json | 65 ++ .../@stdlib/ndarray/vector/bool/test/test.js | 1022 +++++++++++++++++ 11 files changed, 2311 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/vector/bool/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/vector/bool/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/bool/benchmark/benchmark.size.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/bool/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/ndarray/vector/bool/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/bool/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/bool/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/bool/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/bool/lib/main.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/bool/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/vector/bool/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/vector/bool/README.md b/lib/node_modules/@stdlib/ndarray/vector/bool/README.md new file mode 100644 index 000000000000..3a43f0fe9b36 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/bool/README.md @@ -0,0 +1,196 @@ + + +# BooleanVector + +> Create a boolean vector (i.e., a one-dimensional [ndarray][@stdlib/ndarray/ctor]). + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var BooleanVector = require( '@stdlib/ndarray/vector/bool' ); +``` + +#### BooleanVector( \[options] ) + +Returns a one-dimensional boolean [ndarray][@stdlib/ndarray/ctor]. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new BooleanVector(); +// returns + +var len = numel( arr ); +// returns 0 +``` + +The function accepts the following options: + +- **order**: specifies whether an [ndarray][@stdlib/ndarray/ctor] is `'row-major'` (C-style) or `'column-major'` (Fortran-style). Default: `'row-major'`. +- **mode**: specifies how to handle indices which exceed array dimensions (see [`ndarray`][@stdlib/ndarray/ctor]). Default: `'throw'`. +- **readonly**: boolean indicating whether an array should be **read-only**. Default: `false`. + +#### BooleanVector( length\[, options] ) + +Returns a one-dimensional boolean [ndarray][@stdlib/ndarray/ctor] having a specified `length`. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new BooleanVector( 5 ); +// returns + +var len1 = numel( arr ); +// returns 5 +``` + +#### BooleanVector( obj\[, options] ) + +Creates a one-dimensional boolean [ndarray][@stdlib/ndarray/ctor] from an array-like object or iterable. + +```javascript +var numel = require( '@stdlib/ndarray/numel' ); + +var arr = new BooleanVector( [ true, false, true ] ); +// returns + +var len1 = numel( arr ); +// returns 3 +``` + +#### BooleanVector( buffer\[, byteOffset\[, length]]\[, options] ) + +Returns a one-dimensional boolean [ndarray][@stdlib/ndarray/ctor] view of an [`ArrayBuffer`][@stdlib/array/buffer]. + +```javascript +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var numel = require( '@stdlib/ndarray/numel' ); + +var buf = new ArrayBuffer( 32 ); + +var arr1 = new BooleanVector( buf ); +// returns + +var len1 = numel( arr1 ); +// returns 32 + +var arr2 = new BooleanVector( buf, 16 ); +// returns + +var len2 = numel( arr2 ); +// returns 16 + +var arr3 = new BooleanVector( buf, 16, 1 ); +// returns + +var len3 = numel( arr3 ); +// returns 1 +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var bernoulli = require( '@stdlib/random/array/bernoulli' ); +var every = require( '@stdlib/ndarray/every' ); +var map = require( '@stdlib/ndarray/map' ); +var BooleanVector = require( '@stdlib/ndarray/vector/bool' ); + +// Create a vector containing random values: +var x = new BooleanVector( bernoulli( 10, 0.9 ) ); + +// Determine whether every element is truthy: +var v = every( x ); +console.log( v.get() ); + +// Define a function which inverts individual values: +function invert( v ) { + return !v; +} + +// Apply function: +var y = map( x, invert ); + +// Determine whether every element is truthy: +v = every( y ); +console.log( v.get() ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/vector/bool/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/vector/bool/benchmark/benchmark.js new file mode 100644 index 000000000000..1e961e595822 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/bool/benchmark/benchmark.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var BooleanVector = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new BooleanVector( 0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/vector/bool/benchmark/benchmark.size.js b/lib/node_modules/@stdlib/ndarray/vector/bool/benchmark/benchmark.size.js new file mode 100644 index 000000000000..6e796eddae94 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/bool/benchmark/benchmark.size.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var pkg = require( './../package.json' ).name; +var BooleanVector = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = new BooleanVector( len ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isndarrayLike( arr ) ) { + b.fail( 'should return an ndarray' ); + } + 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( pkg+':size='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/ndarray/vector/bool/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/vector/bool/docs/repl.txt new file mode 100644 index 000000000000..c32a86d1cd87 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/bool/docs/repl.txt @@ -0,0 +1,173 @@ + +{{alias}}( [options] ) + Returns a one-dimensional boolean ndarray. + + Parameters + ---------- + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}() + + + +{{alias}}( length[, options] ) + Returns a one-dimensional boolean ndarray having a specified length. + + Parameters + ---------- + length: integer + Number of elements. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var arr = {{alias}}( 5 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 5 + + +{{alias}}( obj[, options] ) + Creates a one-dimensional boolean ndarray from an array-like object or + iterable. + + Parameters + ---------- + obj: Object + Array-like object or iterable from which to generate an ndarray. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var v = [ true, false, true ]; + > var arr = {{alias}}( v ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 3 + + +{{alias}}( buffer[, byteOffset[, length]][, options] ) + Returns a one-dimensional boolean ndarray view of an ArrayBuffer. + + Parameters + ---------- + buffer: ArrayBuffer + Underlying ArrayBuffer. + + byteOffset: integer (optional) + Integer byte offset specifying the location of the first indexed + element. Default: 0. + + length: integer (optional) + View length. If not provided, the view spans from the byteOffset to + the end of the underlying ArrayBuffer. + + options: Object (optional) + Options. + + options.order: string (optional) + Specifies whether an array is row-major (C-style) or column-major + (Fortran-style). Default: 'row-major'. + + options.mode: string (optional) + Specifies how to handle indices which exceed array dimensions. If equal + to 'throw', an ndarray instance throws an error when an index exceeds + array dimensions. If equal to 'normalize', an ndarray instance + normalizes negative indices and throws an error when an index exceeds + array dimensions. If equal to 'wrap', an ndarray instance wraps around + indices exceeding array dimensions using modulo arithmetic. If equal to + 'clamp', an ndarray instance sets an index exceeding array dimensions + to either `0` (minimum index) or the maximum index. Default: 'throw'. + + options.readonly: boolean (optional) + Boolean indicating whether an array should be read-only. Default: false. + + Returns + ------- + out: ndarray + A one-dimensional ndarray. + + Examples + -------- + > var buf = new {{alias:@stdlib/array/buffer}}( 32 ); + > var arr = {{alias}}( buf, 0, 4 ) + + > var len = {{alias:@stdlib/ndarray/numel}}( arr ) + 4 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/vector/bool/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/vector/bool/docs/types/index.d.ts new file mode 100644 index 000000000000..eceda998c1ee --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/bool/docs/types/index.d.ts @@ -0,0 +1,377 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/* eslint-disable @typescript-eslint/unified-signatures */ + +/// + +import { Order, Mode, boolndarray } from '@stdlib/types/ndarray'; +import { Collection, AccessorArrayLike } from '@stdlib/types/array'; +import ArrayBuffer = require( '@stdlib/array/buffer' ); + +/** +* Interface describing function options. +*/ +interface Options { + /** + * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). + */ + order?: Order; + + /** + * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). + */ + mode?: Mode; + + /** + * Boolean indicating whether an array should be read-only (default: false). + */ + readonly?: boolean; +} + +/** +* Interface defining a typed vector constructor which is both "newable" and "callable". +*/ +interface BooleanVector { + /** + * Creates a boolean vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new BooleanVector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + new ( options?: Options ): boolndarray; + + /** + * Creates a boolean vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new BooleanVector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( length: number, options?: Options ): boolndarray; + + /** + * Creates a boolean vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new BooleanVector( [ true, false ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): boolndarray; + + /** + * Creates a boolean vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new BooleanVector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 32 + */ + new ( buffer: ArrayBuffer, options?: Options ): boolndarray; + + /** + * Creates a boolean vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new BooleanVector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 24 + */ + new ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): boolndarray; + + /** + * Creates a boolean vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new BooleanVector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + new ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): boolndarray; + + /** + * Creates a boolean vector (i.e., a one-dimensional ndarray). + * + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new BooleanVector(); + * // returns + * + * var len = numel( arr ); + * // returns 0 + */ + ( options?: Options ): boolndarray; + + /** + * Creates a boolean vector (i.e., a one-dimensional ndarray). + * + * @param length - vector length + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new BooleanVector( 2 ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( length: number, options?: Options ): boolndarray; + + /** + * Creates a boolean vector (i.e., a one-dimensional ndarray). + * + * @param obj - array-like object or iterable from which to generate a vector + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * + * var arr = new BooleanVector( [ true, false ] ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): boolndarray; + + /** + * Creates a boolean vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32 ); + * var arr = new BooleanVector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 32 + */ + ( buffer: ArrayBuffer, options?: Options ): boolndarray; + + /** + * Creates a boolean vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8 ); + * var arr = new BooleanVector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 24 + */ + ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): boolndarray; + + /** + * Creates a boolean vector (i.e., a one-dimensional ndarray). + * + * @param buffer - underlying ArrayBuffer + * @param byteOffset - integer byte offset specifying the location of the first vector element + * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer + * @param options - function options + * @param options.readonly - boolean indicating whether to return a read-only vector + * @param options.mode - specifies how to handle indices which exceed vector dimensions + * @param options.order - memory layout (either row-major or column-major) + * @returns one-dimensional ndarray + * + * @example + * var numel = require( '@stdlib/ndarray/numel' ); + * var ArrayBuffer = require( '@stdlib/array/buffer' ); + * + * var buf = new ArrayBuffer( 32, 8, 2 ); + * var arr = new BooleanVector( buf ); + * // returns + * + * var len = numel( arr ); + * // returns 2 + */ + ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): boolndarray; +} + +/** +* Creates a boolean vector (i.e., a one-dimensional ndarray). +* +* @param arg - length, typed array, array-like object, buffer, or iterable +* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) +* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer +* @param options - function options +* @param options.readonly - boolean indicating whether to return a read-only vector +* @param options.mode - specifies how to handle indices which exceed vector dimensions +* @param options.order - memory layout (either row-major or column-major) +* @returns one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new BooleanVector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new BooleanVector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new BooleanVector( [ true, false ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new BooleanVector( buf, 8, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +declare var ctor: BooleanVector; + + +// EXPORTS // + +export = ctor; diff --git a/lib/node_modules/@stdlib/ndarray/vector/bool/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/vector/bool/docs/types/test.ts new file mode 100644 index 000000000000..15050a15538a --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/bool/docs/types/test.ts @@ -0,0 +1,86 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import ArrayBuffer = require( '@stdlib/array/buffer' ); +import BooleanVector = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + new BooleanVector(); // $ExpectType boolndarray + new BooleanVector( {} ); // $ExpectType boolndarray + + new BooleanVector( 10 ); // $ExpectType boolndarray + new BooleanVector( 10, {} ); // $ExpectType boolndarray + + new BooleanVector( [ 1, 2, 3 ] ); // $ExpectType boolndarray + new BooleanVector( [ 1, 2, 3 ], {} ); // $ExpectType boolndarray + + new BooleanVector( new ArrayBuffer( 10 ) ); // $ExpectType boolndarray + new BooleanVector( new ArrayBuffer( 10 ), {} ); // $ExpectType boolndarray + + new BooleanVector( new ArrayBuffer( 10 ), 8 ); // $ExpectType boolndarray + new BooleanVector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType boolndarray + + new BooleanVector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType boolndarray + new BooleanVector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType boolndarray + + const vector = BooleanVector; + vector(); // $ExpectType boolndarray + vector( {} ); // $ExpectType boolndarray + + vector( 10 ); // $ExpectType boolndarray + vector( 10, {} ); // $ExpectType boolndarray + + vector( [ 1, 2, 3 ] ); // $ExpectType boolndarray + vector( [ 1, 2, 3 ], {} ); // $ExpectType boolndarray + + vector( new ArrayBuffer( 10 ) ); // $ExpectType boolndarray + vector( new ArrayBuffer( 10 ), {} ); // $ExpectType boolndarray + + vector( new ArrayBuffer( 10 ), 8 ); // $ExpectType boolndarray + vector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType boolndarray + + vector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType boolndarray + vector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType boolndarray +} + +// The compiler throws an error if the function is provided a first argument which is not a number, array-like object, iterable, or options object... +{ + new BooleanVector( true ); // $ExpectError + new BooleanVector( false ); // $ExpectError + new BooleanVector( null ); // $ExpectError + new BooleanVector( ( x: number ): number => x ); // $ExpectError + + const vector = BooleanVector; + vector( true ); // $ExpectError + vector( false ); // $ExpectError + vector( null ); // $ExpectError + vector( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const buf = new ArrayBuffer( 32 ); + new BooleanVector( buf, 8, 2, {}, {} ); // $ExpectError + + const vector = BooleanVector; + vector( buf, 8, 2, {}, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/bool/examples/index.js b/lib/node_modules/@stdlib/ndarray/vector/bool/examples/index.js new file mode 100644 index 000000000000..f36ef2a16f1e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/bool/examples/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var bernoulli = require( '@stdlib/random/array/bernoulli' ); +var every = require( '@stdlib/ndarray/every' ); +var map = require( '@stdlib/ndarray/map' ); +var BooleanVector = require( './../lib' ); + +// Create a vector containing random values: +var x = new BooleanVector( bernoulli( 10, 0.9 ) ); + +// Determine whether every element is truthy: +var v = every( x ); +console.log( v.get() ); + +// Define a function which inverts individual values: +function invert( v ) { + return !v; +} + +// Apply function: +var y = map( x, invert ); + +// Determine whether every element is truthy: +v = every( y ); +console.log( v.get() ); diff --git a/lib/node_modules/@stdlib/ndarray/vector/bool/lib/index.js b/lib/node_modules/@stdlib/ndarray/vector/bool/lib/index.js new file mode 100644 index 000000000000..72116e4706eb --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/bool/lib/index.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Create a boolean vector (i.e., a one-dimensional ndarray). +* +* @module @stdlib/ndarray/vector/bool +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var BooleanVector = require( '@stdlib/ndarray/vector/bool' ); +* +* var v = new BooleanVector(); +* // returns +* +* var len = numel( v ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var BooleanVector = require( '@stdlib/ndarray/vector/bool' ); +* +* var v = new BooleanVector( 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var BooleanVector = require( '@stdlib/ndarray/vector/bool' ); +* +* var v = new BooleanVector( [ true, false ] ); +* // returns +* +* var len = numel( v ); +* // returns 2 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var BooleanVector = require( '@stdlib/ndarray/vector/bool' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new BooleanVector( buf ); +* // returns +* +* var len = numel( v ); +* // returns 32 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var BooleanVector = require( '@stdlib/ndarray/vector/bool' ); +* +* var buf = new ArrayBuffer( 32 ); +* var v = new BooleanVector( buf, 16 ); +* // returns +* +* var len = numel( v ); +* // returns 16 +* +* @example +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* var numel = require( '@stdlib/ndarray/numel' ); +* var BooleanVector = require( '@stdlib/ndarray/vector/bool' ); +* +* var buf = new ArrayBuffer( 64 ); +* var v = new BooleanVector( buf, 16, 2 ); +* // returns +* +* var len = numel( v ); +* // returns 2 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/vector/bool/lib/main.js b/lib/node_modules/@stdlib/ndarray/vector/bool/lib/main.js new file mode 100644 index 000000000000..388156ef0e2e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/bool/lib/main.js @@ -0,0 +1,109 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 factory = require( '@stdlib/ndarray/vector/ctor' ).factory; + + +// MAIN // + +/** +* Returns a boolean vector (i.e., a one-dimensional ndarray). +* +* @name BooleanVector +* @type {Function} +* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable +* @param {NonNegativeInteger} [byteOffset=0] - byte offset +* @param {NonNegativeInteger} [length] - view length +* @param {Options} [options] - function options +* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only vector +* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed vector dimensions +* @param {string} [options.order='row-major'] - memory layout (either row-major or column-major) +* @throws {TypeError} first argument must be either a length, typed array, array-like object, buffer, iterable, or options object +* @throws {TypeError} must provide valid options +* @returns {ndarray} one-dimensional ndarray +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new BooleanVector(); +* // returns +* +* var len = numel( arr ); +* // returns 0 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new BooleanVector( 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* +* var arr = new BooleanVector( [ true, false ] ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new BooleanVector( buf ); +* // returns +* +* var len = numel( arr ); +* // returns 32 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = new BooleanVector( buf, 16 ); +* // returns +* +* var len = numel( arr ); +* // returns 16 +* +* @example +* var numel = require( '@stdlib/ndarray/numel' ); +* var ArrayBuffer = require( '@stdlib/array/buffer' ); +* +* var buf = new ArrayBuffer( 64 ); +* var arr = new BooleanVector( buf, 16, 2 ); +* // returns +* +* var len = numel( arr ); +* // returns 2 +*/ +var BooleanVector = factory( 'bool' ); + + +// EXPORTS // + +module.exports = BooleanVector; diff --git a/lib/node_modules/@stdlib/ndarray/vector/bool/package.json b/lib/node_modules/@stdlib/ndarray/vector/bool/package.json new file mode 100644 index 000000000000..78ed1acbf30d --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/bool/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/ndarray/vector/bool", + "version": "0.0.0", + "description": "Create a boolean vector (i.e., a one-dimensional ndarray).", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdtypes", + "types", + "data", + "structure", + "vector", + "vec", + "ndarray", + "constructor", + "ctor", + "bool", + "boolean" + ] +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/bool/test/test.js b/lib/node_modules/@stdlib/ndarray/vector/bool/test/test.js new file mode 100644 index 000000000000..f7b5677c2e29 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/bool/test/test.js @@ -0,0 +1,1022 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* eslint-disable no-new */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isndarrayLikeWithDataType = require( '@stdlib/assert/is-ndarray-like-with-data-type' ); +var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); +var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' ); +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var Uint8Array = require( '@stdlib/array/float64' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var array2buffer = require( '@stdlib/buffer/from-array' ); +var BooleanVector = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof BooleanVector, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new BooleanVector( value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new BooleanVector( value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new BooleanVector( value, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new BooleanVector( value, 0, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new BooleanVector( value, 0, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (byteoffset, length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new BooleanVector( value, 0, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new BooleanVector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new BooleanVector( new ArrayBuffer( 8 ), value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new BooleanVector( new ArrayBuffer( 8 ), value, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid byte offset argument (length, options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new BooleanVector( new ArrayBuffer( 8 ), value, 1, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new BooleanVector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid length argument (options)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5, + 3.14, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + new BooleanVector( new ArrayBuffer( 8 ), 0, value, {} ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (length)', function test( t ) { + var values; + var i; + + 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() { + new BooleanVector( 10, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { + var values; + var i; + + 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() { + new BooleanVector( [], value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new BooleanVector( new ArrayBuffer( 8 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + 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() { + new BooleanVector( new ArrayBuffer( 8 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset, length)', function test( t ) { + var values; + var i; + + 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() { + new BooleanVector( new ArrayBuffer( 8 ), 0, 1, value ); + }; + } +}); + +tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'ROW', + 'row', + 'col-major', + 'col', + 'major', + 'minor', + null + ]; + + 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() { + new BooleanVector({ + 'order': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'THROW', + 5, + null, + true, + false, + [], + {} + ]; + + 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() { + new BooleanVector({ + 'mode': value + }); + }; + } +}); + +tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + 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() { + new BooleanVector({ + 'readonly': value + }); + }; + } +}); + +tape( 'the function returns a one-dimensional ndarray', function test( t ) { + var arr; + + arr = new BooleanVector(); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + arr = new BooleanVector( {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (length)', function test( t ) { + var arr; + + arr = new BooleanVector( 10 ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + arr = new BooleanVector( 10, {} ); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (array)', function test( t ) { + var arr; + var out; + + arr = [ true, false, true, false ]; + + out = new BooleanVector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'bool' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( getData( out ), new BooleanArray( arr ) ), true, 'returns expected value' ); + + out = new BooleanVector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'bool' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( getData( out ), new BooleanArray( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (typed array)', function test( t ) { + var arr; + var out; + + arr = new Uint8Array( [ 1, 2, 3, 4 ] ); + + out = new BooleanVector( arr ); + t.strictEqual( isndarrayLikeWithDataType( out, 'bool' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( getData( out ), new BooleanArray( arr ) ), true, 'returns expected value' ); + + out = new BooleanVector( arr, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'bool' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( getData( out ), new BooleanArray( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (buffer)', function test( t ) { + var arr; + var out; + var buf; + + arr = [ 1, 0, 0, 1 ]; + buf = array2buffer( arr ); + + out = new BooleanVector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'bool' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( getData( out ), new BooleanArray( arr ) ), true, 'returns expected value' ); + + out = new BooleanVector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'bool' ), true, 'returns expected value' ); + t.strictEqual( out.length, 4, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( getData( out ), new BooleanArray( arr ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 8 ); + + out = new BooleanVector( buf ); + t.strictEqual( isndarrayLikeWithDataType( out, 'bool' ), true, 'returns expected value' ); + t.strictEqual( out.length, 8, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( getData( out ), new BooleanArray( buf ) ), true, 'returns expected value' ); + + out = new BooleanVector( buf, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'bool' ), true, 'returns expected value' ); + t.strictEqual( out.length, 8, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( getData( out ), new BooleanArray( buf ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new BooleanVector( buf, 8 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'bool' ), true, 'returns expected value' ); + t.strictEqual( out.length, 24, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( getData( out ), new BooleanArray( buf, 8 ) ), true, 'returns expected value' ); + + out = new BooleanVector( buf, 8, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'bool' ), true, 'returns expected value' ); + t.strictEqual( out.length, 24, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( getData( out ), new BooleanArray( buf, 8 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a one-dimensional ndarray (arraybuffer, byteoffset, length)', function test( t ) { + var buf; + var out; + + buf = new ArrayBuffer( 32 ); + + out = new BooleanVector( buf, 8, 2 ); + t.strictEqual( isndarrayLikeWithDataType( out, 'bool' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( getData( out ), new BooleanArray( buf, 8, 2 ) ), true, 'returns expected value' ); + + out = new BooleanVector( buf, 8, 2, {} ); + t.strictEqual( isndarrayLikeWithDataType( out, 'bool' ), true, 'returns expected value' ); + t.strictEqual( out.length, 2, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( getData( out ), new BooleanArray( buf, 8, 2 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout', function test( t ) { + var arr; + + arr = new BooleanVector({ + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new BooleanVector({ + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (length)', function test( t ) { + var arr; + + arr = new BooleanVector( 10, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new BooleanVector( 10, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (array)', function test( t ) { + var arr; + + arr = new BooleanVector( [ true, false, true, false ], { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new BooleanVector( [ true, false, true, false ], { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer)', function test( t ) { + var arr; + + arr = new BooleanVector( new ArrayBuffer( 32 ), { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new BooleanVector( new ArrayBuffer( 32 ), { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new BooleanVector( new ArrayBuffer( 32 ), 8, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new BooleanVector( new ArrayBuffer( 32 ), 8, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new BooleanVector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'row-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'row-major', 'returns expected value' ); + + arr = new BooleanVector( new ArrayBuffer( 32 ), 8, 2, { + 'order': 'column-major' + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( arr.order, 'column-major', 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays', function test( t ) { + var arr; + + arr = new BooleanVector({ + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (length)', function test( t ) { + var arr; + + arr = new BooleanVector( 10, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (array)', function test( t ) { + var arr; + + arr = new BooleanVector( [ true, false, true, false ], { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new BooleanVector( new ArrayBuffer( 32 ), { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new BooleanVector( new ArrayBuffer( 32 ), 8, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new BooleanVector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': true + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays', function test( t ) { + var arr; + + arr = new BooleanVector({ + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (length)', function test( t ) { + var arr; + + arr = new BooleanVector( 10, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 10, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (array)', function test( t ) { + var arr; + + arr = new BooleanVector( [ true, false, true, false ], { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 4, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer)', function test( t ) { + var arr; + + arr = new BooleanVector( new ArrayBuffer( 32 ), { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 32, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset)', function test( t ) { + var arr; + + arr = new BooleanVector( new ArrayBuffer( 32 ), 8, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 24, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset, length)', function test( t ) { + var arr; + + arr = new BooleanVector( new ArrayBuffer( 32 ), 8, 2, { + 'readonly': false + }); + t.strictEqual( isndarrayLikeWithDataType( arr, 'bool' ), true, 'returns expected value' ); + t.strictEqual( arr.length, 2, 'returns expected value' ); + t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); + + t.end(); +}); From 1ab9f58bcd109f19afd9ab08212d69bfe9d32bbe Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 02:02:02 -0700 Subject: [PATCH 48/60] feat: add `ndarray/vector` namespace --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - 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: passed - task: lint_license_headers status: passed --- --- .../@stdlib/ndarray/vector/README.md | 105 +++++++++++++ .../ndarray/vector/docs/types/index.d.ts | 43 ++++++ .../@stdlib/ndarray/vector/docs/types/test.ts | 29 ++++ .../@stdlib/ndarray/vector/examples/index.js | 24 +++ .../@stdlib/ndarray/vector/lib/index.js | 141 ++++++++++++++++++ .../@stdlib/ndarray/vector/package.json | 60 ++++++++ .../@stdlib/ndarray/vector/test/test.js | 40 +++++ 7 files changed, 442 insertions(+) create mode 100644 lib/node_modules/@stdlib/ndarray/vector/README.md create mode 100644 lib/node_modules/@stdlib/ndarray/vector/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/ndarray/vector/examples/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/lib/index.js create mode 100644 lib/node_modules/@stdlib/ndarray/vector/package.json create mode 100644 lib/node_modules/@stdlib/ndarray/vector/test/test.js diff --git a/lib/node_modules/@stdlib/ndarray/vector/README.md b/lib/node_modules/@stdlib/ndarray/vector/README.md new file mode 100644 index 000000000000..7d07b04d2511 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/README.md @@ -0,0 +1,105 @@ + + +# Vector + +> Vector constructors and associated utilities. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var ns = require( '@stdlib/ndarray/vector' ); +``` + +#### ns + +Namespace containing ndarray vector constructors and associated utilities. + +```javascript +var o = ns; +// returns {...} +``` + +The namespace exports the following: + + + + + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + + + +```javascript +var objectKeys = require( '@stdlib/utils/keys' ); +var ns = require( '@stdlib/ndarray/vector' ); + +console.log( objectKeys( ns ) ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/vector/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/vector/docs/types/index.d.ts new file mode 100644 index 000000000000..6ce1e5da08e8 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/docs/types/index.d.ts @@ -0,0 +1,43 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +// TypeScript Version: 4.1 + +/* eslint-disable max-lines */ + +import Float64Vector = require( '@stdlib/ndarray/vector/float64' ); + +/** +* Interface describing a namespace. +*/ +interface Namespace { + /** + * TODO + */ + Float64Vector: typeof Float64Vector; +} + +/** +* Vector constructors and associated utilities. +*/ +declare var ns: Namespace; + + +// EXPORTS // + +export = ns; diff --git a/lib/node_modules/@stdlib/ndarray/vector/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/vector/docs/types/test.ts new file mode 100644 index 000000000000..1a38cb7de9b0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/docs/types/test.ts @@ -0,0 +1,29 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +/* eslint-disable @typescript-eslint/no-unused-expressions */ + +import ns = require( './index' ); + + +// TESTS // + +// The exported value is the expected interface... +{ + ns; // $ExpectType Namespace +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/examples/index.js b/lib/node_modules/@stdlib/ndarray/vector/examples/index.js new file mode 100644 index 000000000000..f5349d26ce9b --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/examples/index.js @@ -0,0 +1,24 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var objectKeys = require( '@stdlib/utils/keys' ); +var ns = require( './../lib' ); + +console.log( objectKeys( ns ) ); diff --git a/lib/node_modules/@stdlib/ndarray/vector/lib/index.js b/lib/node_modules/@stdlib/ndarray/vector/lib/index.js new file mode 100644 index 000000000000..5a557233158c --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/lib/index.js @@ -0,0 +1,141 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/* +* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); + + +// MAIN // + +/** +* Namespace. +* +* @namespace ns +*/ +var ns = {}; + +/** +* @name BooleanVector +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/vector/bool} +*/ +setReadOnly( ns, 'BooleanVector', require( '@stdlib/ndarray/vector/bool' ) ); + +/** +* @name vector +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/vector/ctor} +*/ +setReadOnly( ns, 'vector', require( '@stdlib/ndarray/vector/ctor' ) ); + +/** +* @name Float32Vector +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/vector/float32} +*/ +setReadOnly( ns, 'Float32Vector', require( '@stdlib/ndarray/vector/float32' ) ); + +/** +* @name Float64Vector +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/vector/float64} +*/ +setReadOnly( ns, 'Float64Vector', require( '@stdlib/ndarray/vector/float64' ) ); + +/** +* @name Int8Vector +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/vector/int8} +*/ +setReadOnly( ns, 'Int8Vector', require( '@stdlib/ndarray/vector/int8' ) ); + +/** +* @name Int16Vector +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/vector/int16} +*/ +setReadOnly( ns, 'Int16Vector', require( '@stdlib/ndarray/vector/int16' ) ); + +/** +* @name Int32Vector +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/vector/int32} +*/ +setReadOnly( ns, 'Int32Vector', require( '@stdlib/ndarray/vector/int32' ) ); + +/** +* @name Uint8Vector +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/vector/uint8} +*/ +setReadOnly( ns, 'Uint8Vector', require( '@stdlib/ndarray/vector/uint8' ) ); + +/** +* @name Uint8ClampedVector +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/vector/uint8c} +*/ +setReadOnly( ns, 'Uint8ClampedVector', require( '@stdlib/ndarray/vector/uint8c' ) ); + +/** +* @name Uint16Vector +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/vector/uint16} +*/ +setReadOnly( ns, 'Uint16Vector', require( '@stdlib/ndarray/vector/uint16' ) ); + +/** +* @name Uint32Vector +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/vector/uint32} +*/ +setReadOnly( ns, 'Uint32Vector', require( '@stdlib/ndarray/vector/uint32' ) ); + + +// EXPORTS // + +module.exports = ns; diff --git a/lib/node_modules/@stdlib/ndarray/vector/package.json b/lib/node_modules/@stdlib/ndarray/vector/package.json new file mode 100644 index 000000000000..70ff9cbeac6f --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/package.json @@ -0,0 +1,60 @@ +{ + "name": "@stdlib/ndarray/vector", + "version": "0.0.0", + "description": "Vector constructors and associated utilities.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "lib/index.js", + "directories": { + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "ndarray", + "vector", + "vec", + "constructor", + "ctor", + "array", + "namespace" + ] +} diff --git a/lib/node_modules/@stdlib/ndarray/vector/test/test.js b/lib/node_modules/@stdlib/ndarray/vector/test/test.js new file mode 100644 index 000000000000..d1e6eeb4039e --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/vector/test/test.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 objectKeys = require( '@stdlib/utils/keys' ); +var ns = require( './../lib' ); + + +// TESTS // + +tape( 'main export is an object', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ns, 'object', 'main export is an object' ); + t.end(); +}); + +tape( 'the exported object contains key-value pairs', function test( t ) { + var keys = objectKeys( ns ); + t.equal( keys.length > 0, true, 'returns expected value' ); + t.end(); +}); From 2349a6edf849f8f7093a77bbdeb2fdd7d9955f89 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 02:03:05 -0700 Subject: [PATCH 49/60] feat: add `vector` to namespace --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/ndarray/lib/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/lib/index.js b/lib/node_modules/@stdlib/ndarray/lib/index.js index 3f2a60de18a4..54a44f72287f 100644 --- a/lib/node_modules/@stdlib/ndarray/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/lib/index.js @@ -576,6 +576,15 @@ setReadOnly( ns, 'ndarray2fancy', require( '@stdlib/ndarray/to-fancy' ) ); */ setReadOnly( ns, 'ndarray2json', require( '@stdlib/ndarray/to-json' ) ); +/** +* @name vector +* @memberof ns +* @readonly +* @type {Namespace} +* @see {@link module:@stdlib/ndarray/vector} +*/ +setReadOnly( ns, 'vector', require( '@stdlib/ndarray/vector' ) ); + /** * @name zeros * @memberof ns From 54dc71e0ff4a2b5661d48a1bdee584507f66373f Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 02:04:05 -0700 Subject: [PATCH 50/60] feat: add `every` and `includes` to namespace --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/ndarray/lib/index.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/node_modules/@stdlib/ndarray/lib/index.js b/lib/node_modules/@stdlib/ndarray/lib/index.js index 54a44f72287f..b7fa2ed305f0 100644 --- a/lib/node_modules/@stdlib/ndarray/lib/index.js +++ b/lib/node_modules/@stdlib/ndarray/lib/index.js @@ -162,6 +162,15 @@ setReadOnly( ns, 'empty', require( '@stdlib/ndarray/empty' ) ); */ setReadOnly( ns, 'emptyLike', require( '@stdlib/ndarray/empty-like' ) ); +/** +* @name every +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/every} +*/ +setReadOnly( ns, 'every', require( '@stdlib/ndarray/every' ) ); + /** * @name FancyArray * @memberof ns @@ -243,6 +252,15 @@ setReadOnly( ns, 'forEach', require( '@stdlib/ndarray/for-each' ) ); */ setReadOnly( ns, 'scalar2ndarray', require( '@stdlib/ndarray/from-scalar' ) ); +/** +* @name includes +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/ndarray/includes} +*/ +setReadOnly( ns, 'includes', require( '@stdlib/ndarray/includes' ) ); + /** * @name ind2sub * @memberof ns From 468d6f7247367a32f73738a0cf7dfda28126eac2 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 02:13:24 -0700 Subject: [PATCH 51/60] bench: fix assertion --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/ndarray/casting-modes/benchmark/benchmark.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/ndarray/casting-modes/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/casting-modes/benchmark/benchmark.js index 8129ed5c0896..040f605bd846 100644 --- a/lib/node_modules/@stdlib/ndarray/casting-modes/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/ndarray/casting-modes/benchmark/benchmark.js @@ -35,8 +35,8 @@ bench( pkg, function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = modes(); - if ( out.length !== 5 ) { - b.fail( 'should return an array of length 5' ); + if ( out.length > 1 ) { + b.fail( 'should return an array' ); } } b.toc(); From d002f3ae7d4f785a0d0d8c4c9f3b383776deea15 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 02:15:29 -0700 Subject: [PATCH 52/60] bench: fix condition --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/ndarray/casting-modes/benchmark/benchmark.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/ndarray/casting-modes/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/casting-modes/benchmark/benchmark.js index 040f605bd846..0ca72a68f317 100644 --- a/lib/node_modules/@stdlib/ndarray/casting-modes/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/ndarray/casting-modes/benchmark/benchmark.js @@ -35,7 +35,7 @@ bench( pkg, function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { out = modes(); - if ( out.length > 1 ) { + if ( out.length < 2 ) { b.fail( 'should return an array' ); } } From a98ddb6a05fd9c1c383857ee0abc3ed4efbac8d2 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 02:16:02 -0700 Subject: [PATCH 53/60] test: fix require path --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/array/base/with/test/test.assign.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/array/base/with/test/test.assign.js b/lib/node_modules/@stdlib/array/base/with/test/test.assign.js index b165d6a25ac9..84e8af60f0b3 100644 --- a/lib/node_modules/@stdlib/array/base/with/test/test.assign.js +++ b/lib/node_modules/@stdlib/array/base/with/test/test.assign.js @@ -28,7 +28,7 @@ var BooleanArray = require( '@stdlib/array/bool' ); var AccessorArray = require( '@stdlib/array/base/accessor' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' ); +var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); var zeros = require( '@stdlib/array/zeros' ); var arrayWith = require( './../lib/assign.js' ); @@ -367,21 +367,21 @@ tape( 'the function copies elements to another array and sets an element at a sp actual = arrayWith( x, 0, true, out, 1, 0 ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); out = new BooleanArray( x.length*2 ); expected = new BooleanArray( [ 0, 0, 1, 0, 1, 0, 1, 0 ] ); actual = arrayWith( x, 1, true, out, 2, 0 ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); out = new BooleanArray( x.length*2 ); expected = new BooleanArray( [ 0, 1, 0, 0, 0, 0, 0, 0 ] ); actual = arrayWith( x, 2, false, out, -2, out.length-1 ); t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); t.end(); }); From a75bd09ef2db7eb2761ebc1e776ebcfa123d7493 Mon Sep 17 00:00:00 2001 From: zhanggy Date: Mon, 19 May 2025 20:04:24 +0800 Subject: [PATCH 54/60] chore: fix EditorConfig lint errors PR-URL: https://github.com/stdlib-js/stdlib/pull/7029 Closes: https://github.com/stdlib-js/stdlib/issues/7018 Reviewed-by: Philipp Burckhardt --- lib/node_modules/@stdlib/blas/sswap/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/sswap/README.md b/lib/node_modules/@stdlib/blas/sswap/README.md index 441d4adebc1c..a14e030fb944 100644 --- a/lib/node_modules/@stdlib/blas/sswap/README.md +++ b/lib/node_modules/@stdlib/blas/sswap/README.md @@ -99,7 +99,7 @@ v2 = y.get( 0, 0 ); - Both input [`ndarrays`][@stdlib/ndarray/ctor] must have the same shape. - Negative indices are resolved relative to the last [`ndarray`][@stdlib/ndarray/ctor] dimension, with the last dimension corresponding to `-1`. -- For multi-dimensional [`ndarrays`][@stdlib/ndarray/ctor], batched computation effectively means swapping all of `x` with all of `y`; however, the choice of `dim` will significantly affect performance. For best performance, specify a `dim` which best aligns with the [memory layout][@stdlib/ndarray/orders] of provided [`ndarrays`][@stdlib/ndarray/ctor]. +- For multi-dimensional [`ndarrays`][@stdlib/ndarray/ctor], batched computation effectively means swapping all of `x` with all of `y`; however, the choice of `dim` will significantly affect performance. For best performance, specify a `dim` which best aligns with the [memory layout][@stdlib/ndarray/orders] of provided [`ndarrays`][@stdlib/ndarray/ctor]. - `sswap()` provides a higher-level interface to the [BLAS][blas] level 1 function [`sswap`][@stdlib/blas/base/sswap]. From a8d1b40510aee43e3ce0e6e663ee79f149429390 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 19 May 2025 12:06:33 -0700 Subject: [PATCH 55/60] test: fix require path --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/ndarray/vector/bool/test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/ndarray/vector/bool/test/test.js b/lib/node_modules/@stdlib/ndarray/vector/bool/test/test.js index f7b5677c2e29..93eff10eddb4 100644 --- a/lib/node_modules/@stdlib/ndarray/vector/bool/test/test.js +++ b/lib/node_modules/@stdlib/ndarray/vector/bool/test/test.js @@ -27,7 +27,7 @@ var isndarrayLikeWithDataType = require( '@stdlib/assert/is-ndarray-like-with-da var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); var isReadOnly = require( '@stdlib/ndarray/base/assert/is-read-only' ); var ArrayBuffer = require( '@stdlib/array/buffer' ); -var Uint8Array = require( '@stdlib/array/float64' ); +var Uint8Array = require( '@stdlib/array/uint8' ); var BooleanArray = require( '@stdlib/array/bool' ); var getData = require( '@stdlib/ndarray/data-buffer' ); var array2buffer = require( '@stdlib/buffer/from-array' ); From 02109aa28a0c48a2d6b92de3423614204a39431e Mon Sep 17 00:00:00 2001 From: Sachin Raj <120590207+schnrj@users.noreply.github.com> Date: Tue, 20 May 2025 02:27:57 +0530 Subject: [PATCH 56/60] chore: address commit comments for commit `fbffea0` PR-URL: https://github.com/stdlib-js/stdlib/pull/7038 Closes: https://github.com/stdlib-js/stdlib/issues/7030 Co-authored-by: Philipp Burckhardt Reviewed-by: Philipp Burckhardt Signed-off-by: Philipp Burckhardt --- .../@stdlib/array/base/assert/any-is-entry/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/base/assert/any-is-entry/README.md b/lib/node_modules/@stdlib/array/base/assert/any-is-entry/README.md index 02c3bae3e029..e83549b4cd7a 100644 --- a/lib/node_modules/@stdlib/array/base/assert/any-is-entry/README.md +++ b/lib/node_modules/@stdlib/array/base/assert/any-is-entry/README.md @@ -40,7 +40,7 @@ limitations under the License. var anyIsEntry = require( '@stdlib/array/base/assert/any-is-entry' ); ``` -#### anyIsEntry( arr, property ) +#### anyIsEntry( arr, property, value ) Tests whether at least one element in a provided array has a specified own property key-value pair. From 576b85bb15cbf83346f8f100e48acf573ac1fcfe Mon Sep 17 00:00:00 2001 From: Uday Kakade <141299403+udaykakade25@users.noreply.github.com> Date: Tue, 20 May 2025 03:27:39 +0530 Subject: [PATCH 57/60] chore: fix C lint errors PR-URL: https://github.com/stdlib-js/stdlib/pull/7033 Closes: https://github.com/stdlib-js/stdlib/issues/7032 Reviewed-by: Philipp Burckhardt --- .../@stdlib/blas/base/dger/include/stdlib/blas/base/dger.h | 2 +- lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dger/include/stdlib/blas/base/dger.h b/lib/node_modules/@stdlib/blas/base/dger/include/stdlib/blas/base/dger.h index 616c8c57a9e3..1b774738e5c5 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/include/stdlib/blas/base/dger.h +++ b/lib/node_modules/@stdlib/blas/base/dger/include/stdlib/blas/base/dger.h @@ -34,7 +34,7 @@ extern "C" { /** * Performs the rank 1 operation `A = alpha*x*y^T + A`, where `alpha` is a scalar, `x` is an `M` element vector, `y` is an `N` element vector, and `A` is an `M`-by-`N` matrix. */ -void API_SUFFIX(c_dger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ); +void API_SUFFIX(c_dger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c b/lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c index 9f5a8d88af0e..0be9e8b58350 100644 --- a/lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c +++ b/lib/node_modules/@stdlib/blas/base/dger/src/dger_f.c @@ -35,7 +35,7 @@ * @param A matrix of coefficients * @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) */ -void API_SUFFIX(c_dger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const double alpha, double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { +void API_SUFFIX(c_dger)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const double *Y, const CBLAS_INT strideY, double *A, const CBLAS_INT LDA ) { extern int RowMajorStrg; // global flag RowMajorStrg = 0; From 57b0e7428d3e8f21640e9fe6462a33c2b0881c48 Mon Sep 17 00:00:00 2001 From: Neeraj Pathak Date: Tue, 20 May 2025 03:31:03 +0530 Subject: [PATCH 58/60] feat: add C implementation for `math/base/special/minmax` PR-URL: https://github.com/stdlib-js/stdlib/pull/6296 Closes: https://github.com/stdlib-js/stdlib/issues/2106 Ref: https://github.com/stdlib-js/stdlib/issues/649 Co-authored-by: Karan Anand Reviewed-by: Karan Anand Reviewed-by: Philipp Burckhardt Reviewed-by: Gunj Joshi Signed-off-by: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> --- .../math/base/special/minmax/README.md | 94 ++++++++++ .../special/minmax/benchmark/benchmark.js | 1 + .../minmax/benchmark/benchmark.native.js | 63 +++++++ .../minmax/benchmark/c/native/Makefile | 146 +++++++++++++++ .../minmax/benchmark/c/native/benchmark.c | 139 ++++++++++++++ .../math/base/special/minmax/binding.gyp | 170 ++++++++++++++++++ .../base/special/minmax/examples/c/Makefile | 146 +++++++++++++++ .../base/special/minmax/examples/c/example.c | 33 ++++ .../math/base/special/minmax/include.gypi | 53 ++++++ .../include/stdlib/math/base/special/minmax.h | 38 ++++ .../math/base/special/minmax/lib/native.js | 58 ++++++ .../math/base/special/minmax/manifest.json | 78 ++++++++ .../math/base/special/minmax/package.json | 3 + .../math/base/special/minmax/src/Makefile | 70 ++++++++ .../math/base/special/minmax/src/addon.c | 42 +++++ .../math/base/special/minmax/src/main.c | 63 +++++++ .../base/special/minmax/test/test.assign.js | 24 +-- .../base/special/minmax/test/test.main.js | 8 +- .../base/special/minmax/test/test.native.js | 129 +++++++++++++ 19 files changed, 1342 insertions(+), 16 deletions(-) create mode 100644 lib/node_modules/@stdlib/math/base/special/minmax/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/minmax/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/minmax/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/minmax/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/minmax/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/minmax/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/minmax/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/minmax/include/stdlib/math/base/special/minmax.h create mode 100644 lib/node_modules/@stdlib/math/base/special/minmax/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/minmax/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/minmax/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/minmax/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/minmax/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/minmax/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/README.md b/lib/node_modules/@stdlib/math/base/special/minmax/README.md index 9f4b1b904a3f..aa3f93986f21 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmax/README.md +++ b/lib/node_modules/@stdlib/math/base/special/minmax/README.md @@ -119,6 +119,100 @@ for ( i = 0; i < 100; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/minmax.h" +``` + +#### stdlib_base_minmax( x, y, &min, &max ) + +Evaluates the minimum and maximum values in a single pass. + +```c +double x = 3.14; +double y = 2.71; + +double min; +double max; +stdlib_base_minmax( x, y, &min, &max ); +``` + +The function accepts the following arguments: + +- **x**: `[in] double` first number. +- **y**: `[in] double` second number. +- **min**: `[out] double` destination for the minimum value. +- **max**: `[out] double` destination for the maximum value. + +```c +void stdlib_base_minmax( const double x, const double y, double* min, double* max ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/minmax.h" +#include + +int main( void ) { + const double x[] = { 1.0, 0.45, -0.89, 0.0 / 0.0, -0.78, -0.22, 0.66, 0.11, -0.55, 0.0 }; + const double y[] = { -0.22, 0.66, 0.0, -0.55, 0.33, 1.0, 0.0 / 0.0, 0.11, 0.45, -0.78 }; + + double min; + double max; + int i; + for ( i = 0; i < 10; i++ ) { + stdlib_base_minmax( x[ i ], y[ i ], &min, &max ); + printf( "x: %lf, y: %lf => min: %lf, max: %lf\n", x[ i ], y[ i ], min, max ); + } +} +``` + +
+ + + +
+ + +
diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/minmax/benchmark/benchmark.js index e7836730d693..315b1ccc3ef9 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmax/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/minmax/benchmark/benchmark.js @@ -92,6 +92,7 @@ bench( pkg+'::min,max', function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { + // eslint-disable-next-line max-len z = [ min( x[ i%x.length ], y[ i%y.length ] ), max( x[ i%x.length ], y[ i%y.length ] ) ]; if ( z.length !== 2 ) { b.fail( 'should have expected length' ); diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/minmax/benchmark/benchmark.native.js new file mode 100644 index 000000000000..6e6dff037709 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmax/benchmark/benchmark.native.js @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isFloat64Array = require( '@stdlib/assert/is-float64array' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var minmax = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( minmax instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var x; + var y; + var z; + var i; + + x = uniform( 100, -500.0, 500.0 ); + y = uniform( 100, -500.0, 500.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = minmax( x[ i%x.length ], y[ i%y.length ] ); + if ( z.length !== 2 ) { + b.fail( 'should have expected length' ); + } + } + b.toc(); + if ( !isFloat64Array( z ) ) { + b.fail( 'should return a Float64Array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/minmax/benchmark/c/native/Makefile new file mode 100644 index 000000000000..a4bd7b38fd74 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmax/benchmark/c/native/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/minmax/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..bea002d07576 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmax/benchmark/c/native/benchmark.c @@ -0,0 +1,139 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +#include "stdlib/math/base/special/minmax.h" +#include +#include +#include +#include +#include + +#define NAME "minmax" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec / 1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double x[ 100 ]; + double y[ 100 ]; + double elapsed; + double min; + double max; + double t; + int i; + + for( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0*rand_double() ) - 500.0; + y[ i ] = ( 1000.0*rand_double() ) - 500.0; + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + stdlib_base_minmax( x[ i%100 ], y[ i%100 ], &min, &max ); + if ( max != max || min != min ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( max != max || min != min ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::native::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/binding.gyp b/lib/node_modules/@stdlib/math/base/special/minmax/binding.gyp new file mode 100644 index 000000000000..68a1ca11d160 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmax/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2025 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. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/minmax/examples/c/Makefile new file mode 100644 index 000000000000..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmax/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/minmax/examples/c/example.c new file mode 100644 index 000000000000..b104cbded7e0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmax/examples/c/example.c @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +#include "stdlib/math/base/special/minmax.h" +#include + +int main( void ) { + const double x[] = { 1.0, 0.45, -0.89, 0.0 / 0.0, -0.78, -0.22, 0.66, 0.11, -0.55, 0.0 }; + const double y[] = { -0.22, 0.66, 0.0, -0.55, 0.33, 1.0, 0.0 / 0.0, 0.11, 0.45, -0.78 }; + + double min; + double max; + int i; + for ( i = 0; i < 10; i++ ) { + stdlib_base_minmax( x[ i ], y[ i ], &min, &max ); + printf( "x: %lf, y: %lf => min: %lf, max: %lf\n", x[ i ], y[ i ], min, max ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/include.gypi b/lib/node_modules/@stdlib/math/base/special/minmax/include.gypi new file mode 100644 index 000000000000..ecfaf82a3279 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmax/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2025 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. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '[ 3.14, 4.2 ] +* +* @example +* var v = minmax( 3.14, NaN ); +* // returns [ NaN, NaN ] +* +* @example +* var v = minmax( +0.0, -0.0 ); +* // returns [ -0.0, 0.0 ] +*/ +function minmax( x, y ) { + var out = new Float64Array( 2 ); + addon( x, y, out ); + return out; +} + + +// EXPORTS // + +module.exports = minmax; diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/manifest.json b/lib/node_modules/@stdlib/math/base/special/minmax/manifest.json new file mode 100644 index 000000000000..502beab58f74 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmax/manifest.json @@ -0,0 +1,78 @@ +{ + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/argv", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-float64array", + "@stdlib/napi/export", + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/assert/is-negative-zero" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/assert/is-negative-zero" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/assert/is-negative-zero" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/package.json b/lib/node_modules/@stdlib/math/base/special/minmax/package.json index 54aa4e4b91f6..1bdca45ea44a 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmax/package.json +++ b/lib/node_modules/@stdlib/math/base/special/minmax/package.json @@ -14,11 +14,14 @@ } ], "main": "./lib", + "gypfile": true, "directories": { "benchmark": "./benchmark", "doc": "./docs", "example": "./examples", + "include": "./include", "lib": "./lib", + "src": "./src", "test": "./test" }, "types": "./docs/types", diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/src/Makefile b/lib/node_modules/@stdlib/math/base/special/minmax/src/Makefile new file mode 100644 index 000000000000..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmax/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/src/addon.c b/lib/node_modules/@stdlib/math/base/special/minmax/src/addon.c new file mode 100644 index 000000000000..c03f948f9e2c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmax/src/addon.c @@ -0,0 +1,42 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +#include "stdlib/math/base/special/minmax.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_double.h" +#include "stdlib/napi/argv_float64array.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 3 ); + STDLIB_NAPI_ARGV_DOUBLE( env, x, argv, 0 ); + STDLIB_NAPI_ARGV_DOUBLE( env, y, argv, 1 ); + STDLIB_NAPI_ARGV_FLOAT64ARRAY( env, out, outlen, argv, 2 ); + stdlib_base_minmax( x, y, &out[ 0 ], &out[ 1 ] ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/src/main.c b/lib/node_modules/@stdlib/math/base/special/minmax/src/main.c new file mode 100644 index 000000000000..d710b31d4433 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmax/src/main.c @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +#include "stdlib/math/base/special/minmax.h" +#include "stdlib/math/base/assert/is_nan.h" +#include "stdlib/math/base/assert/is_negative_zero.h" + +/** +* Evaluates the minimum and maximum values in a single pass. +* +* @param x first number +* @param y second number +* @param min destination for the minimum value +* @param max destination for the maximum value +* +* @example +* double x = 3.14; +* double y = 2.71; +* +* double min; +* double max; +* stdlib_base_minmax( x, y, &min, &max ); +*/ +void stdlib_base_minmax( const double x, const double y, double* min, double* max ) { + if ( stdlib_base_is_nan( x ) || stdlib_base_is_nan( y ) ) { + *min = 0.0 / 0.0; // NaN + *max = 0.0 / 0.0; // NaN + return; + } + if ( x == y && x == 0.0 ) { + if ( stdlib_base_is_negative_zero( x ) ) { + *min = x; + *max = y; + return; + } + *min = y; + *max = x; + return; + } + if ( x < y ) { + *min = x; + *max = y; + return; + } + *min = y; + *max = x; + return; +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/test/test.assign.js b/lib/node_modules/@stdlib/math/base/special/minmax/test/test.assign.js index 72f82b2d7bb9..dce0ee0fac4d 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmax/test/test.assign.js +++ b/lib/node_modules/@stdlib/math/base/special/minmax/test/test.assign.js @@ -139,14 +139,14 @@ tape( 'the function returns the minimum and maximum values', function test( t ) out = new Float64Array( 2 ); v = minmax( 4.2, 3.14, out, 1, 0 ); t.strictEqual( v, out, 'returns output array' ); - t.strictEqual( v[ 0 ], 3.14, 'returns min value' ); - t.strictEqual( v[ 1 ], 4.2, 'returns max value' ); + t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); + t.strictEqual( v[ 1 ], 4.2, 'returns expected value' ); out = new Float64Array( 2 ); v = minmax( -4.2, 3.14, out, 1, 0 ); t.strictEqual( v, out, 'returns output array' ); - t.strictEqual( v[ 0 ], -4.2, 'returns min value' ); - t.strictEqual( v[ 1 ], 3.14, 'returns max value' ); + t.strictEqual( v[ 0 ], -4.2, 'returns expected value' ); + t.strictEqual( v[ 1 ], 3.14, 'returns expected value' ); t.end(); }); @@ -158,14 +158,14 @@ tape( 'the function supports providing an output object (array)', function test( out = [ 0.0, 0.0 ]; v = minmax( 4.2, 3.14, out, 1, 0 ); t.strictEqual( v, out, 'returns output array' ); - t.strictEqual( v[ 0 ], 3.14, 'returns min value' ); - t.strictEqual( v[ 1 ], 4.2, 'returns max value' ); + t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); + t.strictEqual( v[ 1 ], 4.2, 'returns expected value' ); out = [ 0.0, 0.0 ]; v = minmax( -4.2, 3.14, out, 1, 0 ); t.strictEqual( v, out, 'returns output array' ); - t.strictEqual( v[ 0 ], -4.2, 'returns min value' ); - t.strictEqual( v[ 1 ], 3.14, 'returns max value' ); + t.strictEqual( v[ 0 ], -4.2, 'returns expected value' ); + t.strictEqual( v[ 1 ], 3.14, 'returns expected value' ); t.end(); }); @@ -177,14 +177,14 @@ tape( 'the function supports providing an output object (typed array)', function out = new Float64Array( 2 ); v = minmax( 4.2, 3.14, out, 1, 0 ); t.strictEqual( v, out, 'returns output array' ); - t.strictEqual( v[ 0 ], 3.14, 'returns min value' ); - t.strictEqual( v[ 1 ], 4.2, 'returns max value' ); + t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); + t.strictEqual( v[ 1 ], 4.2, 'returns expected value' ); out = new Float64Array( 2 ); v = minmax( -4.2, 3.14, out, 1, 0 ); t.strictEqual( v, out, 'returns output array' ); - t.strictEqual( v[ 0 ], -4.2, 'returns min value' ); - t.strictEqual( v[ 1 ], 3.14, 'returns max value' ); + t.strictEqual( v[ 0 ], -4.2, 'returns expected value' ); + t.strictEqual( v[ 1 ], 3.14, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/test/test.main.js b/lib/node_modules/@stdlib/math/base/special/minmax/test/test.main.js index 23be03222f8e..a802ddea9966 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmax/test/test.main.js +++ b/lib/node_modules/@stdlib/math/base/special/minmax/test/test.main.js @@ -109,12 +109,12 @@ tape( 'the function returns the minimum and maximum values', function test( t ) var v; v = minmax( 4.2, 3.14 ); - t.strictEqual( v[ 0 ], 3.14, 'returns min value' ); - t.strictEqual( v[ 1 ], 4.2, 'returns max value' ); + t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); + t.strictEqual( v[ 1 ], 4.2, 'returns expected value' ); v = minmax( -4.2, 3.14 ); - t.strictEqual( v[ 0 ], -4.2, 'returns min value' ); - t.strictEqual( v[ 1 ], 3.14, 'returns max value' ); + t.strictEqual( v[ 0 ], -4.2, 'returns expected value' ); + t.strictEqual( v[ 1 ], 3.14, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/minmax/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/minmax/test/test.native.js new file mode 100644 index 000000000000..ea77d4eee9c5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmax/test/test.native.js @@ -0,0 +1,129 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var minmax = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( minmax instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof minmax, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` for both the minimum and maximum value if provided a `NaN`', opts, function test( t ) { + var v; + + v = minmax( NaN, 3.14 ); + t.strictEqual( isnan( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + v = minmax( 3.14, NaN ); + t.strictEqual( isnan( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + v = minmax( NaN, NaN ); + t.strictEqual( isnan( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-Infinity` as the minimum value if provided `-Infinity`', opts, function test( t ) { + var v; + + v = minmax( NINF, 3.14 ); + t.strictEqual( v[ 0 ], NINF, 'returns expected value' ); + t.strictEqual( v[ 1 ], 3.14, 'returns expected value' ); + + v = minmax( 3.14, NINF ); + t.strictEqual( v[ 0 ], NINF, 'returns expected value' ); + t.strictEqual( v[ 1 ], 3.14, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `+Infinity` as the maximum value if provided `+Infinity`', opts, function test( t ) { + var v; + + v = minmax( PINF, 3.14 ); + t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); + + v = minmax( 3.14, PINF ); + t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns correctly signed zeros', opts, function test( t ) { + var v; + + v = minmax( +0.0, -0.0 ); + t.strictEqual( isNegativeZero( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns expected value' ); + + v = minmax( -0.0, +0.0 ); + t.strictEqual( isNegativeZero( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns expected value' ); + + v = minmax( -0.0, -0.0 ); + t.strictEqual( isNegativeZero( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isNegativeZero( v[ 1 ] ), true, 'returns expected value' ); + + v = minmax( +0.0, +0.0 ); + t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the minimum and maximum values', opts, function test( t ) { + var v; + + v = minmax( 4.2, 3.14 ); + t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); + t.strictEqual( v[ 1 ], 4.2, 'returns expected value' ); + + v = minmax( -4.2, 3.14 ); + t.strictEqual( v[ 0 ], -4.2, 'returns expected value' ); + t.strictEqual( v[ 1 ], 3.14, 'returns expected value' ); + + t.end(); +}); From a9d4530c9e486f49e6d13b8bd2d3dfaeda41cb06 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Mon, 19 May 2025 18:55:17 -0700 Subject: [PATCH 59/60] docs: update example and function description --- 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - 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/math/base/special/minmaxabs/docs/repl.txt | 3 ++- .../math/base/special/minmaxabs/docs/types/index.d.ts | 5 ++++- .../@stdlib/math/base/special/minmaxabs/lib/index.js | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabs/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/minmaxabs/docs/repl.txt index ef76d02658ef..e6f1d55617b3 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxabs/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabs/docs/repl.txt @@ -31,7 +31,8 @@ {{alias}}.assign( x, y, out, stride, offset ) - Returns the minimum and maximum absolute values. + Returns the minimum and maximum absolute values and assigns results to a + provided output array. If any argument is `NaN`, the function returns `NaN` for both the minimum and maximum absolute values. diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabs/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/minmaxabs/docs/types/index.d.ts index 3a348937e9a3..d9f443e060d6 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxabs/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabs/docs/types/index.d.ts @@ -22,6 +22,9 @@ import { Collection } from '@stdlib/types/array'; +/** +* Interface describing an interface for computing minimum and maximum absolute values. +*/ interface MinMaxAbs { /** * Returns the minimum and maximum absolute values. @@ -45,7 +48,7 @@ interface MinMaxAbs { ( x: number, y: number ): Array; /** - * Returns the minimum and maximum absolute values. + * Returns the minimum and maximum absolute values and assigns results to a provided output array. * * @param x - first number * @param y - second number diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabs/lib/index.js b/lib/node_modules/@stdlib/math/base/special/minmaxabs/lib/index.js index 265db8198b98..75259ea0eb9b 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxabs/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabs/lib/index.js @@ -38,7 +38,7 @@ * v = minmaxabs( +0.0, -0.0 ); * // returns [ 0.0, 0.0 ] * -* v = minmaxabs( 3.14 ); +* v = minmaxabs( 3.14, -3.14 ); * // returns [ 3.14, 3.14 ] */ From 28b837504e216bf5b5175226511777575b4edc2a Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Mon, 19 May 2025 19:03:42 -0700 Subject: [PATCH 60/60] docs: remove args parameter to match TS declaration --- 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 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/math/base/special/minmaxabs/docs/types/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabs/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/minmaxabs/docs/types/index.d.ts index d9f443e060d6..37a42ebebcd6 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxabs/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabs/docs/types/index.d.ts @@ -73,7 +73,6 @@ interface MinMaxAbs { * * @param x - first number * @param y - second number -* @param args - numbers * @returns minimum and maximum absolute values * * @example