diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/README.md b/lib/node_modules/@stdlib/math/base/special/nanmin/README.md new file mode 100644 index 000000000000..abfff4de8715 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/README.md @@ -0,0 +1,82 @@ + + +# nanmin + +> Return the minimum value, ignoring NaN. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var nanmin = require( '@stdlib/math/base/special/nanmin' ); +``` + +#### nanmin( x, y ) + +Returns the minimum value. + +```javascript +var v = nanmin( 4.2, 3.14 ); +// returns 3.14 + +v = nanmin( +0.0, -0.0 ); +// returns -0.0 +``` + +If any argument is `NaN`, the function returns the other operand. + +```javascript +var v = nanmin( 4.2, NaN ); +// returns 4.2 + +v = nanmin( NaN, 3.14 ); +// returns 3.14 +``` + + +If both argument are `NaN`, the function returns `NaN`. + +```javascript +var v = nanmin( NaN, NaN ); +// returns NaN + +``` + +
+ + + + + +
+ +
diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js new file mode 100644 index 000000000000..14f6d10a2bb9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var nanmin = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var x; + var y; + var z; + var i; + + values = [ 3, 2, 2.0, 1.5, NaN ]; + x = 0.4; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = values[ i%values.length ]; + z = nanmin( x, y ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt new file mode 100644 index 000000000000..e44b922864f1 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt @@ -0,0 +1,33 @@ + +{{alias}}( x, y ) + Returns the minimum value. + + If one operand is NaN, the other operand is always returned. + + Parameters + ---------- + x: number + First number. + + y: number + Second number. + + Returns + ------- + out: number + Minimum value. + + Examples + -------- + > var v = {{alias}}( 3.14, 4.2 ) + 3.14 + > v = {{alias}}( 3.14, NaN ) + 3.14 + > v = {{alias}}( NaN, 4.2 ) + 4.2 + > v = {{alias}}( NaN, NaN ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts new file mode 100644 index 000000000000..925b7b65fc70 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts @@ -0,0 +1,45 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Return the minimum value, ignoring NaN. +* +* @param x - first number +* @param y - second number +* @returns minimum value +* +* @example +* var v = min( 3.14, 4.2 ); +* // returns 3.14 +* +* @example +* var v = min( 4.14, NaN ); +* // returns 4.14 +* +* @example +* var v = min( NaN, NaN ); +* // returns NaN +*/ +declare function nanmin( x: number, y: number ): number; + + +// EXPORTS // + +export = nanmin; diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/test.ts new file mode 100644 index 000000000000..660f6c323428 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/test.ts @@ -0,0 +1,51 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import nanmin = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + nanmin( 3.0, -0.4 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided non-number arguments... +{ + nanmin( true, 3.0 ); // $ExpectError + nanmin( false, 3.0 ); // $ExpectError + nanmin( [], 3.0 ); // $ExpectError + nanmin( {}, 3.0 ); // $ExpectError + nanmin( 'abc', 3.0 ); // $ExpectError + nanmin( ( x: number ): number => x, 3.0 ); // $ExpectError + + nanmin( 1.2, true ); // $ExpectError + nanmin( 1.2, false ); // $ExpectError + nanmin( 1.2, [] ); // $ExpectError + nanmin( 1.2, {} ); // $ExpectError + nanmin( 1.2, 'abc' ); // $ExpectError + nanmin( 1.2, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + nanmin(); // $ExpectError + nanmin( 3.0 ); // $ExpectError + nanmin( 3.0, 2.0, 1.0 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js new file mode 100644 index 000000000000..2d8bb2b500ea --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var nanmin = require( './../lib' ); + +var m = nanmin( 3.0, 4.0 ); +// returns 3.0 + +m = nanmin( NaN, 4.0 ); +// returns 4.0 + +m = nanmin( 4.0, NaN ); +// returns 4.0 + +m = nanmin( NaN, NaN ); +// returns NaN + +console.log(m); diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js new file mode 100644 index 000000000000..e581e527f13e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js @@ -0,0 +1,46 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Return the minimum value, ignoring NaN. +* +* @module @stdlib/math/base/special/nanmin +* +* @example +* var nanmin = require( '@stdlib/math/base/special/nanmin' ); +* +* var v = nanmin( 3.14, 4.2 ); +* // returns 3.14 +* +* v = nanmin( 4.14, NaN ); +* // returns 4.14 +* +* v = nanmin( NaN, NaN ); +* // returns NaN +*/ + +// MODULES // + +var nanmin = require( './main.js' ); + + +// EXPORTS // + +module.exports = nanmin; diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js new file mode 100644 index 000000000000..6ab28cabb103 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -0,0 +1,58 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var min = require( '@stdlib/math/base/special/min'); +var isnan = require( '@stdlib/math/base/assert/is-nan'); + + +// MAIN // + +/** +* Return the minimum value, ignoring NaN. +* +* @param {number} x - first number +* @param {number} y - second number +* @returns {number} minimum value +* +* @example +* var v = nanmin( 3.14, 4.2 ); +* // returns 3.14 +* +* @example +* var v = nanmin( 4.14, NaN ); +* // returns 4.14 +* +* @example +* var v = nanmin( NaN, NaN); +* // returns NaN +*/ +function nanmin( x, y ) { + if ( isnan( x ) ) { + return ( isnan(y) ) ? NaN : y; + } + return ( isnan( y ) ) ? x : min( x, y ); +} + + +// EXPORTS // + +module.exports = nanmin; diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/package.json b/lib/node_modules/@stdlib/math/base/special/nanmin/package.json new file mode 100644 index 000000000000..7edce079bd16 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/package.json @@ -0,0 +1,61 @@ +{ + "name": "@stdlib/math/base/special/nanmin", + "version": "0.0.0", + "description": "Returns the minimum value, ignoring 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", + "mathematics", + "math", + "math.min", + "minimum", + "min", + "smallest" + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js new file mode 100644 index 000000000000..dc2ce765694e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js @@ -0,0 +1,66 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var nanmin = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nanmin, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` if both operands are `NaN`', function test( t ) { + var v; + + v = nanmin( NaN, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN value' ); + t.end(); +}); + +tape( 'the function returns the non-NaN value if one of the operands is `NaN`', function test( t ) { + var v; + + v = nanmin( NaN, 3.14 ); + t.strictEqual( v, 3.14, 'returns not NaN value' ); + + v = nanmin( 4.2, NaN ); + t.strictEqual( v, 4.2, 'returns not NaN value' ); + + t.end(); +}); + +tape( 'the function returns the minimum value', function test( t ) { + var v; + + v = nanmin( 5.2, 3.14 ); + t.strictEqual( v, 3.14, 'returns min value' ); + + v = nanmin( -4.2, 3.14 ); + t.strictEqual( v, -4.2, 'returns min value' ); + + t.end(); +});