From 0f2c4d6209b084c45830d18f1b4e8508d39d2f8d Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 00:54:37 +0530 Subject: [PATCH 01/37] Added @stdlib/math/base/special/nanmin --- .../math/base/special/nanmin/README.md | 118 ++++++++++++++++++ .../special/nanmin/benchmark/benchmark.js | 56 +++++++++ .../math/base/special/nanmin/docs/repl.txt | 33 +++++ .../base/special/nanmin/docs/types/index.d.ts | 45 +++++++ .../base/special/nanmin/docs/types/test.ts | 51 ++++++++ .../base/special/nanmin/examples/index.js | 35 ++++++ .../math/base/special/nanmin/lib/index.js | 46 +++++++ .../math/base/special/nanmin/lib/main.js | 64 ++++++++++ .../math/base/special/nanmin/package.json | 61 +++++++++ .../math/base/special/nanmin/test/test.js | 68 ++++++++++ 10 files changed, 577 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/README.md create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/package.json create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js 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..d75e3d98e57d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/README.md @@ -0,0 +1,118 @@ + + +# nanmin + +> If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum + + + +
+ +
+ + + + + +
+ +## 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 `other operand`. + +```javascript +var v = nanmin( 4.2, NaN ); +// returns 4.2 + +v = nanmin( NaN, 3.14 ); +// returns 3.14 +``` + + +If both argument is `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..2a899e10b3bd --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 randu = require( '@stdlib/random/base/randu' ); +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 x; + var y; + var z; + var i; + + values = [3, 2, 1.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..ab3e572596ad --- /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; otherwise, perform normal minimum. + + 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..37cb184f8fcb --- /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) 2019 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 + +/** +* If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum. +* +* @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( 3.14, NaN ); +* // returns 3.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..73fefa8f9c8d --- /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) 2019 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.2 ); // $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..52a704e03442 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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( 3.0, NaN ); +// returns 3.0 + +m = nanmin( NaN, NaN ); +// returns NaN \ No newline at end of file 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..bbd1025b68c9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js @@ -0,0 +1,46 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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'; + +/** +* If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum. +* +* @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( 3.14, NaN ); +* // returns 3.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..c251ee562843 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 // + +/** +* If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum. +* +* @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( 3.14, NaN ); +* // returns 3.14 +* +* @example +* var v = nanmin( NaN, NaN); +* // returns NaN +*/ +function nanmin( x, y ) { + if (isnan(x) && isnan(y)) { + return NaN; + } else if (isnan(x)) { + return y; + } else if (isnan(y)) { + return x; + } else { + return 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..6561ccab2695 --- /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": "If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum", + "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..03d07866ad49 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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' ); + + + t.end(); +}); + +tape( 'the function returns `Not NaN Value` if one of the operand 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( 4.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(); +}); From d144bb4acd8b26dbf3fdfe7158b339519a2bbe47 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 07:29:32 +0530 Subject: [PATCH 02/37] Added @stdlib/math/base/special/nanmin --- .../@stdlib/math/base/special/nanmin/benchmark/benchmark.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 2a899e10b3bd..d2ce2fe7a13e 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js @@ -21,7 +21,6 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var nanmin = require( './../lib' ); @@ -30,6 +29,7 @@ var nanmin = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { + var values; var x; var y; var z; From 78d82a3774d8bb757aa612237d7bc87be59496a2 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 09:38:46 +0530 Subject: [PATCH 03/37] Added @stdlib/math/base/special/nanmin --- .../math/base/special/nanmin/lib/main.js | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) 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 index c251ee562843..174e291728c8 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -20,10 +20,8 @@ // MODULES // -var min = require( '@stdlib/math/base/special/min' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); - - +var min = require( '@stdlib/math/base/special/min'); +var isnan = require( '@stdlib/math/base/assert/is-nan'); // MAIN // @@ -48,17 +46,17 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); */ function nanmin( x, y ) { if (isnan(x) && isnan(y)) { - return NaN; - } else if (isnan(x)) { - return y; - } else if (isnan(y)) { - return x; - } else { - return min(x, y); - } + return NaN; + } + if (isnan(x)) { + return y; + } + if (isnan(y)) { + return x; + } + return min(x, y); } - // EXPORTS // module.exports = nanmin; From cf88b61225b761d1a6903eeea964cbb2ddadb0b9 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 13:04:02 +0530 Subject: [PATCH 04/37] Added @stdlib/math/base/special/nanmin --- lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index ab3e572596ad..e44b922864f1 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/docs/repl.txt @@ -2,7 +2,7 @@ {{alias}}( x, y ) Returns the minimum value. - If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum. + If one operand is NaN, the other operand is always returned. Parameters ---------- From 4a1e103bd2020e737a4d632a255c9402791814f8 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 15:22:52 +0530 Subject: [PATCH 05/37] Added @stdlib/math/base/special/nanmin --- lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js | 2 ++ 1 file changed, 2 insertions(+) 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 index 174e291728c8..5ee1298e434e 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -23,6 +23,7 @@ var min = require( '@stdlib/math/base/special/min'); var isnan = require( '@stdlib/math/base/assert/is-nan'); + // MAIN // /** @@ -57,6 +58,7 @@ function nanmin( x, y ) { return min(x, y); } + // EXPORTS // module.exports = nanmin; From aeb3795b92b3918f54efe6ef6da59834a9f25c63 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 15:31:16 +0530 Subject: [PATCH 06/37] Added @stdlib/math/base/special/nanmin --- .../@stdlib/math/base/special/nanmin/examples/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 index 52a704e03442..d2a07d7272fa 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js @@ -18,18 +18,20 @@ 'use strict'; - var nanmin = require( './../lib' ); - var m = nanmin( 3.0, 4.0 ); +console.log(m) // returns 3.0 m = nanmin( NaN, 4.0 ); +console.log(m) // returns 4.0 m = nanmin( 3.0, NaN ); +console.log(m) // returns 3.0 m = nanmin( NaN, NaN ); -// returns NaN \ No newline at end of file +console.log(m) +// returns NaN From 4ff14fc45659ee3b522c00e8ec839da7861d96cd Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 15:36:18 +0530 Subject: [PATCH 07/37] Added @stdlib/math/base/special/nanmin --- .../@stdlib/math/base/special/nanmin/examples/index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 index d2a07d7272fa..2e550b25f77e 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js @@ -21,17 +21,15 @@ var nanmin = require( './../lib' ); var m = nanmin( 3.0, 4.0 ); -console.log(m) // returns 3.0 m = nanmin( NaN, 4.0 ); -console.log(m) // returns 4.0 m = nanmin( 3.0, NaN ); -console.log(m) // returns 3.0 m = nanmin( NaN, NaN ); -console.log(m) // returns NaN + +console.log(m); From b1edc3deef8afe46a80e0bb64a65638527b910a7 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 20:16:13 +0530 Subject: [PATCH 08/37] feat: added @stdlib/math/base/special/nanmin --- .../@stdlib/math/base/special/nanmin/benchmark/benchmark.js | 3 +-- .../@stdlib/math/base/special/nanmin/test/test.js | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) 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 index d2ce2fe7a13e..fa985f7862ca 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js @@ -36,7 +36,7 @@ bench( pkg, function benchmark( b ) { var i; values = [3, 2, 1.0, 1.5, NaN]; - x = 0.4 + x = 0.4; b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -53,4 +53,3 @@ bench( pkg, function benchmark( b ) { b.pass( 'benchmark finished' ); b.end(); }); - 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 index 03d07866ad49..df1f99225fc8 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js @@ -37,9 +37,7 @@ 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' ); - - + t.strictEqual( isnan( v ), true, 'returns NaN value' ); t.end(); }); From 6460912a33b35ff616ae200f4d37e36fa48c7f85 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 9 Jun 2024 22:37:49 +0530 Subject: [PATCH 09/37] feat: added @stdlib/math/base/special/nanmin --- .../@stdlib/math/base/special/nanmin/benchmark/benchmark.js | 2 +- .../@stdlib/math/base/special/nanmin/docs/types/index.d.ts | 4 ++-- .../@stdlib/math/base/special/nanmin/docs/types/test.ts | 2 +- .../@stdlib/math/base/special/nanmin/examples/index.js | 4 ++-- .../@stdlib/math/base/special/nanmin/lib/index.js | 4 ++-- lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js | 4 ++-- .../@stdlib/math/base/special/nanmin/test/test.js | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) 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 index fa985f7862ca..6f8ccfece1b5 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js @@ -35,7 +35,7 @@ bench( pkg, function benchmark( b ) { var z; var i; - values = [3, 2, 1.0, 1.5, NaN]; + values = [3, 2, 2.0, 1.5, NaN]; x = 0.4; b.tic(); 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 index 37cb184f8fcb..d20b1b45e0a7 100644 --- 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 @@ -30,8 +30,8 @@ * // returns 3.14 * * @example -* var v = min( 3.14, NaN ); -* // returns 3.14 +* var v = min( 4.14, NaN ); +* // returns 4.14 * * @example * var v = min( NaN, NaN ); 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 index 73fefa8f9c8d..08f7f8316fef 100644 --- 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 @@ -23,7 +23,7 @@ import nanmin = require( './index' ); // The function returns a number... { - nanmin( 3.0, -0.2 ); // $ExpectType number + nanmin( 3.0, -0.4 ); // $ExpectType number } // The compiler throws an error if the function is provided non-number arguments... 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 index 2e550b25f77e..07c39ba4c2bb 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js @@ -26,8 +26,8 @@ var m = nanmin( 3.0, 4.0 ); m = nanmin( NaN, 4.0 ); // returns 4.0 -m = nanmin( 3.0, NaN ); -// returns 3.0 +m = nanmin( 4.0, NaN ); +// returns 4.0 m = nanmin( NaN, NaN ); // returns NaN 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 index bbd1025b68c9..2e58997f7496 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js @@ -29,8 +29,8 @@ * var v = nanmin( 3.14, 4.2 ); * // returns 3.14 * -* v = nanmin( 3.14, NaN ); -* // returns 3.14 +* v = nanmin( 4.14, NaN ); +* // returns 4.14 * * v = nanmin( NaN, NaN ); * // returns NaN 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 index 5ee1298e434e..31b447bf9832 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -38,8 +38,8 @@ var isnan = require( '@stdlib/math/base/assert/is-nan'); * // returns 3.14 * * @example -* var v = nanmin( 3.14, NaN ); -* // returns 3.14 +* var v = nanmin( 4.14, NaN ); +* // returns 4.14 * * @example * var v = nanmin( NaN, NaN); 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 index df1f99225fc8..9c43540f20fc 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js @@ -56,7 +56,7 @@ tape( 'the function returns `Not NaN Value` if one of the operand is `NaN`', fun tape( 'the function returns the minimum value', function test( t ) { var v; - v = nanmin( 4.2, 3.14 ); + v = nanmin( 5.2, 3.14 ); t.strictEqual( v, 3.14, 'returns min value' ); v = nanmin( -4.2, 3.14 ); From 5ccd941caa6aa5c9f4482dbe6264ec3fb2bf77bd Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sun, 9 Jun 2024 21:16:39 +0000 Subject: [PATCH 10/37] chore: update copyright years --- .../@stdlib/math/base/special/nanmin/benchmark/benchmark.js | 2 +- .../@stdlib/math/base/special/nanmin/docs/types/index.d.ts | 2 +- .../@stdlib/math/base/special/nanmin/docs/types/test.ts | 2 +- .../@stdlib/math/base/special/nanmin/examples/index.js | 2 +- lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js | 2 +- lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js | 2 +- lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) 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 index 6f8ccfece1b5..8b958a5fa262 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. 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 index d20b1b45e0a7..8db73944a607 100644 --- 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 @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* 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. 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 index 08f7f8316fef..660f6c323428 100644 --- 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 @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* 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. 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 index 07c39ba4c2bb..2d8bb2b500ea 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. 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 index 2e58997f7496..19088dc05b06 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. 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 index 31b447bf9832..1ef5d97b8281 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. 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 index 9c43540f20fc..cead9d86f692 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. From 4a4f8f307e983e9a7b84bc143bdc663811633743 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Mon, 10 Jun 2024 13:10:11 +0530 Subject: [PATCH 11/37] feat: added @stdlib/math/base/special/nanmin --- .../math/base/special/nanmin/benchmark/benchmark.js | 2 +- .../math/base/special/nanmin/docs/types/index.d.ts | 2 +- .../@stdlib/math/base/special/nanmin/lib/index.js | 2 +- .../@stdlib/math/base/special/nanmin/lib/main.js | 12 +++--------- .../@stdlib/math/base/special/nanmin/package.json | 2 +- .../@stdlib/math/base/special/nanmin/test/test.js | 2 +- 6 files changed, 8 insertions(+), 14 deletions(-) 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 index 6f8ccfece1b5..03fd4e293b57 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/benchmark/benchmark.js @@ -35,7 +35,7 @@ bench( pkg, function benchmark( b ) { var z; var i; - values = [3, 2, 2.0, 1.5, NaN]; + values = [ 3, 2, 2.0, 1.5, NaN ]; x = 0.4; b.tic(); 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 index d20b1b45e0a7..0e8d6823248c 100644 --- 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 @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /** -* If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum. +* Return the minimum value, ignoring NaN. * * @param x - first number * @param y - second number 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 index 2e58997f7496..5ca03f5f3b5b 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum. +* Return the minimum value, ignoring NaN. * * @module @stdlib/math/base/special/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 index 31b447bf9832..1d1979cb0e51 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -27,7 +27,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan'); // MAIN // /** -* If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum. +* Return the minimum value, ignoring NaN. * * @param {number} x - first number * @param {number} y - second number @@ -46,16 +46,10 @@ var isnan = require( '@stdlib/math/base/assert/is-nan'); * // returns NaN */ function nanmin( x, y ) { - if (isnan(x) && isnan(y)) { - return NaN; - } if (isnan(x)) { - return y; - } - if (isnan(y)) { - return x; + return (( isnan(y) ) ? NaN : y); } - return min(x, y); + return (( isnan(y) ) ? x : min(x, y)); } diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/package.json b/lib/node_modules/@stdlib/math/base/special/nanmin/package.json index 6561ccab2695..7edce079bd16 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/package.json +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/math/base/special/nanmin", "version": "0.0.0", - "description": "If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum", + "description": "Returns the minimum value, ignoring NaN.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", 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 index 9c43540f20fc..1f2dfef30096 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/test/test.js @@ -41,7 +41,7 @@ tape( 'the function returns `NaN` if both operands are `NaN`', function test( t t.end(); }); -tape( 'the function returns `Not NaN Value` if one of the operand is `NaN`', function test( t ) { +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 ); From 4a8425eb4609949085b65bf95a813e1d3f6f7a6c Mon Sep 17 00:00:00 2001 From: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> Date: Mon, 10 Jun 2024 13:25:14 +0530 Subject: [PATCH 12/37] feat: added @stdlib/math/base/special/nanmin Signed-off-by: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> --- .../math/base/special/nanmin/README.md | 42 ++----------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/README.md b/lib/node_modules/@stdlib/math/base/special/nanmin/README.md index d75e3d98e57d..abfff4de8715 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/README.md +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/README.md @@ -20,7 +20,7 @@ limitations under the License. # nanmin -> If one operand is NaN, the other operand is always returned; otherwise, perform normal minimum +> Return the minimum value, ignoring NaN. @@ -52,7 +52,7 @@ v = nanmin( +0.0, -0.0 ); // returns -0.0 ``` -If any argument is `NaN`, the function returns `other operand`. +If any argument is `NaN`, the function returns the other operand. ```javascript var v = nanmin( 4.2, NaN ); @@ -63,7 +63,7 @@ v = nanmin( NaN, 3.14 ); ``` -If both argument is `NaN`, the function returns `NaN`. +If both argument are `NaN`, the function returns `NaN`. ```javascript var v = nanmin( NaN, NaN ); @@ -80,39 +80,3 @@ var v = nanmin( NaN, NaN );
- - - - - - - - - - - - - - From 0118ae03354de2247ede1f8fc8240167462b3178 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Mon, 10 Jun 2024 08:57:49 -0400 Subject: [PATCH 13/37] Update lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js Signed-off-by: Philipp Burckhardt --- .../@stdlib/math/base/special/nanmin/lib/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 index 647a77e91446..6ab28cabb103 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -46,10 +46,10 @@ var isnan = require( '@stdlib/math/base/assert/is-nan'); * // returns NaN */ function nanmin( x, y ) { - if (isnan(x)) { - return (( isnan(y) ) ? NaN : y); + if ( isnan( x ) ) { + return ( isnan(y) ) ? NaN : y; } - return (( isnan(y) ) ? x : min(x, y)); + return ( isnan( y ) ) ? x : min( x, y ); } From ebbc3162f84aa6044f05439d65250bbb386bb4f5 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Tue, 11 Jun 2024 23:34:09 +0530 Subject: [PATCH 14/37] feat: add @stdlib/math/base/special/nanmax --- .../special/nanmax/benchmark/benchmark.js | 55 ++++++++++++++++ .../base/special/nanmax/docs/types/index.d.ts | 45 +++++++++++++ .../base/special/nanmax/docs/types/test.ts | 51 ++++++++++++++ .../base/special/nanmax/examples/index.js | 37 +++++++++++ .../math/base/special/nanmax/lib/index.js | 46 +++++++++++++ .../math/base/special/nanmax/lib/main.js | 58 ++++++++++++++++ .../math/base/special/nanmax/package.json | 61 +++++++++++++++++ .../math/base/special/nanmax/test/test.js | 66 +++++++++++++++++++ .../base/special/nanmin/examples/index.js | 4 +- .../math/base/special/nanmin/lib/main.js | 2 +- 10 files changed, 423 insertions(+), 2 deletions(-) create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/examples/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/package.json create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/test/test.js diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/nanmax/benchmark/benchmark.js new file mode 100644 index 000000000000..fb6b2b185245 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/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 nanmax = 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 = nanmax( 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/nanmax/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/index.d.ts new file mode 100644 index 000000000000..ff74e7a9efa2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/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 maximum value, ignoring NaN. +* +* @param x - first number +* @param y - second number +* @returns maximum value +* +* @example +* var v = nanmax( 3.14, 4.2 ); +* // returns 4.2 +* +* @example +* var v = nanmax( 4.14, NaN ); +* // returns 4.14 +* +* @example +* var v = nanmax( NaN, NaN ); +* // returns NaN +*/ +declare function nanmax( x: number, y: number ): number; + + +// EXPORTS // + +export = nanmax; diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/test.ts new file mode 100644 index 000000000000..78e080627a01 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/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 nanmax = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + nanmax( 3.0, -0.4 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided non-number arguments... +{ + nanmax( true, 3.0 ); // $ExpectError + nanmax( false, 3.0 ); // $ExpectError + nanmax( [], 3.0 ); // $ExpectError + nanmax( {}, 3.0 ); // $ExpectError + nanmax( 'abc', 3.0 ); // $ExpectError + nanmax( ( x: number ): number => x, 3.0 ); // $ExpectError + + nanmax( 1.2, true ); // $ExpectError + nanmax( 1.2, false ); // $ExpectError + nanmax( 1.2, [] ); // $ExpectError + nanmax( 1.2, {} ); // $ExpectError + nanmax( 1.2, 'abc' ); // $ExpectError + nanmax( 1.2, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + nanmax(); // $ExpectError + nanmax( 3.0 ); // $ExpectError + nanmax( 3.0, 2.0, 1.0 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/examples/index.js b/lib/node_modules/@stdlib/math/base/special/nanmax/examples/index.js new file mode 100644 index 000000000000..902c9cd36e2a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/examples/index.js @@ -0,0 +1,37 @@ +/** +* @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 nanmax = require( './../lib' ); + +var m = nanmax( 3.0, 4.0 ); +// returns 4.0 +console.log(m); + +m = nanmax( NaN, 4.0 ); +// returns 4.0 +console.log(m); + +m = nanmax( 4.0, NaN ); +// returns 4.0 +console.log(m); + +m = nanmax( NaN, NaN ); +// returns NaN +console.log(m); diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/lib/index.js b/lib/node_modules/@stdlib/math/base/special/nanmax/lib/index.js new file mode 100644 index 000000000000..b11c08d56d73 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/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 maximum value, ignoring NaN. +* +* @module @stdlib/math/base/special/nanmax +* +* @example +* var nanmax = require( '@stdlib/math/base/special/nanmax' ); +* +* var v = nanmax( 3.14, 4.2 ); +* // returns 4.2 +* +* v = nanmax( 4.14, NaN ); +* // returns 4.14 +* +* v = nanmax( NaN, NaN ); +* // returns NaN +*/ + +// MODULES // + +var nanmax = require( './main.js' ); + + +// EXPORTS // + +module.exports = nanmax; diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/lib/main.js b/lib/node_modules/@stdlib/math/base/special/nanmax/lib/main.js new file mode 100644 index 000000000000..5d2b73ac2c07 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/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 max = require( '@stdlib/math/base/special/max'); +var isnan = require( '@stdlib/math/base/assert/is-nan'); + + +// MAIN // + +/** +* Return the maximum value, ignoring NaN. +* +* @param {number} x - first number +* @param {number} y - second number +* @returns {number} minimum value +* +* @example +* var v = nanmax( 3.14, 4.2 ); +* // returns 4.2 +* +* @example +* var v = nanmax( 4.14, NaN ); +* // returns 4.14 +* +* @example +* var v = nanmax( NaN, NaN); +* // returns NaN +*/ +function nanmax( x, y ) { + if ( isnan( x ) ) { + return ( isnan( y ) ) ? NaN : y; + } + return ( isnan( y ) ) ? x : max( x, y ); +} + + +// EXPORTS // + +module.exports = nanmax; diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/package.json b/lib/node_modules/@stdlib/math/base/special/nanmax/package.json new file mode 100644 index 000000000000..5fcbaa47a111 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/package.json @@ -0,0 +1,61 @@ +{ + "name": "@stdlib/math/base/special/nanmax", + "version": "0.0.0", + "description": "Returns the maximum 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/nanmax/test/test.js b/lib/node_modules/@stdlib/math/base/special/nanmax/test/test.js new file mode 100644 index 000000000000..122ca6655603 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/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 nanmax = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof nanmax, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` if both operands are `NaN`', function test( t ) { + var v; + + v = nanmax( 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 = nanmax( NaN, 3.14 ); + t.strictEqual( v, 3.14, 'returns not NaN value' ); + + v = nanmax( 4.2, NaN ); + t.strictEqual( v, 4.2, 'returns not NaN value' ); + + t.end(); +}); + +tape( 'the function returns the maximum value', function test( t ) { + var v; + + v = nanmax( 5.2, 3.14 ); + t.strictEqual( v, 5.2, 'returns max value' ); + + v = nanmax( -4.2, 3.14 ); + t.strictEqual( v, 3.14, 'returns max value' ); + + t.end(); +}); 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 index 2d8bb2b500ea..5b9a292241ff 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/examples/index.js @@ -22,14 +22,16 @@ var nanmin = require( './../lib' ); var m = nanmin( 3.0, 4.0 ); // returns 3.0 +console.log(m); m = nanmin( NaN, 4.0 ); // returns 4.0 +console.log(m); m = nanmin( 4.0, NaN ); // returns 4.0 +console.log(m); m = nanmin( NaN, NaN ); // returns NaN - console.log(m); 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 index 6ab28cabb103..f7ce9931e4c5 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/lib/main.js @@ -47,7 +47,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan'); */ function nanmin( x, y ) { if ( isnan( x ) ) { - return ( isnan(y) ) ? NaN : y; + return ( isnan( y ) ) ? NaN : y; } return ( isnan( y ) ) ? x : min( x, y ); } From b66ba8e2189228da16d006ddf0e772102ce46871 Mon Sep 17 00:00:00 2001 From: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> Date: Tue, 11 Jun 2024 23:46:38 +0530 Subject: [PATCH 15/37] feat: add math/base/special/nanmax Signed-off-by: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> --- .../@stdlib/math/base/special/nanmin/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmin/README.md b/lib/node_modules/@stdlib/math/base/special/nanmin/README.md index abfff4de8715..cfda2816d903 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmin/README.md +++ b/lib/node_modules/@stdlib/math/base/special/nanmin/README.md @@ -80,3 +80,20 @@ var v = nanmin( NaN, NaN );
+ + + + + + + + + + + From 169c7675a874ae5b1094bb1a8c729665c475db62 Mon Sep 17 00:00:00 2001 From: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> Date: Tue, 11 Jun 2024 23:48:23 +0530 Subject: [PATCH 16/37] feat: add math/base/special/nanmax Signed-off-by: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> --- .../base/special/nanmax/docs/types/repl.txt | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/repl.txt diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/repl.txt b/lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/repl.txt new file mode 100644 index 000000000000..919ef176e635 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/repl.txt @@ -0,0 +1,33 @@ + +{{alias}}( x, y ) + Returns the maximum value. + + If one operand is NaN, the other operand is always returned. + + Parameters + ---------- + x: number + First number. + + y: number + Second number. + + Returns + ------- + out: number + Maximum value. + + Examples + -------- + > var v = {{alias}}( 3.14, 4.2 ) + 4.2 + > v = {{alias}}( 3.14, NaN ) + 3.14 + > v = {{alias}}( NaN, 4.2 ) + 4.2 + > v = {{alias}}( NaN, NaN ) + NaN + + See Also + -------- + From 2ad13235a68921162630ae4f3c78eeaedb817499 Mon Sep 17 00:00:00 2001 From: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> Date: Tue, 11 Jun 2024 23:50:01 +0530 Subject: [PATCH 17/37] feat: add math/base/special/nanmax Signed-off-by: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> --- .../math/base/special/nanmax/README.md | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/README.md diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/README.md b/lib/node_modules/@stdlib/math/base/special/nanmax/README.md new file mode 100644 index 000000000000..9e51b2c9885a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/README.md @@ -0,0 +1,101 @@ + + +# nanmin + +> Return the maximum value, ignoring NaN. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var nanmax = require( '@stdlib/math/base/special/nanmax' ); +``` + +#### nanmin( x, y ) + +Returns the maximum value. + +```javascript +var v = nanmax( 4.2, 3.14 ); +// returns 4.2 + +v = nanmax( +0.0, -0.0 ); +// returns +0.0 +``` + +If any argument is `NaN`, the function returns the other operand. + +```javascript +var v = nanmax( 4.2, NaN ); +// returns 4.2 + +v = nanmax( NaN, 3.14 ); +// returns 3.14 +``` + + +If both argument are `NaN`, the function returns `NaN`. + +```javascript +var v = nanmax( NaN, NaN ); +// returns NaN + +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + From 79ffdf950f4c5b53f0c83c7ecc70ed9c8a0ed57d Mon Sep 17 00:00:00 2001 From: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> Date: Wed, 12 Jun 2024 00:10:50 +0530 Subject: [PATCH 18/37] feat: add @stdlib/math/base/special/nanmax Signed-off-by: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/nanmax/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/README.md b/lib/node_modules/@stdlib/math/base/special/nanmax/README.md index 9e51b2c9885a..989cfce404f6 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmax/README.md +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/README.md @@ -18,7 +18,7 @@ limitations under the License. --> -# nanmin +# nanmax > Return the maximum value, ignoring NaN. @@ -40,7 +40,7 @@ limitations under the License. var nanmax = require( '@stdlib/math/base/special/nanmax' ); ``` -#### nanmin( x, y ) +#### nanmax( x, y ) Returns the maximum value. @@ -98,4 +98,3 @@ var v = nanmax( NaN, NaN ); - From 43d5904bccb8b22830412ef8b5118707ad8b78f5 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 11 Jun 2024 22:45:29 -0400 Subject: [PATCH 19/37] chore: minor clean-up Signed-off-by: Philipp Burckhardt --- .../@stdlib/math/base/special/nanmax/README.md | 9 ++++----- .../math/base/special/nanmax/examples/index.js | 16 ++++++++-------- .../@stdlib/math/base/special/nanmax/lib/main.js | 4 ++-- .../math/base/special/nanmax/package.json | 8 ++++---- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/README.md b/lib/node_modules/@stdlib/math/base/special/nanmax/README.md index 989cfce404f6..96d924657949 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmax/README.md +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/README.md @@ -62,15 +62,14 @@ v = nanmax( NaN, 3.14 ); // returns 3.14 ``` - -If both argument are `NaN`, the function returns `NaN`. +If both arguments are `NaN`, the function returns `NaN`. ```javascript var v = nanmax( NaN, NaN ); // returns NaN - ``` + @@ -92,9 +91,9 @@ var v = nanmax( NaN, NaN ); diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/examples/index.js b/lib/node_modules/@stdlib/math/base/special/nanmax/examples/index.js index 902c9cd36e2a..fdc34abf572d 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmax/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/examples/index.js @@ -21,17 +21,17 @@ var nanmax = require( './../lib' ); var m = nanmax( 3.0, 4.0 ); -// returns 4.0 -console.log(m); +console.log( m ); +// => 4.0 m = nanmax( NaN, 4.0 ); -// returns 4.0 -console.log(m); +console.log( m ); +// => 4.0 m = nanmax( 4.0, NaN ); -// returns 4.0 -console.log(m); +console.log( m ); +// => 4.0 m = nanmax( NaN, NaN ); -// returns NaN -console.log(m); +console.log( m ); +// => NaN diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/lib/main.js b/lib/node_modules/@stdlib/math/base/special/nanmax/lib/main.js index 5d2b73ac2c07..a8738c2f5b37 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmax/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/lib/main.js @@ -27,11 +27,11 @@ var isnan = require( '@stdlib/math/base/assert/is-nan'); // MAIN // /** -* Return the maximum value, ignoring NaN. +* Returns the maximum value, ignoring NaN. * * @param {number} x - first number * @param {number} y - second number -* @returns {number} minimum value +* @returns {number} maximum value * * @example * var v = nanmax( 3.14, 4.2 ); diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/package.json b/lib/node_modules/@stdlib/math/base/special/nanmax/package.json index 5fcbaa47a111..b11a4535a497 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmax/package.json +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/math/base/special/nanmax", "version": "0.0.0", - "description": "Returns the maximum value, ignoring NaN.", + "description": "Return the maximum value, ignoring NaN.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -53,9 +53,9 @@ "stdmath", "mathematics", "math", - "math.min", - "minimum", - "min", + "math.max", + "maximum", + "max", "smallest" ] } From 2eab29d2a40f4d0bb1c1c3b106a189f61a580f76 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 11 Jun 2024 22:49:12 -0400 Subject: [PATCH 20/37] chore: update line endings Signed-off-by: Philipp Burckhardt --- lib/node_modules/@stdlib/math/base/special/nanmax/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/README.md b/lib/node_modules/@stdlib/math/base/special/nanmax/README.md index 96d924657949..397462f70d56 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmax/README.md +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/README.md @@ -69,7 +69,6 @@ var v = nanmax( NaN, NaN ); // returns NaN ``` - @@ -91,9 +90,11 @@ var v = nanmax( NaN, NaN ); From 544fed96961f622524fd98ffc743e6886dc61dfb Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 11 Jun 2024 22:52:59 -0400 Subject: [PATCH 21/37] chore: update README.md Signed-off-by: Philipp Burckhardt From 204a7b61b38e9d462c908f9d12703a1ed4bd43c3 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 11 Jun 2024 22:54:11 -0400 Subject: [PATCH 22/37] chore: update line endings in repl.txt Signed-off-by: Philipp Burckhardt --- .../@stdlib/math/base/special/nanmax/docs/types/repl.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/repl.txt b/lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/repl.txt index 919ef176e635..6f8a639825e7 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/repl.txt @@ -30,4 +30,3 @@ See Also -------- - From 87567d220d9cf69d77a511426da9e2c1a9aa340f Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 23 Jun 2024 10:31:08 +0530 Subject: [PATCH 23/37] feat: add @stdlib/iter/cuany --- .../@stdlib/iter/cuany/benchmark/benchmark.js | 113 +++++++++++++ .../@stdlib/iter/cuany/docs/types/index.d.ts | 61 +++++++ .../@stdlib/iter/cuany/docs/types/test.ts | 68 ++++++++ .../@stdlib/iter/cuany/examples/index.js | 42 +++++ .../@stdlib/iter/cuany/lib/index.js | 60 +++++++ .../@stdlib/iter/cuany/package.json | 66 ++++++++ .../@stdlib/iter/cuany/test/test.js | 159 ++++++++++++++++++ 7 files changed, 569 insertions(+) create mode 100644 lib/node_modules/@stdlib/iter/cuany/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/iter/cuany/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/iter/cuany/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/iter/cuany/examples/index.js create mode 100644 lib/node_modules/@stdlib/iter/cuany/lib/index.js create mode 100644 lib/node_modules/@stdlib/iter/cuany/package.json create mode 100644 lib/node_modules/@stdlib/iter/cuany/test/test.js diff --git a/lib/node_modules/@stdlib/iter/cuany/benchmark/benchmark.js b/lib/node_modules/@stdlib/iter/cuany/benchmark/benchmark.js new file mode 100644 index 000000000000..98eee1a741fa --- /dev/null +++ b/lib/node_modules/@stdlib/iter/cuany/benchmark/benchmark.js @@ -0,0 +1,113 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var iterCuAny = require( './../lib' ); + + +// FUNCTIONS // + +function createIterator( arr ) { + var len; + var it; + var i; + + len = arr.length; + i = -1; + + it = {}; + it.next = next; + it.reset = reset; + + return it; + + function next() { + i += 1; + if ( i < len ) { + return { + 'value': arr[ i ], + 'done': false + }; + } + return { + 'done': true + }; + } + + function reset() { + i = -1; + } +} + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var iter; + var arr; + var i; + + arr = createIterator( [ 0, 0, 0, 0, 0, 1 ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + iter = iterCuAny( arr ); + if ( typeof iter !== 'object' ) { + b.fail( 'should return an object' ); + } + arr.reset(); + } + b.toc(); + if ( !isIteratorLike( iter ) ) { + b.fail( 'should return an iterator protocol-compliant object' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::iteration', function benchmark( b ) { + var values; + var iter; + var arr; + var z; + var i; + + values = [ 0, 0, 0, 0, 0, 1 ]; + arr = createIterator( values ); + iter = iterCuAny( arr ); + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = iter.next().value; + 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/iter/cuany/docs/types/index.d.ts b/lib/node_modules/@stdlib/iter/cuany/docs/types/index.d.ts new file mode 100644 index 000000000000..2df0e6c9f52d --- /dev/null +++ b/lib/node_modules/@stdlib/iter/cuany/docs/types/index.d.ts @@ -0,0 +1,61 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 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 { Iterator } from '@stdlib/types/iter'; + +/** +* Return Iterator which have all truthy value after getting first truthy value. +* +* @param iterator - input iterator +* @returns Return Iterator which have all truthy value after getting first truthy value. +* +* @example +* var array2iterator = require( '@stdlib/array/to-iterator' ); +* +* var arr = array2iterator( [ false, false, false, true, false ] ); +* +* var it = iterCuAny( arr ); +* +* var v = it.next().value; +* returns false +* +* v = it.next().value; +* returns false +* +* v = it.next().value; +* returns false +* +* v = it.next().value; +* returns true +* +* v = it.next().value; +* returns true +* +* var bool = it.next().done; +* returns true +*/ +declare function iterCuAny( iterator: Iterator ): Iterator; + + +// EXPORTS // + +export = iterCuAny; diff --git a/lib/node_modules/@stdlib/iter/cuany/docs/types/test.ts b/lib/node_modules/@stdlib/iter/cuany/docs/types/test.ts new file mode 100644 index 000000000000..3fe1464d9ecf --- /dev/null +++ b/lib/node_modules/@stdlib/iter/cuany/docs/types/test.ts @@ -0,0 +1,68 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 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 iterCuAny = require( './index' ); + +/** +* Returns an iterator protocol-compliant object. +* +* @returns iterator protocol-compliant object +*/ +function iterator(): any { + + /** + * Implements the iterator protocol `next` method. + * + * @returns iterator protocol-compliant object + */ + function next(): any { + return { + 'value': true, + 'done': false + }; + } + return { + 'next': next + }; +} + + +// TESTS // + +// The function returns a Iterator... +{ + iterCuAny( iterator() ); // $ExpectType Iterator +} + +// The compiler throws an error if the function is provided a value other than an iterator protocol-compliant object... +{ + iterCuAny( '5' ); // $ExpectError + iterCuAny( 5 ); // $ExpectError + iterCuAny( true ); // $ExpectError + iterCuAny( false ); // $ExpectError + iterCuAny( null ); // $ExpectError + iterCuAny( undefined ); // $ExpectError + iterCuAny( [] ); // $ExpectError + iterCuAny( {} ); // $ExpectError + iterCuAny( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + iterCuAny(); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/iter/cuany/examples/index.js b/lib/node_modules/@stdlib/iter/cuany/examples/index.js new file mode 100644 index 000000000000..f23ff860bceb --- /dev/null +++ b/lib/node_modules/@stdlib/iter/cuany/examples/index.js @@ -0,0 +1,42 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 randu = require( '@stdlib/random/iter/randu' ); +var iterMap = require( '@stdlib/iter/map' ); +var iterCuAny = require( './../lib' ); + +function threshold( r ) { + return ( r > 0.95 ); +} + +// Create an iterator which generates uniformly distributed pseudorandom numbers: +var opts = { + 'iter': 100 +}; +var riter = randu( opts ); + +// Create an iterator which applies a threshold to generated numbers: +var miter = iterMap( riter, threshold ); + +// Return Iterator which have all truthy value after getting first truthy value. +var it = iterCuAny( miter ); +while ( !it.next().done ) { + console.log( it.next().value ); +} diff --git a/lib/node_modules/@stdlib/iter/cuany/lib/index.js b/lib/node_modules/@stdlib/iter/cuany/lib/index.js new file mode 100644 index 000000000000..a2f3618f9c53 --- /dev/null +++ b/lib/node_modules/@stdlib/iter/cuany/lib/index.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 Iterator which have all truthy value after getting first truthy value. +* +* @module @stdlib/iter/cuany +* +* @example +* var array2iterator = require( '@stdlib/array/to-iterator' ); +* var iterCuAny = require( '@stdlib/iter/cuany' ); +* +* var arr = array2iterator( [ false, false, false, true, false ] ); +* +* var it = iterCuAny( arr ); +* +* var v = it.next().value; +* returns false +* +* v = it.next().value; +* returns false +* +* v = it.next().value; +* returns false +* +* v = it.next().value; +* returns true +* +* v = it.next().value; +* returns true +* +* var bool = it.next().done; +* returns true +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/iter/cuany/package.json b/lib/node_modules/@stdlib/iter/cuany/package.json new file mode 100644 index 000000000000..0cb83dbc244d --- /dev/null +++ b/lib/node_modules/@stdlib/iter/cuany/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/iter/cuany", + "version": "0.0.0", + "description": "Returns an iterator which yields all truthy values after getting the first truthy value.", + "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", + "stdutils", + "stdutil", + "utilities", + "utility", + "utils", + "util", + "test", + "any", + "iterate", + "iterator", + "iter", + "validate" + ] +} diff --git a/lib/node_modules/@stdlib/iter/cuany/test/test.js b/lib/node_modules/@stdlib/iter/cuany/test/test.js new file mode 100644 index 000000000000..7b1bcac81443 --- /dev/null +++ b/lib/node_modules/@stdlib/iter/cuany/test/test.js @@ -0,0 +1,159 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 array2iterator = require( '@stdlib/array/to-iterator' ); +var iterCuAny = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof iterCuAny, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if not provided an iterator', 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 a type error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + iterCuAny( value ); + }; + } +}); + +tape( 'the function returns an iterator protocol-compliant object', function test( t ) { + var arr; + var it; + var r; + var i; + + arr = array2iterator( [0, 0, 1, 0, 1] ); + it = iterCuAny(arr); + for ( i = 0; i < 100; i++ ) { + r = it.next(); + t.equal( typeof r.value, 'boolean', 'returns a number' ); + t.equal( typeof r.done, 'boolean', 'returns a boolean' ); + } + t.end(); +}); + +tape( 'the function returns an iterator protocol-compliant object which returns all falsy values', function test( t ) { + var expected; + var actual; + var values; + var it; + var i; + + values = [ 0, 0, 0, 0]; + expected = [ + { + 'value': false, + 'done': false + }, + { + 'value': false, + 'done': false + }, + { + 'value': false, + 'done': false + }, + { + 'value': false, + 'done': false + }, + { + 'done': true + } + ]; + + it = iterCuAny( array2iterator( values ) ); + + actual = []; + for ( i = 0; i < expected.length; i++ ) { + actual.push( it.next() ); + } + t.deepEqual( actual, expected, 'returns expected values' ); + t.end(); +}); + +tape( 'the function returns an iterator protocol-compliant object which returns truthy values after getting first truthy', function test( t ) { + var expected; + var actual; + var values; + var it; + var i; + + values = [ 0, 0, 1, 0]; + expected = [ + { + 'value': false, + 'done': false + }, + { + 'value': false, + 'done': false + }, + { + 'value': true, + 'done': false + }, + { + 'value': true, + 'done': false + }, + { + 'done': true + } + ]; + + it = iterCuAny( array2iterator( values ) ); + + actual = []; + for ( i = 0; i < expected.length; i++ ) { + actual.push( it.next() ); + } + t.deepEqual( actual, expected, 'returns expected values' ); + t.end(); +}); From 7c1ff01f48f9cc7314123661db6fb7c070ea3bf3 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 23 Jun 2024 13:04:45 +0530 Subject: [PATCH 24/37] feat: add @stdlib/iter/cuany --- .../@stdlib/iter/cuany/lib/main.js | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 lib/node_modules/@stdlib/iter/cuany/lib/main.js diff --git a/lib/node_modules/@stdlib/iter/cuany/lib/main.js b/lib/node_modules/@stdlib/iter/cuany/lib/main.js new file mode 100644 index 000000000000..4d4420b9aa36 --- /dev/null +++ b/lib/node_modules/@stdlib/iter/cuany/lib/main.js @@ -0,0 +1,86 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); +var format = require( '@stdlib/string/format' ); +var array2iterator = require( '@stdlib/array/to-iterator' ); + + +// MAIN // + +/** +* Return Iterator which yields all truthy values after getting the first truthy value. +* +* @param {Iterator} iterator - Input iterator. +* @throws {TypeError} Must provide an iterator. +* @returns {Iterator} Iterator which yields all truthy values after getting the first truthy value. +* +* @example +* var array2iterator = require( '@stdlib/array/to-iterator' ); +* +* var arr = array2iterator( [ 0, 0, 0, 1, 0 ] ); +* +* var it = iterCuAny( arr ); +* +* var v = it.next().value; +* // returns false +* +* v = it.next().value; +* // returns false +* +* v = it.next().value; +* // returns false +* +* v = it.next().value; +* // returns true +* +* v = it.next().value; +* // returns true +* +* var bool = it.next().done; +* // returns true +*/ +function iterCuAny( iterator ) { + var arr = []; + var v = false; + var x = false; + + if ( !isIteratorLike( iterator ) ) { + throw new TypeError( format( 'invalid argument. Must provide an iterator. Value: `%s`.', iterator ) ); + } + while ( true ) { + v = iterator.next(); + if ( v.done ) { + break; + } + if ( v.value ) { + x = true; + } + arr.push( x ); + } + return array2iterator(arr); +} + + +// EXPORTS // + +module.exports = iterCuAny; From c5f61a4163b7893deb53a6cd5e32cc8c2cda3d2a Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 23 Jun 2024 13:08:54 +0530 Subject: [PATCH 25/37] feat: add @stdlib/iter/cuany --- lib/node_modules/@stdlib/iter/cuany/test/test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/iter/cuany/test/test.js b/lib/node_modules/@stdlib/iter/cuany/test/test.js index 7b1bcac81443..ce547bfb85fd 100644 --- a/lib/node_modules/@stdlib/iter/cuany/test/test.js +++ b/lib/node_modules/@stdlib/iter/cuany/test/test.js @@ -70,11 +70,11 @@ tape( 'the function returns an iterator protocol-compliant object', function tes arr = array2iterator( [0, 0, 1, 0, 1] ); it = iterCuAny(arr); - for ( i = 0; i < 100; i++ ) { + for ( i = 0; i < 5; i++ ) { r = it.next(); - t.equal( typeof r.value, 'boolean', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); + t.equal( typeof r.value, 'boolean', 'returns a boolean' ); } + t.equal( typeof r.done, 'boolean', 'returns a boolean' ); t.end(); }); From c1086d434e690b84cca81f94312a36b4b5dbda49 Mon Sep 17 00:00:00 2001 From: RidamGarg Date: Sun, 23 Jun 2024 13:21:13 +0530 Subject: [PATCH 26/37] feat: add @stdlib/iter/cuany --- lib/node_modules/@stdlib/iter/cuany/examples/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/iter/cuany/examples/index.js b/lib/node_modules/@stdlib/iter/cuany/examples/index.js index f23ff860bceb..602cee66c83b 100644 --- a/lib/node_modules/@stdlib/iter/cuany/examples/index.js +++ b/lib/node_modules/@stdlib/iter/cuany/examples/index.js @@ -37,6 +37,12 @@ var miter = iterMap( riter, threshold ); // Return Iterator which have all truthy value after getting first truthy value. var it = iterCuAny( miter ); -while ( !it.next().done ) { - console.log( it.next().value ); +var r; + +while ( true ) { + r = it.next(); + if ( r.done ) { + break; + } + console.log( r.value ); } From 9b39111edd206a7a4168092db812b0f1c981946d Mon Sep 17 00:00:00 2001 From: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> Date: Sun, 23 Jun 2024 13:29:30 +0530 Subject: [PATCH 27/37] feat: add @stdlib/iter/cuany Signed-off-by: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> --- .../@stdlib/iter/cuany/docs/repl.txt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 lib/node_modules/@stdlib/iter/cuany/docs/repl.txt diff --git a/lib/node_modules/@stdlib/iter/cuany/docs/repl.txt b/lib/node_modules/@stdlib/iter/cuany/docs/repl.txt new file mode 100644 index 000000000000..edc72ff34659 --- /dev/null +++ b/lib/node_modules/@stdlib/iter/cuany/docs/repl.txt @@ -0,0 +1,44 @@ + +{{alias}}( iterator ) + Returns an iterator which yields all truthy values + after getting the first truthy value. + + If an environment supports Symbol.iterator and a provided iterator is + iterable, the returned iterator is iterable. + + Parameters + ---------- + iterator: Object + Input iterator over which to iterate. + + Returns + ------- + iterator: Object + Iterator. + + iterator.next(): Function + Returns an iterator protocol-compliant object containing the next + iterated value (if one exists) and a boolean flag indicating whether the + iterator is finished. + + iterator.return( [value] ): Function + Finishes an iterator and returns a provided value. + + Examples + -------- + > var arr = {{alias:@stdlib/array/to-iterator}}( [ 0, 0, 0, 1, 0 ] ); + > var it = {{alias}}( arr ) + > var v = it.next().value + false + > v = it.next().value + false + > v = it.next().value + false + > v = it.next().value + true + > v = it.next().value + true + + See Also + -------- + From b236648ef048847b23cb63255dd4622c006f7187 Mon Sep 17 00:00:00 2001 From: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> Date: Sun, 23 Jun 2024 13:30:46 +0530 Subject: [PATCH 28/37] feat: add @stdlib/iter/cuany Signed-off-by: Ridam Garg <67867319+RidamGarg@users.noreply.github.com> --- lib/node_modules/@stdlib/iter/cuany/README.md | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 lib/node_modules/@stdlib/iter/cuany/README.md diff --git a/lib/node_modules/@stdlib/iter/cuany/README.md b/lib/node_modules/@stdlib/iter/cuany/README.md new file mode 100644 index 000000000000..b5e8e589cc1c --- /dev/null +++ b/lib/node_modules/@stdlib/iter/cuany/README.md @@ -0,0 +1,166 @@ + + +# iterCuAny + +> Create an [iterator][mdn-iterator-protocol] which yields all truthy values after getting the first truthy value. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var iterCuAny = require( '@stdlib/iter/cuany' ); +``` + +#### iterCuAny( iterator ) + +Returns an [iterator][mdn-iterator-protocol] which yields all truthy values after getting the first truthy value. + +```javascript +var array2iterator = require( '@stdlib/array/to-iterator' ); + +var arr = array2iterator( [ 0, 0, 0, 1, 0 ] ); + +var it = iterCuAny( arr ); +// returns + +var v = it.next().value; +// returns false + +v = it.next().value; +// returns false + +v = it.next().value; +// returns false + +v = it.next().value; +// returns true + +v = it.next().value; +// returns true + +var bool = it.next().done; +// returns true +``` + +The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties: + +- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished. +- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object. + +The `predicate` function is provided two arguments: + +- `value`: iterated value +- `index`: iteration index (zero-based) + + + + + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var randu = require( '@stdlib/random/iter/randu' ); +var iterMap = require( '@stdlib/iter/map' ); +var iterCuAny = require( '@stdlib/iter/cuany' ); + +function threshold( r ) { + return ( r > 0.95 ); +} + +// Create an iterator which generates uniformly distributed pseudorandom numbers: +var opts = { + 'iter': 100 +}; +var riter = randu( opts ); + +// Create an iterator which applies a threshold to generated numbers: +var miter = iterMap( riter, threshold ); + +// Create an iterator which yields all truthy values after getting the first truthy value. +var it = iterCuAny( miter ); +// returns Object +var r; +while ( true ) { + r = it.next(); + if ( r.done ) { + break; + } + console.log( r.value ); +} +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + From 957fb99a2c654e60fef1febfa5e9805ec6161e5c Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 16:28:39 -0700 Subject: [PATCH 29/37] bench: refactor to use existing utilities --- .../@stdlib/iter/cuany/benchmark/benchmark.js | 58 ++++--------------- 1 file changed, 10 insertions(+), 48 deletions(-) diff --git a/lib/node_modules/@stdlib/iter/cuany/benchmark/benchmark.js b/lib/node_modules/@stdlib/iter/cuany/benchmark/benchmark.js index 98eee1a741fa..c7a99150fccb 100644 --- a/lib/node_modules/@stdlib/iter/cuany/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/iter/cuany/benchmark/benchmark.js @@ -21,63 +21,28 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var iterConstant = require( '@stdlib/iter/constant' ); var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var iterCuAny = require( './../lib' ); -// FUNCTIONS // - -function createIterator( arr ) { - var len; - var it; - var i; - - len = arr.length; - i = -1; - - it = {}; - it.next = next; - it.reset = reset; - - return it; - - function next() { - i += 1; - if ( i < len ) { - return { - 'value': arr[ i ], - 'done': false - }; - } - return { - 'done': true - }; - } - - function reset() { - i = -1; - } -} - - // MAIN // bench( pkg, function benchmark( b ) { var iter; - var arr; + var it; var i; - arr = createIterator( [ 0, 0, 0, 0, 0, 1 ] ); + it = iterConstant( 3.14 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - iter = iterCuAny( arr ); + iter = iterCuAny( it ); if ( typeof iter !== 'object' ) { b.fail( 'should return an object' ); } - arr.reset(); } b.toc(); if ( !isIteratorLike( iter ) ) { @@ -88,24 +53,21 @@ bench( pkg, function benchmark( b ) { }); bench( pkg+'::iteration', function benchmark( b ) { - var values; var iter; - var arr; - var z; + var v; var i; - values = [ 0, 0, 0, 0, 0, 1 ]; - arr = createIterator( values ); - iter = iterCuAny( arr ); + iter = iterCuAny( iterConstant( 3.14 ) ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( isnan( z ) ) { + v = iter.next().value; + if ( isnan( v ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( z ) ) { + if ( isnan( v ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); From 4d681fe1dd2db6dcd55ab1051b23879540859ddf Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 16:36:19 -0700 Subject: [PATCH 30/37] docs: update copyright years and address lint errors --- lib/node_modules/@stdlib/iter/cuany/README.md | 21 +++++++------------ .../@stdlib/iter/cuany/benchmark/benchmark.js | 2 +- .../@stdlib/iter/cuany/docs/repl.txt | 8 +++---- .../@stdlib/iter/cuany/docs/types/index.d.ts | 2 +- .../@stdlib/iter/cuany/docs/types/test.ts | 2 +- .../@stdlib/iter/cuany/examples/index.js | 2 +- .../@stdlib/iter/cuany/lib/index.js | 2 +- .../@stdlib/iter/cuany/lib/main.js | 2 +- .../@stdlib/iter/cuany/test/test.js | 2 +- 9 files changed, 18 insertions(+), 25 deletions(-) diff --git a/lib/node_modules/@stdlib/iter/cuany/README.md b/lib/node_modules/@stdlib/iter/cuany/README.md index b5e8e589cc1c..9dd8c8e9d4d0 100644 --- a/lib/node_modules/@stdlib/iter/cuany/README.md +++ b/lib/node_modules/@stdlib/iter/cuany/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +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. @@ -20,7 +20,7 @@ limitations under the License. # iterCuAny -> Create an [iterator][mdn-iterator-protocol] which yields all truthy values after getting the first truthy value. +> Create an [iterator][mdn-iterator-protocol] which cumulatively tests whether at least one iterated value is truthy. @@ -42,7 +42,7 @@ var iterCuAny = require( '@stdlib/iter/cuany' ); #### iterCuAny( iterator ) -Returns an [iterator][mdn-iterator-protocol] which yields all truthy values after getting the first truthy value. +Returns an [iterator][mdn-iterator-protocol] which cumulatively tests whether at least one iterated value is truthy. ```javascript var array2iterator = require( '@stdlib/array/to-iterator' ); @@ -76,12 +76,6 @@ The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the - **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished. - **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object. -The `predicate` function is provided two arguments: - -- `value`: iterated value -- `index`: iteration index (zero-based) - - @@ -120,9 +114,10 @@ var riter = randu( opts ); // Create an iterator which applies a threshold to generated numbers: var miter = iterMap( riter, threshold ); -// Create an iterator which yields all truthy values after getting the first truthy value. +// Create an iterator which cumulatively tests whether at least one iterated value is truthy: var it = iterCuAny( miter ); -// returns Object + +// Perform manual iteration... var r; while ( true ) { r = it.next(); @@ -157,9 +152,7 @@ while ( true ) { diff --git a/lib/node_modules/@stdlib/iter/cuany/benchmark/benchmark.js b/lib/node_modules/@stdlib/iter/cuany/benchmark/benchmark.js index c7a99150fccb..5e4a16633e56 100644 --- a/lib/node_modules/@stdlib/iter/cuany/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/iter/cuany/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/iter/cuany/docs/repl.txt b/lib/node_modules/@stdlib/iter/cuany/docs/repl.txt index edc72ff34659..30a2515b8315 100644 --- a/lib/node_modules/@stdlib/iter/cuany/docs/repl.txt +++ b/lib/node_modules/@stdlib/iter/cuany/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( iterator ) - Returns an iterator which yields all truthy values - after getting the first truthy value. + Returns an iterator which cumulatively tests whether at least one iterated + value is truthy. If an environment supports Symbol.iterator and a provided iterator is iterable, the returned iterator is iterable. @@ -9,7 +9,7 @@ Parameters ---------- iterator: Object - Input iterator over which to iterate. + Input iterator. Returns ------- @@ -27,7 +27,7 @@ Examples -------- > var arr = {{alias:@stdlib/array/to-iterator}}( [ 0, 0, 0, 1, 0 ] ); - > var it = {{alias}}( arr ) + > var it = {{alias}}( arr ); > var v = it.next().value false > v = it.next().value diff --git a/lib/node_modules/@stdlib/iter/cuany/docs/types/index.d.ts b/lib/node_modules/@stdlib/iter/cuany/docs/types/index.d.ts index 2df0e6c9f52d..27c41958519b 100644 --- a/lib/node_modules/@stdlib/iter/cuany/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/iter/cuany/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/iter/cuany/docs/types/test.ts b/lib/node_modules/@stdlib/iter/cuany/docs/types/test.ts index 3fe1464d9ecf..8d7c758598cd 100644 --- a/lib/node_modules/@stdlib/iter/cuany/docs/types/test.ts +++ b/lib/node_modules/@stdlib/iter/cuany/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/iter/cuany/examples/index.js b/lib/node_modules/@stdlib/iter/cuany/examples/index.js index 602cee66c83b..e28feb2d77ef 100644 --- a/lib/node_modules/@stdlib/iter/cuany/examples/index.js +++ b/lib/node_modules/@stdlib/iter/cuany/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/iter/cuany/lib/index.js b/lib/node_modules/@stdlib/iter/cuany/lib/index.js index a2f3618f9c53..1ac11e621e2d 100644 --- a/lib/node_modules/@stdlib/iter/cuany/lib/index.js +++ b/lib/node_modules/@stdlib/iter/cuany/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/iter/cuany/lib/main.js b/lib/node_modules/@stdlib/iter/cuany/lib/main.js index 4d4420b9aa36..dca1a5dfa2bb 100644 --- a/lib/node_modules/@stdlib/iter/cuany/lib/main.js +++ b/lib/node_modules/@stdlib/iter/cuany/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/iter/cuany/test/test.js b/lib/node_modules/@stdlib/iter/cuany/test/test.js index ce547bfb85fd..7b594183cf0d 100644 --- a/lib/node_modules/@stdlib/iter/cuany/test/test.js +++ b/lib/node_modules/@stdlib/iter/cuany/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. From cbd728bed7d8aa182d68fbefeb65635d2f12c3c2 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 16:42:52 -0700 Subject: [PATCH 31/37] docs: fix declarations --- .../@stdlib/iter/cuany/docs/types/index.d.ts | 9 ++++-- .../@stdlib/iter/cuany/docs/types/test.ts | 29 ++++++++++--------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/node_modules/@stdlib/iter/cuany/docs/types/index.d.ts b/lib/node_modules/@stdlib/iter/cuany/docs/types/index.d.ts index 27c41958519b..134c4b077aa7 100644 --- a/lib/node_modules/@stdlib/iter/cuany/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/iter/cuany/docs/types/index.d.ts @@ -20,13 +20,16 @@ /// -import { Iterator } from '@stdlib/types/iter'; +import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; + +// Define a union type representing both iterable and non-iterable iterators: +type Iterator = Iter | IterableIterator; /** -* Return Iterator which have all truthy value after getting first truthy value. +* Returns an iterator which cumulatively tests whether at least one iterated value is truthy. * * @param iterator - input iterator -* @returns Return Iterator which have all truthy value after getting first truthy value. +* @returns iterator * * @example * var array2iterator = require( '@stdlib/array/to-iterator' ); diff --git a/lib/node_modules/@stdlib/iter/cuany/docs/types/test.ts b/lib/node_modules/@stdlib/iter/cuany/docs/types/test.ts index 8d7c758598cd..02cfaac58c43 100644 --- a/lib/node_modules/@stdlib/iter/cuany/docs/types/test.ts +++ b/lib/node_modules/@stdlib/iter/cuany/docs/types/test.ts @@ -16,26 +16,27 @@ * limitations under the License. */ +import { Iterator, IteratorResult } from '@stdlib/types/iter'; import iterCuAny = require( './index' ); /** -* Returns an iterator protocol-compliant object. +* Implements the iterator protocol `next` method. * * @returns iterator protocol-compliant object */ -function iterator(): any { +function next(): IteratorResult { + return { + 'value': true, + 'done': false + }; +} - /** - * Implements the iterator protocol `next` method. - * - * @returns iterator protocol-compliant object - */ - function next(): any { - return { - 'value': true, - 'done': false - }; - } +/** +* Returns an iterator protocol-compliant object. +* +* @returns iterator protocol-compliant object +*/ +function iterator(): Iterator { return { 'next': next }; @@ -44,7 +45,7 @@ function iterator(): any { // TESTS // -// The function returns a Iterator... +// The function returns an iterator... { iterCuAny( iterator() ); // $ExpectType Iterator } From eda97112587ef10925252610636ee188eaf76f95 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 16:44:34 -0700 Subject: [PATCH 32/37] docs: update example --- lib/node_modules/@stdlib/iter/cuany/examples/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/iter/cuany/examples/index.js b/lib/node_modules/@stdlib/iter/cuany/examples/index.js index e28feb2d77ef..a9c872b36167 100644 --- a/lib/node_modules/@stdlib/iter/cuany/examples/index.js +++ b/lib/node_modules/@stdlib/iter/cuany/examples/index.js @@ -35,10 +35,11 @@ var riter = randu( opts ); // Create an iterator which applies a threshold to generated numbers: var miter = iterMap( riter, threshold ); -// Return Iterator which have all truthy value after getting first truthy value. +// Create an iterator which cumulatively tests whether at least one iterated value is truthy: var it = iterCuAny( miter ); -var r; +// Perform manual iteration... +var r; while ( true ) { r = it.next(); if ( r.done ) { From fdceb9779ac807bf093e09bbdc76eccf44e74e9e Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 16:50:11 -0700 Subject: [PATCH 33/37] refactor: fix implementation to lazily consume upstream values --- .../@stdlib/iter/cuany/lib/index.js | 2 +- .../@stdlib/iter/cuany/lib/main.js | 87 ++++++++++++++++--- 2 files changed, 74 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/iter/cuany/lib/index.js b/lib/node_modules/@stdlib/iter/cuany/lib/index.js index 1ac11e621e2d..d7d001fa3d02 100644 --- a/lib/node_modules/@stdlib/iter/cuany/lib/index.js +++ b/lib/node_modules/@stdlib/iter/cuany/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Return Iterator which have all truthy value after getting first truthy value. +* Create an iterator which cumulatively tests whether at least one iterated value is truthy. * * @module @stdlib/iter/cuany * diff --git a/lib/node_modules/@stdlib/iter/cuany/lib/main.js b/lib/node_modules/@stdlib/iter/cuany/lib/main.js index dca1a5dfa2bb..16ec9cb5def4 100644 --- a/lib/node_modules/@stdlib/iter/cuany/lib/main.js +++ b/lib/node_modules/@stdlib/iter/cuany/lib/main.js @@ -20,19 +20,21 @@ // MODULES // +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); +var iteratorSymbol = require( '@stdlib/symbol/iterator' ); var format = require( '@stdlib/string/format' ); -var array2iterator = require( '@stdlib/array/to-iterator' ); // MAIN // /** -* Return Iterator which yields all truthy values after getting the first truthy value. +* Returns an iterator which cumulatively tests whether at least one iterated value is truthy. * -* @param {Iterator} iterator - Input iterator. -* @throws {TypeError} Must provide an iterator. -* @returns {Iterator} Iterator which yields all truthy values after getting the first truthy value. +* @param {Iterator} iterator - input iterator +* @throws {TypeError} first argument must be an iterator +* @returns {Iterator} iterator * * @example * var array2iterator = require( '@stdlib/array/to-iterator' ); @@ -60,24 +62,81 @@ var array2iterator = require( '@stdlib/array/to-iterator' ); * // returns true */ function iterCuAny( iterator ) { - var arr = []; - var v = false; - var x = false; - + var value; + var iter; + var FLG; if ( !isIteratorLike( iterator ) ) { throw new TypeError( format( 'invalid argument. Must provide an iterator. Value: `%s`.', iterator ) ); } - while ( true ) { + value = false; + + // Create an iterator protocol-compliant object: + iter = {}; + setReadOnly( iter, 'next', next ); + setReadOnly( iter, 'return', end ); + + // If an environment supports `Symbol.iterator` and the provided iterator is iterable, make the iterator iterable: + if ( iteratorSymbol && isFunction( iterator[ iteratorSymbol ] ) ) { + setReadOnly( iter, iteratorSymbol, factory ); + } + return iter; + + /** + * Returns an iterator protocol-compliant object containing the next iterated value. + * + * @private + * @returns {Object} iterator protocol-compliant object + */ + function next() { + var v; + if ( FLG ) { + return { + 'done': true + }; + } v = iterator.next(); if ( v.done ) { - break; + FLG = true; + return v; } if ( v.value ) { - x = true; + value = true; } - arr.push( x ); + return { + 'value': value, + 'done': false + }; + } + + /** + * Finishes an iterator. + * + * @private + * @param {*} [value] - value to return + * @returns {Object} iterator protocol-compliant object + */ + function end( value ) { + FLG = true; + if ( arguments.length ) { + return { + 'value': value, + 'done': true + }; + } + return { + 'done': true + }; + } + + /** + * Returns a new iterator. + * + * @private + * @returns {Iterator} iterator + */ + function factory() { + return iterCuAny( iterator[ iteratorSymbol ]() ); } - return array2iterator(arr); } From 297ad020eb9ba8418596af86470407947154bbac Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 16:57:26 -0700 Subject: [PATCH 34/37] test: add additional tests --- .../@stdlib/iter/cuany/test/test.js | 181 +++++++++++++++++- 1 file changed, 172 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/iter/cuany/test/test.js b/lib/node_modules/@stdlib/iter/cuany/test/test.js index 7b594183cf0d..8f483c5705b7 100644 --- a/lib/node_modules/@stdlib/iter/cuany/test/test.js +++ b/lib/node_modules/@stdlib/iter/cuany/test/test.js @@ -21,7 +21,10 @@ // MODULES // var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); var array2iterator = require( '@stdlib/array/to-iterator' ); +var randu = require( '@stdlib/random/iter/randu' ); +var iteratorSymbol = require( '@stdlib/symbol/iterator' ); var iterCuAny = require( './../lib' ); @@ -33,7 +36,7 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function throws an error if not provided an iterator', function test( t ) { +tape( 'the function throws an error if not provided an iterator protocol-compliant object', function test( t ) { var values; var i; @@ -68,24 +71,25 @@ tape( 'the function returns an iterator protocol-compliant object', function tes var r; var i; - arr = array2iterator( [0, 0, 1, 0, 1] ); - it = iterCuAny(arr); + arr = array2iterator( [ 0, 0, 1, 0, 1 ] ); + it = iterCuAny( arr ); for ( i = 0; i < 5; i++ ) { r = it.next(); - t.equal( typeof r.value, 'boolean', 'returns a boolean' ); + t.equal( typeof r.value, 'boolean', 'returns expected value' ); + t.equal( typeof r.done, 'boolean', 'returns expected value' ); } - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); + t.equal( typeof r.done, 'boolean', 'returns expected value' ); t.end(); }); -tape( 'the function returns an iterator protocol-compliant object which returns all falsy values', function test( t ) { +tape( 'if no upstream iterator values are truthy, the function returns an iterator protocol-compliant object which returns all falsy values', function test( t ) { var expected; var actual; var values; var it; var i; - values = [ 0, 0, 0, 0]; + values = [ 0, 0, 0, 0 ]; expected = [ { 'value': false, @@ -118,14 +122,14 @@ tape( 'the function returns an iterator protocol-compliant object which returns t.end(); }); -tape( 'the function returns an iterator protocol-compliant object which returns truthy values after getting first truthy', function test( t ) { +tape( 'if at least one upstream iterator value is truthy, the function returns an iterator protocol-compliant object which returns truthy values upon encountering the first truthy value', function test( t ) { var expected; var actual; var values; var it; var i; - values = [ 0, 0, 1, 0]; + values = [ 0, 0, 1, 0 ]; expected = [ { 'value': false, @@ -157,3 +161,162 @@ tape( 'the function returns an iterator protocol-compliant object which returns t.deepEqual( actual, expected, 'returns expected values' ); t.end(); }); + +tape( 'if all upstream iterator values are truthy, the function returns an iterator protocol-compliant object which always returns truthy values', function test( t ) { + var expected; + var actual; + var values; + var it; + var i; + + values = [ 1, 1, 1, 1 ]; + expected = [ + { + 'value': true, + 'done': false + }, + { + 'value': true, + 'done': false + }, + { + 'value': true, + 'done': false + }, + { + 'value': true, + 'done': false + }, + { + 'done': true + } + ]; + + it = iterCuAny( array2iterator( values ) ); + + actual = []; + for ( i = 0; i < expected.length; i++ ) { + actual.push( it.next() ); + } + t.deepEqual( actual, expected, 'returns expected values' ); + t.end(); +}); + +tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { + var it; + var r; + + it = iterCuAny( randu() ); + + r = it.next(); + t.equal( typeof r.value, 'boolean', 'returns expected value' ); + t.equal( r.done, false, 'returns expected value' ); + + r = it.next(); + t.equal( typeof r.value, 'boolean', 'returns expected value' ); + t.equal( r.done, false, 'returns expected value' ); + + r = it.return(); + t.equal( r.value, void 0, 'returns expected value' ); + t.equal( r.done, true, 'returns expected value' ); + + r = it.next(); + t.equal( r.value, void 0, 'returns expected value' ); + t.equal( r.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { + var it; + var r; + + it = iterCuAny( randu() ); + + r = it.next(); + t.equal( typeof r.value, 'boolean', 'returns expected value' ); + t.equal( r.done, false, 'returns expected value' ); + + r = it.next(); + t.equal( typeof r.value, 'boolean', 'returns expected value' ); + t.equal( r.done, false, 'returns expected value' ); + + r = it.return( 'finished' ); + t.equal( r.value, 'finished', 'returns expected value' ); + t.equal( r.done, true, 'returns expected value' ); + + r = it.next(); + t.equal( r.value, void 0, 'returns expected value' ); + t.equal( r.done, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if an environment supports `Symbol.iterator` and the provided iterator is iterable, the returned iterator is iterable', function test( t ) { + var iterCuAny; + var opts; + var rand; + var it1; + var it2; + var i; + + iterCuAny = proxyquire( './../lib/main.js', { + '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' + }); + + opts = { + 'seed': 12345 + }; + rand = randu( opts ); + rand[ '__ITERATOR_SYMBOL__' ] = factory; + + it1 = iterCuAny( rand ); + t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); + t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); + + it2 = it1[ '__ITERATOR_SYMBOL__' ](); + t.equal( typeof it2, 'object', 'returns an object' ); + t.equal( typeof it2.next, 'function', 'has method' ); + t.equal( typeof it2.return, 'function', 'has method' ); + + for ( i = 0; i < 100; i++ ) { + t.equal( it2.next().value, it1.next().value, 'returns expected value' ); + } + t.end(); + + function factory() { + return randu( opts ); + } +}); + +tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable"', function test( t ) { + var iterCuAny; + var it; + + iterCuAny = proxyquire( './../lib/main.js', { + '@stdlib/symbol/iterator': false + }); + + it = iterCuAny( randu() ); + t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); + + t.end(); +}); + +tape( 'if a provided iterator is not iterable, the returned iterator is not iterable', function test( t ) { + var iterCuAny; + var rand; + var it; + + iterCuAny = proxyquire( './../lib/main.js', { + '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' + }); + + rand = randu(); + rand[ '__ITERATOR_SYMBOL__' ] = null; + + it = iterCuAny( rand ); + t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); + + t.end(); +}); From 758fc63d7dcf4618a58951f068bb7c0c84a2aa1a Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 16:59:18 -0700 Subject: [PATCH 35/37] docs: update description --- lib/node_modules/@stdlib/iter/cuany/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/iter/cuany/package.json b/lib/node_modules/@stdlib/iter/cuany/package.json index 0cb83dbc244d..b975a853e119 100644 --- a/lib/node_modules/@stdlib/iter/cuany/package.json +++ b/lib/node_modules/@stdlib/iter/cuany/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/iter/cuany", "version": "0.0.0", - "description": "Returns an iterator which yields all truthy values after getting the first truthy value.", + "description": "Create an iterator which cumulatively tests whether at least one iterated value is truthy.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From db0a54c81df85fa8652390d4f10c4fcfc9e46724 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 17:33:59 -0700 Subject: [PATCH 36/37] docs: undo linebreak changes --- .../math/base/special/nanmax/README.md | 200 +++++++++--------- 1 file changed, 100 insertions(+), 100 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/README.md b/lib/node_modules/@stdlib/math/base/special/nanmax/README.md index 397462f70d56..71d3e2e861ae 100644 --- a/lib/node_modules/@stdlib/math/base/special/nanmax/README.md +++ b/lib/node_modules/@stdlib/math/base/special/nanmax/README.md @@ -1,100 +1,100 @@ - - -# nanmax - -> Return the maximum value, ignoring NaN. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var nanmax = require( '@stdlib/math/base/special/nanmax' ); -``` - -#### nanmax( x, y ) - -Returns the maximum value. - -```javascript -var v = nanmax( 4.2, 3.14 ); -// returns 4.2 - -v = nanmax( +0.0, -0.0 ); -// returns +0.0 -``` - -If any argument is `NaN`, the function returns the other operand. - -```javascript -var v = nanmax( 4.2, NaN ); -// returns 4.2 - -v = nanmax( NaN, 3.14 ); -// returns 3.14 -``` - -If both arguments are `NaN`, the function returns `NaN`. - -```javascript -var v = nanmax( NaN, NaN ); -// returns NaN -``` - -
- - - - - -
- -
- - - - - - - - - - - - + + +# nanmax + +> Return the maximum value, ignoring NaN. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var nanmax = require( '@stdlib/math/base/special/nanmax' ); +``` + +#### nanmax( x, y ) + +Returns the maximum value. + +```javascript +var v = nanmax( 4.2, 3.14 ); +// returns 4.2 + +v = nanmax( +0.0, -0.0 ); +// returns +0.0 +``` + +If any argument is `NaN`, the function returns the other operand. + +```javascript +var v = nanmax( 4.2, NaN ); +// returns 4.2 + +v = nanmax( NaN, 3.14 ); +// returns 3.14 +``` + +If both arguments are `NaN`, the function returns `NaN`. + +```javascript +var v = nanmax( NaN, NaN ); +// returns NaN +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + From d7d4a3bb41ea156110e9406dcadcc9d13a555b58 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 17:34:56 -0700 Subject: [PATCH 37/37] chore: delete stray file --- .../base/special/nanmax/docs/types/repl.txt | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/repl.txt diff --git a/lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/repl.txt b/lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/repl.txt deleted file mode 100644 index 6f8a639825e7..000000000000 --- a/lib/node_modules/@stdlib/math/base/special/nanmax/docs/types/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( x, y ) - Returns the maximum value. - - If one operand is NaN, the other operand is always returned. - - Parameters - ---------- - x: number - First number. - - y: number - Second number. - - Returns - ------- - out: number - Maximum value. - - Examples - -------- - > var v = {{alias}}( 3.14, 4.2 ) - 4.2 - > v = {{alias}}( 3.14, NaN ) - 3.14 - > v = {{alias}}( NaN, 4.2 ) - 4.2 - > v = {{alias}}( NaN, NaN ) - NaN - - See Also - --------