diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/README.md b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/README.md new file mode 100644 index 000000000000..f86f5d54ed5c --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/README.md @@ -0,0 +1,80 @@ + + +# isnan + +> Test if a half-precision floating-point numeric value is NaN. + +
+ +## Usage + +```javascript +var isnan = require( '@stdlib/number/float16/base/assert/is-nan' ); +``` + +#### isnan( x ) + +Tests if a half-precision floating-point `numeric` value is `NaN`. + +```javascript +var bool = isnan( NaN ); +// returns true +``` + +
+ + + +
+ +## Examples + + + +```javascript +var isnan = require( '@stdlib/number/float16/base/assert/is-nan' ); + +var bool = isnan( NaN ); +// returns true + +bool = isnan( 5.0 ); +// returns false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/benchmark/benchmark.js b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/benchmark/benchmark.js new file mode 100644 index 000000000000..2034533bc313 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/benchmark/benchmark.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var toFloat16 = require( '@stdlib/number/float64/base/to-float16' ); +var map = require( '@stdlib/array/base/map' ); +var naryFunction = require( '@stdlib/utils/nary-function' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var isnan = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var x; + var y; + var i; + + x = map( uniform( 100, -5.0e6, 5.0e6 ), naryFunction( toFloat16, 1 ) ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = isnan( x[ i%x.length ] ); + if ( typeof y !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( y ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/docs/repl.txt b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/docs/repl.txt new file mode 100644 index 000000000000..889ff4104b9f --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/docs/repl.txt @@ -0,0 +1,24 @@ + +{{alias}}( x ) + Tests if a half-precision floating-point numeric value is `NaN`. + + Parameters + ---------- + x: number + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating whether the value is `NaN`. + + Examples + -------- + > var bool = {{alias}}( NaN ) + true + > bool = {{alias}}( 7.0 ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/docs/types/index.d.ts b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/docs/types/index.d.ts new file mode 100644 index 000000000000..3258788a177b --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/docs/types/index.d.ts @@ -0,0 +1,40 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Tests if a half-precision floating-point numeric value is `NaN`. +* +* @param x - value to test +* @returns boolean indicating whether the value is `NaN` +* +* @example +* var bool = isnan( NaN ); +* // returns true +* +* @example +* var bool = isnan( 7.0 ); +* // returns false +*/ +declare function isnan( x: number ): boolean; + + +// EXPORTS // + +export = isnan; diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/docs/types/test.ts b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/docs/types/test.ts new file mode 100644 index 000000000000..1ed989ca7dc1 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/docs/types/test.ts @@ -0,0 +1,46 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import isnan = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isnan( NaN ); // $ExpectType boolean + isnan( 2 ); // $ExpectType boolean + isnan( 3 ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided a value other than a number... +{ + isnan( true ); // $ExpectError + isnan( false ); // $ExpectError + isnan( null ); // $ExpectError + isnan( undefined ); // $ExpectError + isnan( [] ); // $ExpectError + isnan( {} ); // $ExpectError + isnan( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isnan(); // $ExpectError + isnan( undefined, 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/examples/index.js b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/examples/index.js new file mode 100644 index 000000000000..db1ca4d4fd71 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/examples/index.js @@ -0,0 +1,27 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var isnan = require( './../lib' ); + +console.log( isnan( NaN ) ); +// => true + +console.log( isnan( 5 ) ); +// => false diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/lib/index.js b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/lib/index.js new file mode 100644 index 000000000000..46b0e9b67123 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/lib/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Test if a half-precision floating-point numeric value is `NaN`. +* +* @module @stdlib/number/float16/base/assert/is-nan +* +* @example +* var isnan = require( '@stdlib/number/float16/base/assert/is-nan' ); +* +* var bool = isnan( NaN ); +* // returns true +* +* bool = isnan( 7.0 ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/lib/main.js b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/lib/main.js new file mode 100644 index 000000000000..ffbb65dc6d12 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/lib/main.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Tests if a half-precision floating-point numeric value is `NaN`. +* +* @param {number} x - value to test +* @returns {boolean} boolean indicating whether the value is `NaN` +* +* @example +* var bool = isnan( NaN ); +* // returns true +* +* @example +* var bool = isnan( 7.0 ); +* // returns false +*/ +function isnan( x ) { + return ( x !== x ); +} + + +// EXPORTS // + +module.exports = isnan; diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/package.json b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/package.json new file mode 100644 index 000000000000..dfa426c21b3a --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/package.json @@ -0,0 +1,75 @@ +{ + "name": "@stdlib/number/float16/base/assert/is-nan", + "version": "0.0.0", + "description": "Test if a half-precision floating-point numeric value is NaN.", + "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", + "stdmath", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "math", + "mathematics", + "ieee754", + "floating-point", + "float", + "number", + "numeric", + "non-numeric", + "nan", + "is", + "isnan", + "type", + "check" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/test/test.js b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/test/test.js new file mode 100644 index 000000000000..50807643f0c0 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-nan/test/test.js @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Number = require( '@stdlib/number/ctor' ); +var isnan = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isnan, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided `NaN`', function test( t ) { + t.strictEqual( isnan( NaN ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `false` if not provided `NaN`', function test( t ) { + var values; + var i; + + values = [ + '5', + 5.0, + true, + false, + null, + void 0, + [], + {}, + function noop() {}, + new Number( NaN ) + ]; + + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isnan( values[i] ), false, 'returns expected value when provided ' + values[ i ] ); + } + t.end(); +});