diff --git a/lib/node_modules/@stdlib/assert/is-float16array/README.md b/lib/node_modules/@stdlib/assert/is-float16array/README.md new file mode 100644 index 000000000000..4e85d923d505 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/README.md @@ -0,0 +1,148 @@ + + +# isFloat16Array + +> Test if a value is a [Float16Array][mdn-float16array]. + +
+ +## Usage + +```javascript +var isFloat16Array = require( '@stdlib/assert/is-float16array' ); +``` + +#### isFloat16Array( value ) + +Tests if a value is a [`Float16Array`][mdn-float16array]. + +```javascipt +var Float16Array = require( '@stdlib/array/float16' ); + +var bool = isFloat16Array( new Float16Array( 10 ) ); +// returns true + +bool = isFloat16Array( [] ); +// returns false +``` + +
+ + + +
+ +## Examples + + + +```javascript +var Int8Array = require( '@stdlib/array/int8' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +var Int16Array = require( '@stdlib/array/int16' ); +var Uint16Array = require( '@stdlib/array/uint16' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Uint32Array = require( '@stdlib/array/uint32' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Float16Array = require( '@stdlib/array/float16' ); +var isFloat16Array = require( '@stdlib/assert/is-float16array' ); + +var bool = isFloat16Array( new Float16Array( 10 ) ); +// returns true + +bool = isFloat16Array( new Int8Array( 10 ) ); +// returns false + +bool = isFloat16Array( new Uint8Array( 10 ) ); +// returns false + +bool = isFloat16Array( new Uint8ClampedArray( 10 ) ); +// returns false + +bool = isFloat16Array( new Int16Array( 10 ) ); +// returns false + +bool = isFloat16Array( new Uint16Array( 10 ) ); +// returns false + +bool = isFloat16Array( new Int32Array( 10 ) ); +// returns false + +bool = isFloat16Array( new Uint32Array( 10 ) ); +// returns false + +bool = isFloat16Array( new Float32Array( 10 ) ); +// returns false + +bool = isFloat16Array( new Float64Array( 10 ) ); +// returns false + +bool = isFloat16Array( new Array( 10 ) ); +// returns false + +bool = isFloat16Array( {} ); +// returns false + +bool = isFloat16Array( null ); +// returns false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/assert/is-float16array/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/is-float16array/benchmark/benchmark.js new file mode 100644 index 000000000000..09f3c30ee8b2 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/benchmark/benchmark.js @@ -0,0 +1,132 @@ +/** +* @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 Int8Array = require( '@stdlib/array/int8' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +var Int16Array = require( '@stdlib/array/int16' ); +var Uint16Array = require( '@stdlib/array/uint16' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Uint32Array = require( '@stdlib/array/uint32' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var isFloat16Array = require( './../lib' ); +var Float16Array = globalThis[ Symbol.for( '@@stdlib/array/float16' ) ]; + +var opts = { + skip: ( typeof Float16Array !== 'function' ) +}; + +// MAIN // + +bench( pkg, opts, function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + new Float64Array( 10 ), + new Float16Array( 10 ), + new Float32Array( 10 ), + new Int32Array( 10 ), + new Uint32Array( 10 ), + new Int16Array( 10 ), + new Uint16Array( 10 ), + new Int8Array( 10 ), + new Uint8Array( 10 ), + new Uint8ClampedArray( 10 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isFloat16Array( values[ i%values.length ] ); + 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(); +}); + +bench( pkg+'::true', opts, function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + new Float16Array( 10 ), + new Float16Array( 10 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isFloat16Array( values[ i%values.length ] ); + 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(); +}); + +bench( pkg+'::false', opts, function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + new Float64Array( 10 ), + new Float32Array( 10 ), + new Int32Array( 10 ), + new Uint32Array( 10 ), + new Int16Array( 10 ), + new Uint16Array( 10 ), + new Int8Array( 10 ), + new Uint8Array( 10 ), + new Uint8ClampedArray( 10 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isFloat16Array( values[ i%values.length ] ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/assert/is-float16array/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-float16array/docs/repl.txt new file mode 100644 index 000000000000..9f55b6ed22c6 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/docs/repl.txt @@ -0,0 +1,22 @@ +{{alias}}( value ) + Tests if a value is a Float16Array. + + Parameters + ---------- + value: any + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating whether value is a Float16Array. + + Examples + -------- + > var bool = {{alias}}( new {{alias:@stdlib/array/float16}}( 10 ) ) + true + > bool = {{alias}}( [] ) + false + + See Also + -------- \ No newline at end of file diff --git a/lib/node_modules/@stdlib/assert/is-float16array/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-float16array/docs/types/index.d.ts new file mode 100644 index 000000000000..c14fe1cd8563 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/docs/types/index.d.ts @@ -0,0 +1,42 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +import Float16Array = require( '@stdlib/array/float16' ); + +/** +* Tests if a value is a Float16Array. +* +* @param value - value to test +* @returns boolean indicating whether value is a Float16Array +* +* @example +* +* var bool = isFloat16Array( new Float16Array( 10 ) ); +* // returns true +* +* @example +* var bool = isFloat16Array( [] ); +* // returns false +*/ +declare function isFloat16Array( value: any ): value is Float16Array; + +// EXPORTS // + +export = isFloat16Array; diff --git a/lib/node_modules/@stdlib/assert/is-float16array/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-float16array/docs/types/test.ts new file mode 100644 index 000000000000..5675a3d69a30 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/docs/types/test.ts @@ -0,0 +1,34 @@ +/* +* @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 isFloat16Array = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isFloat16Array( new Float16Array( 10 ) ); // $ExpectType boolean + isFloat16Array( [] ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isFloat16Array(); // $ExpectError + isFloat16Array( new Float16Array( 10 ), 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/is-float16array/examples/index.js b/lib/node_modules/@stdlib/assert/is-float16array/examples/index.js new file mode 100644 index 000000000000..92a135dbf2f8 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/examples/index.js @@ -0,0 +1,91 @@ +/** +* @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 Uint8Array = require( '@stdlib/array/uint8' ); +var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +var Int16Array = require( '@stdlib/array/int16' ); +var Uint16Array = require( '@stdlib/array/uint16' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Uint32Array = require( '@stdlib/array/uint32' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Float16Array; +var isFloat16Array = require( './../lib' ); + + +try { + Float16Array = require( '@stdlib/array/float16' ); +} catch (err) { + console.log( 'Float16Array is not available in this environment. Skipping all tests.' ); + process.exit(0); +} + +var bool = isFloat16Array( new Float16Array( 10 ) ); +console.log( bool ); +// => true + +bool = isFloat16Array( new Int8Array( 10 ) ); +console.log( bool ); +// => false + +bool = isFloat16Array( new Uint8Array( 10 ) ); +console.log( bool ); +// => false + +bool = isFloat16Array( new Uint8ClampedArray( 10 ) ); +console.log( bool ); +// => false + +bool = isFloat16Array( new Int16Array( 10 ) ); +console.log( bool ); +// => false + +bool = isFloat16Array( new Uint16Array( 10 ) ); +console.log( bool ); +// => false + +bool = isFloat16Array( new Int32Array( 10 ) ); +console.log( bool ); +// => false + +bool = isFloat16Array( new Uint32Array( 10 ) ); +console.log( bool ); +// => false + +bool = isFloat16Array( new Float32Array( 10 ) ); +console.log( bool ); +// => false + +bool = isFloat16Array( new Float64Array( 10 ) ); +console.log( bool ); +// => false + +bool = isFloat16Array( new Array( 10 ) ); +console.log( bool ); +// => false + +bool = isFloat16Array( {} ); +console.log( bool ); +// => false + +bool = isFloat16Array( null ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/assert/is-float16array/lib/index.js b/lib/node_modules/@stdlib/assert/is-float16array/lib/index.js new file mode 100644 index 000000000000..0d17a27a22c0 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/lib/index.js @@ -0,0 +1,44 @@ +/** +* @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 a value is a Float16Array. +* +* @module @stdlib/assert/is-float16array +* +* @example +* var isFloat16Array = require( '@stdlib/assert/is-float16array' ); +* +* var value = new Float16rray( 2 ); +* var bool = isFloat16Array( value ); +* // returns true +* +* bool = isFloat16Array( [] ); +* // returns false +*/ + +// MODULES // + +var isFloat16Array = require( './main.js' ); + + +// EXPORTS // + +module.exports = isFloat16Array; diff --git a/lib/node_modules/@stdlib/assert/is-float16array/lib/main.js b/lib/node_modules/@stdlib/assert/is-float16array/lib/main.js new file mode 100644 index 000000000000..5007ae6f0b2f --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/lib/main.js @@ -0,0 +1,60 @@ +/** +* @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 nativeClass = require( '@stdlib/utils/native-class' ); + + +// VARIABLES // + +var hasFloat16Array = ( typeof Float16Array === 'function' ); + + +// MAIN // + +/** +* Tests if a value is a Float16Array. +* +* @param {*} value - value to test +* @returns {boolean} boolean indicating whether value is a Float16Array +* +* @example +* var Float16Array = require( '@stdlib/array/float16' ); +* var isFloat16Array = require( '@stdlib/assert/is-float16array' ); +* +* var bool = isFloat16Array( new Float16Array( 10 ) ); +* // returns true +* +* bool = isFloat16Array( [] ); +* // returns false +*/ +function isFloat16Array( value ) { + return ( + ( hasFloat16Array && value instanceof Float16Array ) || + nativeClass( value ) === '[object Float16Array]' + ); +} + + +// EXPORTS // + +module.exports = isFloat16Array; diff --git a/lib/node_modules/@stdlib/assert/is-float16array/package.json b/lib/node_modules/@stdlib/assert/is-float16array/package.json new file mode 100644 index 000000000000..d3edb52f9726 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/package.json @@ -0,0 +1,77 @@ +{ + "name": "@stdlib/assert/is-float16array", + "version": "0.0.0", + "description": "Test if a value is a Float16Array.", + "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", + "float16array", + "float16", + "float", + "typed", + "typed array", + "typed-array", + "array", + "is", + "isarray", + "istypedarray", + "type", + "check", + "validate", + "valid", + "isvalid", + "test" + ] +} diff --git a/lib/node_modules/@stdlib/assert/is-float16array/test/test.js b/lib/node_modules/@stdlib/assert/is-float16array/test/test.js new file mode 100644 index 000000000000..605879ad682c --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/test/test.js @@ -0,0 +1,83 @@ +/** +* @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 Uint8Array = require( '@stdlib/array/uint8' ); +var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +var Int16Array = require( '@stdlib/array/int16' ); +var Uint16Array = require( '@stdlib/array/uint16' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Uint32Array = require( '@stdlib/array/uint32' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var isFloat16Array = require( './../lib' ); + + +// OPTIONS // + +var opts = { + 'skip': ( typeof Float16Array === 'undefined' ) +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isFloat16Array, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided a Float16Array', opts, function test( t ) { + t.strictEqual( isFloat16Array( new Float16Array( 10 ) ), true, 'returns true' ); + t.end(); +}); + +tape( 'the function returns `false` if not provided a Float16Array', function test( t ) { + var values = [ + '5', + 5, + NaN, + true, + null, + void 0, + [], + {}, + function noop() {}, + new Array( 10 ), + new Float64Array( 10 ), + new Uint32Array( 10 ), + new Int32Array( 10 ), + new Uint16Array( 10 ), + new Int16Array( 10 ), + new Uint8Array( 10 ), + new Int8Array( 10 ), + new Uint8ClampedArray( 10 ), + new Float32Array( 10 ) + ]; + + for ( var i = 0; i < values.length; i++ ) { + t.strictEqual( isFloat16Array( values[i] ), false, 'returns false when provided ' + values[i] ); + } + t.end(); +});