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/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(); }); 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(); }); 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 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 ) ); } diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/README.md b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/README.md similarity index 76% rename from lib/node_modules/@stdlib/assert/is-same-booleanarray/README.md rename to lib/node_modules/@stdlib/assert/is-equal-booleanarray/README.md index b069aecf20d7..8518cd4a221a 100644 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/README.md +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/README.md @@ -18,31 +18,31 @@ limitations under the License. --> -# isSameBooleanArray +# isEqualBooleanArray -> Test if two arguments are both [BooleanArrays][@stdlib/array/bool] and have the [same values][@stdlib/assert/is-same-value]. +> Test if two arguments are both [BooleanArrays][@stdlib/array/bool] and have equal values.
## Usage ```javascript -var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' ); +var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); ``` -#### isSameBooleanArray( v1, v2 ) +#### isEqualBooleanArray( v1, v2 ) -Tests if two arguments are both [BooleanArrays][@stdlib/array/bool] and have the [same values][@stdlib/assert/is-same-value]. +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 = isSameBooleanArray( x, y ); +var bool = isEqualBooleanArray( x, y ); // returns true -bool = isSameBooleanArray( x, [ true, false ] ); +bool = isEqualBooleanArray( x, [ true, false ] ); // returns false ``` @@ -64,16 +64,16 @@ bool = isSameBooleanArray( x, [ true, false ] ); ```javascript var BooleanArray = require( '@stdlib/array/bool' ); -var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' ); +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 = isSameBooleanArray( x, y ); +var out = isEqualBooleanArray( x, y ); // returns true x = new BooleanArray( [ true, false, false, true ] ); y = new BooleanArray( [ true, true, false, false ] ); -out = isSameBooleanArray( x, y ); +out = isEqualBooleanArray( x, y ); // returns false ``` @@ -95,8 +95,6 @@ out = isSameBooleanArray( x, y ); [@stdlib/array/bool]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/bool -[@stdlib/assert/is-same-value]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-same-value -
diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/benchmark/benchmark.length.js similarity index 95% rename from lib/node_modules/@stdlib/assert/is-same-booleanarray/benchmark/benchmark.length.js rename to lib/node_modules/@stdlib/assert/is-equal-booleanarray/benchmark/benchmark.length.js index 82a55c1b563d..b6dd4ad48f91 100644 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/benchmark/benchmark.length.js +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/benchmark/benchmark.length.js @@ -26,7 +26,7 @@ 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' ); +var isEqualBooleanArray = require( './../lib' ); // FUNCTIONS // @@ -64,7 +64,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - bool = isSameBooleanArray( x, y ); + bool = isEqualBooleanArray( x, y ); if ( typeof bool !== 'boolean' ) { b.fail( 'should return a boolean' ); } diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/repl.txt similarity index 81% rename from lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/repl.txt rename to lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/repl.txt index 9ed0fbe15ef8..c2e170686bab 100644 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/repl.txt +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( v1, v2 ) - Tests if two arguments are both BooleanArrays and have the same values. + Tests if two arguments are both BooleanArrays and have equal values. Parameters ---------- @@ -13,7 +13,7 @@ Returns ------- bool: boolean - Boolean indicating whether two arguments are the same. + Boolean indicating whether two arguments are equal. Examples -------- diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/types/index.d.ts similarity index 78% rename from lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/types/index.d.ts rename to lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/types/index.d.ts index cc768f78a9ef..5e603a44ec7d 100644 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/types/index.d.ts @@ -19,11 +19,11 @@ // TypeScript Version: 4.1 /** -* Tests if two arguments are both BooleanArrays and have the same values. +* 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 the same +* @returns boolean indicating whether two arguments are equal * * @example * var BooleanArray = require( '@stdlib/array/bool' ); @@ -31,7 +31,7 @@ * var x = new BooleanArray( [ true, false, false, true ] ); * var y = new BooleanArray( [ true, false, false, true ] ); * -* var out = isSameBooleanArray( x, y ); +* var out = isEqualBooleanArray( x, y ); * // returns true * * @example @@ -40,12 +40,12 @@ * var x = new BooleanArray( [ true, false, false, true ] ); * var y = new BooleanArray( [ true, true, false, false ] ); * -* var out = isSameBooleanArray( x, y ); +* var out = isEqualBooleanArray( x, y ); * // returns false */ -declare function isSameBooleanArray( v1: any, v2: any ): boolean; +declare function isEqualBooleanArray( v1: any, v2: any ): boolean; // EXPORTS // -export = isSameBooleanArray; +export = isEqualBooleanArray; diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/types/test.ts similarity index 67% rename from lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/types/test.ts rename to lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/types/test.ts index 27aec976ac81..3dc546d5f148 100644 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/docs/types/test.ts +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/docs/types/test.ts @@ -16,21 +16,21 @@ * limitations under the License. */ -import isSameBooleanArray = require( './index' ); +import isEqualBooleanArray = require( './index' ); // TESTS // // The function returns a boolean... { - isSameBooleanArray( true, true ); // $ExpectType boolean - isSameBooleanArray( null, null ); // $ExpectType boolean - isSameBooleanArray( 'beep', 'boop' ); // $ExpectType 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... { - isSameBooleanArray(); // $ExpectError - isSameBooleanArray( 3.14 ); // $ExpectError - isSameBooleanArray( 'beep', 'beep', 3.14 ); // $ExpectError + isEqualBooleanArray(); // $ExpectError + isEqualBooleanArray( 3.14 ); // $ExpectError + isEqualBooleanArray( '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-equal-booleanarray/examples/index.js similarity index 88% rename from lib/node_modules/@stdlib/assert/is-same-booleanarray/examples/index.js rename to lib/node_modules/@stdlib/assert/is-equal-booleanarray/examples/index.js index e0899ff43005..b49411df58f3 100644 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/examples/index.js +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/examples/index.js @@ -19,16 +19,16 @@ 'use strict'; var BooleanArray = require( '@stdlib/array/bool' ); -var isSameBooleanArray = require( './../lib' ); +var isEqualBooleanArray = require( './../lib' ); var x = new BooleanArray( [ true, false, false, true ] ); var y = new BooleanArray( [ true, false, false, true ] ); -var out = isSameBooleanArray( x, y ); +var out = isEqualBooleanArray( x, y ); console.log( out ); // => true x = new BooleanArray( [ true, false, false, true ] ); y = new BooleanArray( [ true, true, false, false ] ); -out = isSameBooleanArray( x, y ); +out = isEqualBooleanArray( 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-equal-booleanarray/lib/index.js similarity index 76% rename from lib/node_modules/@stdlib/assert/is-same-booleanarray/lib/index.js rename to lib/node_modules/@stdlib/assert/is-equal-booleanarray/lib/index.js index 0620d6d52255..83a33140552a 100644 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/lib/index.js +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/lib/index.js @@ -19,28 +19,28 @@ 'use strict'; /** -* Test if two arguments are both BooleanArrays and have the same values. +* Test if two arguments are both BooleanArrays and have equal values. * -* @module @stdlib/assert/is-same-booleanarray +* @module @stdlib/assert/is-equal-booleanarray * * @example * var BooleanArray = require( '@stdlib/array/bool' ); -* var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' ); +* 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 = isSameBooleanArray( x, y ); +* var out = isEqualBooleanArray( x, y ); * // returns true * * @example * var BooleanArray = require( '@stdlib/array/bool' ); -* var isSameBooleanArray = require( '@stdlib/assert/is-same-booleanarray' ); +* 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 = isSameBooleanArray( x, y ); +* var out = isEqualBooleanArray( x, y ); * // returns false */ diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/lib/main.js b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/lib/main.js similarity index 74% rename from lib/node_modules/@stdlib/assert/is-same-booleanarray/lib/main.js rename to lib/node_modules/@stdlib/assert/is-equal-booleanarray/lib/main.js index ca2162e2a5aa..c133b926ea44 100644 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/lib/main.js @@ -21,13 +21,13 @@ // MODULES // var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); // MAIN // /** -* Tests if two arguments are both BooleanArrays and have the same values. +* Tests if two arguments are both BooleanArrays and have equal values. * * @param {*} v1 - first value * @param {*} v2 - second value @@ -39,7 +39,7 @@ var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); * var x = new BooleanArray( [ true, false, false, true ] ); * var y = new BooleanArray( [ true, false, false, true ] ); * -* var out = isSameBooleanArray( x, y ); +* var out = isEqualBooleanArray( x, y ); * // returns true * * @example @@ -48,17 +48,14 @@ var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); * var x = new BooleanArray( [ true, false, false, true ] ); * var y = new BooleanArray( [ true, true, false, false ] ); * -* var out = isSameBooleanArray( x, y ); +* var out = isEqualBooleanArray( x, y ); * // returns false */ -function isSameBooleanArray( v1, v2 ) { - if ( isBooleanArray( v1 ) && isBooleanArray( v2 ) ) { - return hasSameValues( v1, v2 ); - } - return false; +function isEqualBooleanArray( v1, v2 ) { + return ( isBooleanArray( v1 ) && isBooleanArray( v2 ) && hasEqualValues( v1, v2 ) ); // eslint-disable-line max-len } // EXPORTS // -module.exports = isSameBooleanArray; +module.exports = isEqualBooleanArray; diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/package.json b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/package.json similarity index 94% rename from lib/node_modules/@stdlib/assert/is-same-booleanarray/package.json rename to lib/node_modules/@stdlib/assert/is-equal-booleanarray/package.json index ff14fd60947c..884ab378d5db 100644 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/package.json +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/package.json @@ -1,7 +1,7 @@ { - "name": "@stdlib/assert/is-same-booleanarray", + "name": "@stdlib/assert/is-equal-booleanarray", "version": "0.0.0", - "description": "Test if two arguments are both BooleanArrays and have the same values.", + "description": "Test if two arguments are both BooleanArrays and have equal values.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/assert/is-same-booleanarray/test/test.js b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/test/test.js similarity index 78% rename from lib/node_modules/@stdlib/assert/is-same-booleanarray/test/test.js rename to lib/node_modules/@stdlib/assert/is-equal-booleanarray/test/test.js index 4624cf3d3f86..e34172d397a5 100644 --- a/lib/node_modules/@stdlib/assert/is-same-booleanarray/test/test.js +++ b/lib/node_modules/@stdlib/assert/is-equal-booleanarray/test/test.js @@ -22,32 +22,32 @@ var tape = require( 'tape' ); var typedarray = require( '@stdlib/array/typed' ); -var isSameBooleanArray = require( './../lib' ); +var isEqualBooleanArray = 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.strictEqual( typeof isEqualBooleanArray, 'function', 'main export is a function' ); t.end(); }); -tape( 'the function returns `true` if provided two BooleanArrays having the same values', function test( t ) { +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( isSameBooleanArray( x, x ), true, 'returns expected value' ); + 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( isSameBooleanArray( x, y ), true, 'returns expected value' ); + t.strictEqual( isEqualBooleanArray( 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 ) { +tape( 'the function returns `false` if not provided two BooleanArrays having equal values', function test( t ) { var x; var y; var i; @@ -95,7 +95,7 @@ tape( 'the function returns `false` if not provided two BooleanArrays having the 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.strictEqual( isEqualBooleanArray( x[ i ], y[ i ] ), false, 'returns expected value when provided '+x[ i ]+' and '+y[ i ] ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/README.md b/lib/node_modules/@stdlib/assert/is-equal-date-object/README.md similarity index 76% rename from lib/node_modules/@stdlib/assert/is-same-date-object/README.md rename to lib/node_modules/@stdlib/assert/is-equal-date-object/README.md index ca7a7af7a886..a5391201c000 100644 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/README.md +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/README.md @@ -18,7 +18,7 @@ limitations under the License. --> -# isSameDateObject +# 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. @@ -27,20 +27,20 @@ limitations under the License. ## Usage ```javascript -var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); +var isEqualDateObject = require( '@stdlib/assert/is-equal-date-object' ); ``` -#### isSameDateObject( d1, d2 ) +#### 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 = isSameDateObject( d1, d2 ); +var bool = isEqualDateObject( d1, d2 ); // returns true -bool = isSameDateObject( d1, new Date( 2023, 11, 31, 23, 59, 59, 78 ) ); +bool = isEqualDateObject( d1, new Date( 2023, 11, 31, 23, 59, 59, 78 ) ); // returns false ``` @@ -55,33 +55,33 @@ bool = isSameDateObject( d1, new Date( 2023, 11, 31, 23, 59, 59, 78 ) ); ```javascript -var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); +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 = isSameDateObject( d1, d2 ); +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 = isSameDateObject( d1, d2 ); +bool = isEqualDateObject( d1, d2 ); // returns false d1 = new Date(); d2 = new Date( '2024-12-31T23:59:59.999' ); -bool = isSameDateObject( d1, d2 ); +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 = isSameDateObject( d1, d3 ); +bool = isEqualDateObject( d1, d3 ); // returns false -bool = isSameDateObject( d2, d4 ); +bool = isEqualDateObject( 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-equal-date-object/benchmark/benchmark.js similarity index 93% rename from lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/benchmark.js rename to lib/node_modules/@stdlib/assert/is-equal-date-object/benchmark/benchmark.js index 3c000a5afc7c..5430e44de47b 100644 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/benchmark/benchmark.js @@ -23,7 +23,7 @@ var bench = require( '@stdlib/bench' ); var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; var pkg = require( './../package.json' ).name; -var isSameDateObject = require( './../lib' ); +var isEqualDateObject = require( './../lib' ); // MAIN // @@ -48,7 +48,7 @@ bench( pkg, function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { date2 = values[ i%values.length ]; - bool = isSameDateObject( date1, date2 ); + bool = isEqualDateObject( date1, date2 ); if ( typeof bool !== 'boolean' ) { b.fail( 'should return a boolean' ); } diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-equal-date-object/docs/repl.txt similarity index 61% rename from lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt rename to lib/node_modules/@stdlib/assert/is-equal-date-object/docs/repl.txt index e5078d774774..e4f3c43ab945 100644 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( d1, d2 ) - Tests if two values are both Date objects corresponding - to the same date and time. + Tests if two values are both Date objects corresponding to the same date + and time. Parameters ---------- @@ -13,8 +13,8 @@ Returns ------- bool: boolean - Boolean indicating whether both values are Date objects - corresponding to the same date and time. + Boolean indicating whether both values are Date objects corresponding to + the same date and time. Examples -------- @@ -22,11 +22,11 @@ > 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 ) + > 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-same-date-object/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-equal-date-object/docs/types/index.d.ts similarity index 84% rename from lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/index.d.ts rename to lib/node_modules/@stdlib/assert/is-equal-date-object/docs/types/index.d.ts index 557a16d2e67a..2b8bda12f5d1 100644 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/docs/types/index.d.ts @@ -23,25 +23,25 @@ * * @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. +* @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 ); +* 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 = isSameDateObject( d1, d2 ); +* var bool = isEqualDateObject( d1, d2 ); * // returns false */ -declare function isSameDateObject( d1: any, d2: any ): boolean; +declare function isEqualDateObject( d1: any, d2: any ): boolean; // EXPORTS // -export = isSameDateObject; +export = isEqualDateObject; diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-equal-date-object/docs/types/test.ts similarity index 66% rename from lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/test.ts rename to lib/node_modules/@stdlib/assert/is-equal-date-object/docs/types/test.ts index 0bc2ed487ab6..0c5c2b19837e 100644 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/test.ts +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/docs/types/test.ts @@ -16,21 +16,21 @@ * limitations under the License. */ -import isSameDateObject = require( './index' ); +import isEqualDateObject = 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 + 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... { - isSameDateObject(); // $ExpectError - isSameDateObject( new Date() ); // $ExpectError - isSameDateObject( 'beep', 'beep', new Date() ); // $ExpectError + isEqualDateObject(); // $ExpectError + isEqualDateObject( new Date() ); // $ExpectError + isEqualDateObject( '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-equal-date-object/examples/index.js similarity index 83% rename from lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js rename to lib/node_modules/@stdlib/assert/is-equal-date-object/examples/index.js index 000083c80701..d02e3931ca10 100644 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/examples/index.js @@ -18,34 +18,34 @@ 'use strict'; -var isSameDateObject = require( './../lib' ); +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 = isSameDateObject( d1, d2 ); +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 = isSameDateObject( d1, d2 ); +bool = isEqualDateObject( d1, d2 ); console.log( bool ); // => false d1 = new Date(); d2 = new Date( '2024-12-31T23:59:59.999' ); -bool = isSameDateObject( d1, d2 ); +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 = isSameDateObject( d1, d3 ); +bool = isEqualDateObject( d1, d3 ); console.log( bool ); // => false -bool = isSameDateObject( d2, d4 ); +bool = isEqualDateObject( 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-equal-date-object/lib/index.js similarity index 79% rename from lib/node_modules/@stdlib/assert/is-same-date-object/lib/index.js rename to lib/node_modules/@stdlib/assert/is-equal-date-object/lib/index.js index 8344411ffca0..46149c9be308 100644 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/lib/index.js +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/lib/index.js @@ -21,24 +21,24 @@ /** * Test if two arguments are both Date objects corresponding to the same date and time. * -* @module @stdlib/assert/is-same-date-object +* @module @stdlib/assert/is-equal-date-object * * @example -* var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); +* 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 = isSameDateObject( d1, d2 ); +* var bool = isEqualDateObject( d1, d2 ); * // returns true * * @example -* var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); +* 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 = isSameDateObject( d1, d2 ); +* var bool = isEqualDateObject( d1, d2 ); * // returns false */ diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/lib/main.js b/lib/node_modules/@stdlib/assert/is-equal-date-object/lib/main.js similarity index 81% rename from lib/node_modules/@stdlib/assert/is-same-date-object/lib/main.js rename to lib/node_modules/@stdlib/assert/is-equal-date-object/lib/main.js index d804d00bcd48..6a0305c9629b 100644 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/lib/main.js @@ -35,23 +35,20 @@ var isDateObject = require( '@stdlib/assert/is-date-object' ); * @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 ); +* 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 = isSameDateObject( d1, d2 ); +* var bool = isEqualDateObject( d1, d2 ); * // returns false */ -function isSameDateObject( d1, d2 ) { - if ( isDateObject( d1 ) && isDateObject( d2 ) ) { - return d1.getTime() === d2.getTime(); - } - return false; +function isEqualDateObject( d1, d2 ) { + return ( isDateObject( d1 ) && isDateObject( d2 ) && ( d1.getTime() === d2.getTime() ) ); // eslint-disable-line max-len } // EXPORTS // -module.exports = isSameDateObject; +module.exports = isEqualDateObject; diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/package.json b/lib/node_modules/@stdlib/assert/is-equal-date-object/package.json similarity index 96% rename from lib/node_modules/@stdlib/assert/is-same-date-object/package.json rename to lib/node_modules/@stdlib/assert/is-equal-date-object/package.json index 185de9500037..2c916eb13915 100644 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/package.json +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/assert/is-same-date-object", + "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", diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/test/test.js b/lib/node_modules/@stdlib/assert/is-equal-date-object/test/test.js similarity index 65% rename from lib/node_modules/@stdlib/assert/is-same-date-object/test/test.js rename to lib/node_modules/@stdlib/assert/is-equal-date-object/test/test.js index 1f85c75dca84..bc7e42944651 100644 --- a/lib/node_modules/@stdlib/assert/is-same-date-object/test/test.js +++ b/lib/node_modules/@stdlib/assert/is-equal-date-object/test/test.js @@ -21,14 +21,14 @@ // MODULES // var tape = require( 'tape' ); -var isSameDateObject = require( './../lib' ); +var isEqualDateObject = 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.strictEqual( typeof isEqualDateObject, 'function', 'main export is a function' ); t.end(); } ); @@ -37,15 +37,15 @@ tape( 'the function returns `true` if provided two Date objects corresponding to var d2; d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); - t.strictEqual( isSameDateObject( d1, d1 ), true, 'returns expected value' ); + 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( isSameDateObject( d1, d2 ), true, 'returns expected value' ); + 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( isSameDateObject( d1, d2 ), true, 'returns expected value' ); + t.strictEqual( isEqualDateObject( d1, d2 ), true, 'returns expected value' ); t.end(); } ); @@ -56,35 +56,35 @@ tape( 'the function returns `false` if not provided two Date objects correspondi 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' ); + t.strictEqual( isEqualDateObject( 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' ); + t.strictEqual( isEqualDateObject( 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' ); + t.strictEqual( isEqualDateObject( d1, d2 ), false, 'returns expected value' ); d1 = new Date( 2024, 11, 31 ); d2 = 'string'; - t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); + t.strictEqual( isEqualDateObject( d1, d2 ), false, 'returns expected value' ); d1 = new Date( 2024, 11, 31 ); d2 = 1; - t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); + t.strictEqual( isEqualDateObject( d1, d2 ), false, 'returns expected value' ); d1 = new Date( 2024, 11, 31 ); - d2 = undefined; - t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); + d2 = void 0; + t.strictEqual( isEqualDateObject( d1, d2 ), false, 'returns expected value' ); d1 = new Date( 2024, 11, 31 ); d2 = {}; - t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); + t.strictEqual( isEqualDateObject( d1, d2 ), false, 'returns expected value' ); d1 = new Date( 2024, 11, 31 ); d2 = []; - t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); + t.strictEqual( isEqualDateObject( d1, d2 ), false, 'returns expected value' ); t.end(); } ); 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(); +}); 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(); +}); 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(); +}); 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(); +}); 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(); +}); 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(); +}); 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(); +}); 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 } 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 } 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 } 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 ) ); } 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 } 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 } 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 ) ); } 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 ) ); } 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 } 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 } 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 } diff --git a/lib/node_modules/@stdlib/assert/lib/index.js b/lib/node_modules/@stdlib/assert/lib/index.js index 30f116c28f64..f09b226d171e 100644 --- a/lib/node_modules/@stdlib/assert/lib/index.js +++ b/lib/node_modules/@stdlib/assert/lib/index.js @@ -1170,6 +1170,87 @@ 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 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 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 +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-equal-int16array} +*/ +setReadOnly( ns, 'isEqualInt16Array', require( '@stdlib/assert/is-equal-int16array' ) ); + +/** +* @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 isEqualUint8Array +* @memberof ns +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-equal-uint8array} +*/ +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 +* @readonly +* @type {Function} +* @see {@link module:@stdlib/assert/is-equal-uint16array} +*/ +setReadOnly( ns, 'isEqualUint16Array', require( '@stdlib/assert/is-equal-uint16array' ) ); + +/** +* @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 @@ -2196,6 +2277,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 @@ -2214,6 +2304,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 @@ -2286,6 +2385,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 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]. diff --git a/lib/node_modules/@stdlib/math/base/special/polygamma/README.md b/lib/node_modules/@stdlib/math/base/special/polygamma/README.md index bc071c75657d..f21e5d6bb576 100644 --- a/lib/node_modules/@stdlib/math/base/special/polygamma/README.md +++ b/lib/node_modules/@stdlib/math/base/special/polygamma/README.md @@ -74,7 +74,7 @@ v = polygamma( 2, -1.0 ); If `x` on the other hand is a negative even `integer`, the function returns `NaN`. ```javascript -v = polygamma( 2, -4.0 ); +var v = polygamma( 2, -4.0 ); // returns NaN v = polygamma( 2, -2.0 ); @@ -105,21 +105,18 @@ v = polygamma( NaN, NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var polygamma = require( '@stdlib/math/base/special/polygamma' ); -var n; -var x; -var v; -var i; - -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - n = round( randu()*50.0 ); - v = polygamma( x, n ); - console.log( 'x: %d, ψ^(%d)(x): %d', x, n, v ); -} +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); +var n = discreteUniform( 100, 0, 50, opts ); + +logEachMap( 'x: %0.4f, ψ^(%d)(x): %0.4f', x, n, polygamma ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/polygamma/examples/index.js b/lib/node_modules/@stdlib/math/base/special/polygamma/examples/index.js index 795d68cbcbb4..f3fc82df3417 100644 --- a/lib/node_modules/@stdlib/math/base/special/polygamma/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/polygamma/examples/index.js @@ -18,18 +18,15 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var polygamma = require( './../lib' ); -var n; -var x; -var v; -var i; +var opts = { + 'dtype': 'float64' +}; +var x = uniform( 100, -50.0, 50.0, opts ); +var n = discreteUniform( 100, 0, 50, opts ); -for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - n = round( randu()*50.0 ); - v = polygamma( n, x ); - console.log( 'x: %d, ψ^(%d)(x): %d', x, n, v ); -} +logEachMap( 'x: %0.4f, ψ^(%d)(x): %0.4f', x, n, polygamma ); diff --git a/lib/node_modules/@stdlib/math/base/special/pow/README.md b/lib/node_modules/@stdlib/math/base/special/pow/README.md index 28d0d3c55a93..8652b007b72b 100644 --- a/lib/node_modules/@stdlib/math/base/special/pow/README.md +++ b/lib/node_modules/@stdlib/math/base/special/pow/README.md @@ -94,19 +94,17 @@ v = pow( NaN, NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var pow = require( '@stdlib/math/base/special/pow' ); -var b; -var x; -var i; +var opts = { + 'dtype': 'float64' +}; +var b = discreteUniform( 100, 0, 10, opts ); +var x = discreteUniform( 100, -5, 5, opts ); -for ( i = 0; i < 100; i++ ) { - b = round( randu()*10.0 ); - x = round( randu()*10.0 ) - 5.0; - console.log( '%d^%d = %d', b, x, pow( b, x ) ); -} +logEachMap( '%d^%d = %0.4f', b, x, pow ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/pow/examples/index.js b/lib/node_modules/@stdlib/math/base/special/pow/examples/index.js index b54032c638a2..2c43e0c898c8 100644 --- a/lib/node_modules/@stdlib/math/base/special/pow/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/pow/examples/index.js @@ -18,16 +18,14 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var pow = require( './../lib' ); -var b; -var x; -var i; +var opts = { + 'dtype': 'float64' +}; +var b = discreteUniform( 100, 0, 10, opts ); +var x = discreteUniform( 100, -5, 5, opts ); -for ( i = 0; i < 100; i++ ) { - b = round( randu()*10.0 ); - x = round( randu()*10.0 ) - 5.0; - console.log( '%d^%d = %d', b, x, pow( b, x ) ); -} +logEachMap( '%d^%d = %0.4f', b, x, pow ); diff --git a/lib/node_modules/@stdlib/math/base/special/powm1/README.md b/lib/node_modules/@stdlib/math/base/special/powm1/README.md index 487921a77c66..bbac6b21b9c4 100644 --- a/lib/node_modules/@stdlib/math/base/special/powm1/README.md +++ b/lib/node_modules/@stdlib/math/base/special/powm1/README.md @@ -92,21 +92,17 @@ y = powm1( 5.0, NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var powm1 = require( '@stdlib/math/base/special/powm1' ); -var b; -var x; -var y; -var i; +var opts = { + 'dtype': 'float64' +}; +var b = discreteUniform( 100, 0, 10, opts ); +var x = discreteUniform( 100, -5, 5, opts ); -for ( i = 0; i < 100; i++ ) { - b = round( randu()*10.0 ); - x = round( randu()*10.0 ) - 5.0; - y = powm1( b, x ); - console.log( '%d^%d - 1 = %d', b, x, y ); -} +logEachMap( '%d^%d - 1 = %0.4f', b, x, powm1 ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/powm1/examples/index.js b/lib/node_modules/@stdlib/math/base/special/powm1/examples/index.js index ad92df2edf83..98eb49334bee 100644 --- a/lib/node_modules/@stdlib/math/base/special/powm1/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/powm1/examples/index.js @@ -18,18 +18,14 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var powm1 = require( './../lib' ); -var b; -var x; -var y; -var i; +var opts = { + 'dtype': 'float64' +}; +var b = discreteUniform( 100, 0, 10, opts ); +var x = discreteUniform( 100, -5, 5, opts ); -for ( i = 0; i < 100; i++ ) { - b = round( randu()*10.0 ); - x = round( randu()*10.0 ) - 5.0; - y = powm1( b, x ); - console.log( '%d^%d - 1 = %d', b, x, y ); -} +logEachMap( '%d^%d - 1 = %0.4f', b, x, powm1 ); diff --git a/lib/node_modules/@stdlib/math/base/special/rad2deg/README.md b/lib/node_modules/@stdlib/math/base/special/rad2deg/README.md index aaa9e4df1cb7..4317fcc75b34 100644 --- a/lib/node_modules/@stdlib/math/base/special/rad2deg/README.md +++ b/lib/node_modules/@stdlib/math/base/special/rad2deg/README.md @@ -71,19 +71,17 @@ d = rad2deg( NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var TWO_PI = require( '@stdlib/constants/float64/two-pi' ); var rad2deg = require( '@stdlib/math/base/special/rad2deg' ); -var r; -var d; -var i; +var opts = { + 'dtype': 'float64' +}; +var r = uniform( 100, 0.0, TWO_PI, opts ); -for ( i = 0; i < 100; i++ ) { - r = randu() * TWO_PI; - d = rad2deg( r ); - console.log( 'radians: %d => degrees: %d', r, d ); -} +logEachMap( 'radians: %0.4f => degrees: %0.4f', r, rad2deg ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/rad2deg/examples/index.js b/lib/node_modules/@stdlib/math/base/special/rad2deg/examples/index.js index c3bacd52052a..731cf4a1f9b9 100644 --- a/lib/node_modules/@stdlib/math/base/special/rad2deg/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/rad2deg/examples/index.js @@ -18,16 +18,14 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var TWO_PI = require( '@stdlib/constants/float64/two-pi' ); var rad2deg = require( './../lib' ); -var r; -var d; -var i; +var opts = { + 'dtype': 'float64' +}; +var r = uniform( 100, 0.0, TWO_PI, opts ); -for ( i = 0; i < 100; i++ ) { - r = randu() * TWO_PI; - d = rad2deg( r ); - console.log( 'radians: %d => degrees: %d', r, d ); -} +logEachMap( 'radians: %0.4f => degrees: %0.4f', r, rad2deg ); diff --git a/lib/node_modules/@stdlib/math/base/special/rad2degf/README.md b/lib/node_modules/@stdlib/math/base/special/rad2degf/README.md index 5ac7a4755312..f695884b3518 100644 --- a/lib/node_modules/@stdlib/math/base/special/rad2degf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/rad2degf/README.md @@ -71,19 +71,17 @@ d = rad2degf( NaN ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var TWO_PI = require( '@stdlib/constants/float32/two-pi' ); var rad2degf = require( '@stdlib/math/base/special/rad2degf' ); -var r; -var d; -var i; +var opts = { + 'dtype': 'float32' +}; +var r = uniform( 100, 0.0, TWO_PI, opts ); -for ( i = 0; i < 100; i++ ) { - r = randu() * TWO_PI; - d = rad2degf( r ); - console.log( 'radians: %d => degrees: %d', r, d ); -} +logEachMap( 'radians: %0.4f => degrees: %0.4f', r, rad2degf ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/rad2degf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/rad2degf/examples/index.js index d57b59f855ca..baf841d5e68f 100644 --- a/lib/node_modules/@stdlib/math/base/special/rad2degf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/rad2degf/examples/index.js @@ -18,16 +18,14 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var TWO_PI = require( '@stdlib/constants/float32/two-pi' ); var rad2degf = require( './../lib' ); -var r; -var d; -var i; +var opts = { + 'dtype': 'float32' +}; +var r = uniform( 100, 0.0, TWO_PI, opts ); -for ( i = 0; i < 100; i++ ) { - r = randu() * TWO_PI; - d = rad2degf( r ); - console.log( 'radians: %d => degrees: %d', r, d ); -} +logEachMap( 'radians: %0.4f => degrees: %0.4f', r, rad2degf ); diff --git a/lib/node_modules/@stdlib/math/base/special/rcbrt/README.md b/lib/node_modules/@stdlib/math/base/special/rcbrt/README.md index 37f5f95d9da9..38f556fd7dd3 100644 --- a/lib/node_modules/@stdlib/math/base/special/rcbrt/README.md +++ b/lib/node_modules/@stdlib/math/base/special/rcbrt/README.md @@ -86,15 +86,16 @@ v = rcbrt( Infinity ); ```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var rcbrt = require( '@stdlib/math/base/special/rcbrt' ); -var x; -var i; -for ( i = 0; i < 100; i++ ) { - x = discreteUniform( 0.0, 100.0 ); - console.log( 'rcbrt(%d) = %d', x, rcbrt( x ) ); -} +var opts = { + 'dtype': 'float64' +}; +var x = discreteUniform( 100, 0, 100, opts ); + +logEachMap( 'rcbrt(%d) = %0.4f', x, rcbrt ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/rcbrt/examples/index.js b/lib/node_modules/@stdlib/math/base/special/rcbrt/examples/index.js index be4cf4da9c48..935f44ad25d2 100644 --- a/lib/node_modules/@stdlib/math/base/special/rcbrt/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/rcbrt/examples/index.js @@ -18,12 +18,13 @@ 'use strict'; -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var rcbrt = require( './../lib' ); -var x; -var i; -for ( i = 0; i < 100; i++ ) { - x = discreteUniform( 0.0, 100.0 ); - console.log( 'rcbrt(%d) = %d', x, rcbrt( x ) ); -} +var opts = { + 'dtype': 'float64' +}; +var x = discreteUniform( 100, 0, 100, opts ); + +logEachMap( 'rcbrt(%d) = %0.4f', x, rcbrt ); 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', 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..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,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 < 2 ) { + b.fail( 'should return an array' ); } } b.toc(); diff --git a/lib/node_modules/@stdlib/ndarray/lib/index.js b/lib/node_modules/@stdlib/ndarray/lib/index.js index 3f2a60de18a4..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 @@ -576,6 +594,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 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/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(); +}); 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/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(); +}); 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(); +}); 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(); +}); 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(); +}); 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(); +}); 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(); +}); 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(); +}); 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(); +});