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..16b237390334 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/README.md @@ -0,0 +1,123 @@ + + +# 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]. + + + +```javascript +var 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 isFloat16Array = require( '@stdlib/assert/is-float16array' ); + +var 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( [] ); +// 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..fb7e41407a4c --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/benchmark/benchmark.js @@ -0,0 +1,136 @@ +/** +* @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' ); + + +// VARIABLES // + +// TODO: remove once `array/float16` is added +var Float16Array = ( typeof Float16Array === 'function' ) ? Float16Array : null; // eslint-disable-line no-use-before-define +var opts = { + 'skip': ( Float16Array === null ) +}; + + +// MAIN // + +bench( pkg, 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(); +}); + +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', 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..824930703e02 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/docs/repl.txt @@ -0,0 +1,25 @@ + +{{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 + -------- + // TODO: update to use `array/float16` once added + > var bool = {{alias}}( new {{alias:@stdlib/array/float32}}( 10 ) ) + false + > bool = {{alias}}( [] ) + false + + See Also + -------- + 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..9706f9090c64 --- /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 + +/** +* Tests if a value is a Float16Array. +* +* @param value - value to test +* @returns boolean indicating whether value is a Float16Array +* +* @example +* var Float16Array = require( '@stdlib/array/float16' ); +* +* var bool = isFloat16Array( new Float16Array( 10 ) ); +* // returns true +* +* @example +* var bool = isFloat16Array( [] ); +* // returns false +*/ +declare function isFloat16Array( value: any ): boolean; // TODO: replace with `value is Float16Array` once `array/float16` added + + +// 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..1f8ddf65f9dc --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/docs/types/test.ts @@ -0,0 +1,33 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import isFloat16Array = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isFloat16Array( [] ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isFloat16Array(); // $ExpectError + isFloat16Array( [], 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..6a4224cc9ed1 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/examples/index.js @@ -0,0 +1,80 @@ +/** +* @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 isFloat16Array = require( './../lib' ); + +// TODO: add example with Float16Array once `array/float16` is added + +var 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( [] ); +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..d7b41e8c959c --- /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 Float16Array = require( '@stdlib/array/float16' ); +* var isFloat16Array = require( '@stdlib/assert/is-float16array' ); +* +* var bool = isFloat16Array( new Float16Array( 10 ) ); +* // 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..c38ae627bc6a --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/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. +*/ + +/* eslint-disable no-undef, stdlib/jsdoc-doctest */ // TODO: remove once `array/float16` added; consider refactoring similar to `assert/is-complex128array` + +'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 bool = isFloat16Array( new Float16Array( 10 ) ); +* // returns true +* +* @example +* var 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..026b5b4dd334 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-float16array/test/test.js @@ -0,0 +1,76 @@ +/** +* @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' ); + + +// 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(); +}); + +// TODO: add positive assertion test once `array/float16` is added + +tape( 'the function returns `false` if not provided a Float16Array', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + null, + void 0, + [], + {}, + function noop() {}, + [], + 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 ( i = 0; i < values.length; i++ ) { + t.strictEqual( isFloat16Array( values[i] ), false, 'returns false when provided ' + values[i] ); + } + t.end(); +});