diff --git a/lib/node_modules/@stdlib/assert/is-positive-finite/README.md b/lib/node_modules/@stdlib/assert/is-positive-finite/README.md new file mode 100644 index 000000000000..8cc07fce7b93 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-positive-finite/README.md @@ -0,0 +1,173 @@ + + +# isPositiveFinite + +> Test if a value is a number having a non-infinite positive value. + +
+ +## Usage + +```javascript +var isPositiveFinite = require( '@stdlib/assert/is-positive-finite' ); +``` + +#### isPositiveFinite( value ) + +Tests if a `value` is a `number` having a non-infinite positive value. + + + +```javascript +var Number = require( '@stdlib/number/ctor' ); + +var bool = isPositiveFinite( 5.0 ); +// returns true + +bool = isPositiveFinite( new Number( 5.0 ) ); +// returns true + +bool = isPositiveFinite( 5.0/0.0 ); +// returns false + +bool = isPositiveFinite( -5.0 ); +// returns false + +bool = isPositiveFinite( new Number( 5.0/0.0 ) ); +// returns false + +bool = isPositiveFinite( null ); +// returns false +``` + +#### isPositiveFinite.isPrimitive( value ) + +Tests if a `value` is a primitive `number` having a non-infinite positive value. + + + +```javascript +var Number = require( '@stdlib/number/ctor' ); + +var bool = isPositiveFinite.isPrimitive( 3.0 ); +// returns true + +bool = isPositiveFinite.isPrimitive( 3.0/0.0 ); +// returns false + +bool = isPositiveFinite.isPrimitive( new Number( 3.0 ) ); +// returns false +``` + +#### isPositiveFinite.isObject( value ) + +Tests if a `value` is a `Number` object having a non-infinite positive value. + + + +```javascript +var Number = require( '@stdlib/number/ctor' ); + +var bool = isPositiveFinite.isObject( new Number( 3.0 ) ); +// returns true + +bool = isPositiveFinite.isObject( 3.0 ); +// returns false + +bool = isPositiveFinite.isObject( new Number( 3.0/0.0 ) ); +// returns false +``` + +
+ + + +
+ +## Examples + + + + + +```javascript +var Number = require( '@stdlib/number/ctor' ); +var isPositiveFinite = require( '@stdlib/assert/is-positive-finite' ); + +var bool = isPositiveFinite( 5.0 ); +// returns true + +bool = isPositiveFinite( new Number( 5.0 ) ); +// returns true + +bool = isPositiveFinite( 3.14 ); +// returns true + +bool = isPositiveFinite( 0.0 ); +// returns false + +bool = isPositiveFinite( 1.0/0.0 ); +// returns false + +bool = isPositiveFinite( new Number( 5.0/0.0 ) ); +// returns false + +bool = isPositiveFinite( -5.0 ); +// returns false + +bool = isPositiveFinite( '5' ); +// returns false + +bool = isPositiveFinite( null ); +// returns false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/assert/is-positive-finite/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/is-positive-finite/benchmark/benchmark.js new file mode 100644 index 000000000000..20297decf596 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-positive-finite/benchmark/benchmark.js @@ -0,0 +1,228 @@ +/** +* @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. +*/ + +/* eslint-disable no-undefined, no-empty-function */ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var Number = require( '@stdlib/number/ctor' ); +var pkg = require( './../package.json' ).name; +var isPositiveFinite = require( './../lib' ); + + +// MAIN // + +bench( pkg+'::primitives', function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + '5', + 5.00/0.00, + new Number( 5.0/0.00 ), + 5.0, + 4.0, + 3.14, + -5.0, + -4.0, + NaN, + true, + false, + null, + undefined + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isPositiveFinite( values[ i % values.length ] ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::objects', function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + [], + {}, + function noop() {}, + new Number( 2.0 ), + new Number( -3.0 ), + new Number( 3.14/0.00 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isPositiveFinite( values[ i % values.length ] ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::primitives:isPrimitive', function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + '5', + 5.0, + 4.0, + 3.14, + 5.00/0.00, + new Number( 5.0/0.00 ), + -5.0, + -4.0, + NaN, + true, + false, + null, + undefined + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isPositiveFinite.isPrimitive( values[ i % values.length ] ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::objects:isPrimitive', function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + [], + {}, + 5.00/0.00, + function noop() {}, + new Number( 2.0 ), + new Number( -3.0 ), + new Number( 3.14 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isPositiveFinite.isPrimitive( values[ i % values.length ] ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::primitives:isObject', function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + '5', + 5.0, + 5.00/0.00, + new Number( 5.0/0.00 ), + 4.0, + 3.14, + -5.0, + -4.0, + NaN, + true, + false, + null, + undefined + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isPositiveFinite.isObject( values[ i % values.length ] ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::objects:isObject', function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + [], + {}, + function noop() {}, + new Number( 2.0 ), + new Number( -3.0 ), + new Number( 3.14/0.00 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isPositiveFinite.isObject( values[ i % values.length ] ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/assert/is-positive-finite/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-positive-finite/docs/repl.txt new file mode 100644 index 000000000000..b2f82a2053d5 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-positive-finite/docs/repl.txt @@ -0,0 +1,85 @@ + +{{alias}}( value ) + Tests if a value is a non-infinite positive number. + + Parameters + ---------- + value: any + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating whether value is a + non-infinite positive number. + + Examples + -------- + > var bool = {{alias}}( 5.0 ) + true + > bool = {{alias}}( new Number( 5.0 ) ) + true + > bool = {{alias}}( 3.14 ) + true + > bool = {{alias}}( -5.0 ) + false + > var bool = {{alias}}( 5.0/0.0 ) + false + > bool = {{alias}}( new Number( 5.0/0.0 ) ) + false + > bool = {{alias}}( null ) + false + + +{{alias}}.isPrimitive( value ) + Tests if a value is a number primitive having a + non-infinite positive value. + + Parameters + ---------- + value: any + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating if a value is a number primitive having + a non-infinite positive value. + + Examples + -------- + > var bool = {{alias}}.isPrimitive( 3.0 ) + true + > var bool = {{alias}}.isPrimitive( 3.0/0.0 ) + false + > bool = {{alias}}.isPrimitive( new Number( 3.0 ) ) + false + + +{{alias}}.isObject( value ) + Tests if a value is a number object having a non-infinite positive value. + + Parameters + ---------- + value: any + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating whether value is a number object + having a non-infinite positive value. + + Examples + -------- + > var bool = {{alias}}.isObject( 3.0 ) + false + > bool = {{alias}}.isObject( new Number( 3.0 ) ) + true + > bool = {{alias}}.isObject( new Number( 3.0/0.0 ) ) + false + + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/assert/is-positive-finite/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-positive-finite/docs/types/index.d.ts new file mode 100644 index 000000000000..65a3a2694fe4 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-positive-finite/docs/types/index.d.ts @@ -0,0 +1,147 @@ +/* +* @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 + +/** +* Interface defining `isPositiveFinite` with methods for testing for primitives and objects, respectively. +*/ +interface isPositiveFinite { + /** + * Tests if a value is a non-infinite positive number. + * + * @param value - value to test + * @returns boolean indicating whether value is a non-infinite positive number + * + * var bool = isPositiveFinite( 5.0 ); + * // returns true + * + * bool = isPositiveFinite( new Number( 5.0 ) ); + * // returns true + * + * bool = isPositiveFinite( 3.14 ); + * // returns true + * + * bool = isPositiveFinite( new Number( 5.0/0.0 ) ); + * // returns false + * + * bool = isPositiveFinite( -5.0 ); + * // returns false + * + * bool = isPositiveFinite( 5.0/0.0 ); + * // returns false + * + * bool = isPositiveFinite( null ); + * // returns false + */ + ( value: any ): value is number | Number; + + /** + * Tests if a value is a number primitive having a non-infinite positive value. + * + * @param value - value to test + * @returns boolean indicating if a value is a number primitive having a non-infinite positive value + * + * @example + * var bool = isPositiveFinite.isPrimitive( 3.0 ); + * // returns true + * + * @example + * var bool = isPositiveFinite.isPrimitive( 3.0/0.0 ); + * // returns true + * + * @example + * var bool = isPositiveFinite.isPrimitive( new Number( 3.0 ) ); + * // returns false + * @example + * var bool = isPositiveFinite.isPrimitive( new Number( 3.0/0.0 ) ); + * // returns false + */ + isPrimitive( value: any ): value is number; + + /** + * Tests if a value is a number object having a non-infinite positive value. + * + * @param value - value to test + * @returns boolean indicating if a value is a number object having a non-infinite positive value + * + * @example + * var bool = isPositiveFinite.isObject( 3.0 ); + * // returns false + * @example + * var bool = isPositiveFinite.isObject( new Number( 3.0/0.0 )); + * // returns false + * @example + * var bool = isPositiveFinite.isObject( new Number( 3.0 ) ); + * // returns true + */ + isObject( value: any ): value is Number; +} + +/** +* Tests if a value is a non-infinite positive number. +* +* @param value - value to test +* @returns boolean indicating whether value is a non-infinite positive number +* +* @example +* var bool = isPositiveFinite( 5.0 ); +* // returns true +* +* @example +* var bool = isPositiveFinite( new Number( 5.0 ) ); +* // returns true +* +* @example +* var bool = isPositiveFinite( 3.14 ); +* // returns true +* +* @example +* var bool = isPositiveFinite( 5.0/0.0 ); +* // returns false +* +* @example +* var bool = isPositiveFinite( new Number( 5.0/0.0 ) ); +* // returns false +* +* @example +* var bool = isPositiveFinite( -5.0 ); +* // returns false +* +* @example +* var bool = isPositiveFinite( null ); +* // returns false +* +* @example +* var bool = isPositiveFinite.isPrimitive( 3.0 ); +* // returns true +* +* @example +* var bool = isPositiveFinite.isPrimitive( 3.0/0.0 ); +* // returns false +* +* @example +* var bool = isPositiveFinite.isObject( 3.0 ); +* // returns false +*/ +declare var isPositiveFinite: isPositiveFinite; + + +// EXPORTS // + +export = isPositiveFinite; diff --git a/lib/node_modules/@stdlib/assert/is-positive-finite/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-positive-finite/docs/types/test.ts new file mode 100644 index 000000000000..008e3d0cee86 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-positive-finite/docs/types/test.ts @@ -0,0 +1,61 @@ +/* +* @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 isPositiveFinite = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isPositiveFinite( 3 ); // $ExpectType boolean + isPositiveFinite( -2 ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isPositiveFinite(); // $ExpectError + isPositiveFinite( 2, 123 ); // $ExpectError +} + +// Attached to main export is an isPrimitive method which returns a boolean... +{ + // eslint-disable-next-line no-new-wrappers + isPositiveFinite.isPrimitive( new Number( 2 ) ); // $ExpectType boolean + isPositiveFinite.isPrimitive( 2 ); // $ExpectType boolean +} + +// The compiler throws an error if the isPrimitive method is provided an unsupported number of arguments... +{ + isPositiveFinite.isPrimitive(); // $ExpectError + isPositiveFinite.isPrimitive( 2, 123 ); // $ExpectError +} + + +// Attached to main export is an isPrimitive method which returns a boolean... +{ + // eslint-disable-next-line no-new-wrappers + isPositiveFinite.isObject( new Number( 2 ) ); // $ExpectType boolean + isPositiveFinite.isObject( 2 ); // $ExpectType boolean +} + +// The compiler throws an error if the isObject method is provided an unsupported number of arguments... +{ + isPositiveFinite.isObject(); // $ExpectError + isPositiveFinite.isObject( 2, 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/is-positive-finite/examples/index.js b/lib/node_modules/@stdlib/assert/is-positive-finite/examples/index.js new file mode 100644 index 000000000000..82ad89079b77 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-positive-finite/examples/index.js @@ -0,0 +1,49 @@ +/** +* @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 Number = require( '@stdlib/number/ctor' ); +var isPositiveFinite = require( './../lib' ); + +console.log( isPositiveFinite( 5.0 ) ); +// => true + +console.log( isPositiveFinite( new Number( 5.0 ) ) ); +// => true + +console.log( isPositiveFinite( 3.14 ) ); +// => true + +console.log( isPositiveFinite( new Number( 5.0/0.00 ) ) ); +// => false + +console.log( isPositiveFinite( 3.14/0.00 ) ); +// => false + +console.log( isPositiveFinite( 0.0 ) ); +// => false + +console.log( isPositiveFinite( -5.0 ) ); +// => false + +console.log( isPositiveFinite( '5' ) ); +// => false + +console.log( isPositiveFinite( null ) ); +// => false diff --git a/lib/node_modules/@stdlib/assert/is-positive-finite/lib/index.js b/lib/node_modules/@stdlib/assert/is-positive-finite/lib/index.js new file mode 100644 index 000000000000..a0ac69045b71 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-positive-finite/lib/index.js @@ -0,0 +1,85 @@ +/** +* @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'; + +/** +* Test if a value is a non-infinite positive number. +* +* @module @stdlib/assert/is-positive-finite +* +* @example +* var isPositiveFinite = require( '@stdlib/assert/is-positive-finite' ); +* +* var bool = isPositiveFinite( 5.0 ); +* // returns true +* +* bool = isPositiveFinite( new Number( 5.0 ) ); +* // returns true +* +* bool = isPositiveFinite( 3.14 ); +* // returns true +* +* bool = isPositiveFinite( new Number( 5.0/0.0 ) ); +* // returns false +* +* bool = isPositiveFinite( -5.0 ); +* // returns false +* +* bool = isPositiveFinite( -5.0/0.0 ); +* // returns false +* +* bool = isPositiveFinite( null ); +* // returns false +* +* @example +* var isPositiveFinite = require( '@stdlib/assert/is-positive-finite' ).isPrimitive; +* +* var bool = isPositiveFinite( 3.0 ); +* // returns true +* +* bool = isPositiveFinite( new Number( 3.0 ) ); +* // returns false +* +* @example +* var isPositiveFinite = require( '@stdlib/assert/is-positive-finite' ).isObject; +* +* var bool = isPositiveFinite( 3.0 ); +* // returns false +* +* bool = isPositiveFinite( new Number( 3.0 ) ); +* // returns true +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var isPrimitive = require( './primitive.js' ); +var isObject = require( './object.js' ); + + +// MAIN // + +setReadOnly( main, 'isPrimitive', isPrimitive ); +setReadOnly( main, 'isObject', isObject ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/is-positive-finite/lib/main.js b/lib/node_modules/@stdlib/assert/is-positive-finite/lib/main.js new file mode 100644 index 000000000000..252387870d8a --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-positive-finite/lib/main.js @@ -0,0 +1,62 @@ +/** +* @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 isPrimitiveFinite = require( './primitive.js' ); +var isObjectFinite = require( './object.js' ); + + +// MAIN // + +/** +* Tests if a value is a non-infinite positive number. +* +* @param {*} value - value to test +* @returns {boolean} boolean indicating whether value is a non-infinite positive number +* +* @example +* var bool = isPositiveFinite( 5.0 ); +* // returns true +* +* @example +* var bool = isPositiveFinite( new Number( 5.0 ) ); +* // returns true +* +* @example +* var bool = isPositiveFinite( -5.0 ); +* // returns false +* +* @example +* var bool = isPositiveFinite( new Number( 5.0 )/0.0 ); +* // returns false +* +* @example +* var bool = isPositiveFinite( null ); +* // returns false +*/ +function isPositiveFinite( value ) { + return ( isPrimitiveFinite( value ) || isObjectFinite( value ) ); +} + + +// EXPORTS // + +module.exports = isPositiveFinite; diff --git a/lib/node_modules/@stdlib/assert/is-positive-finite/lib/object.js b/lib/node_modules/@stdlib/assert/is-positive-finite/lib/object.js new file mode 100644 index 000000000000..4974dda5534e --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-positive-finite/lib/object.js @@ -0,0 +1,56 @@ +/** +* @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 isNumber = require( '@stdlib/assert/is-number' ).isObject; +var isInfiniteObject = require( '@stdlib/assert/is-infinite' ).isObject; + + +// MAIN // + +/** +* Tests if a value is a number object having a non-infinite positive value. +* +* @param {*} value - value to test +* @returns {boolean} boolean indicating if a value is a number object having a non-infinite positive value +* +* @example +* var bool = isPositiveFinite( 3.0 ); +* // returns false +* +* @example +* var bool = isPositiveFinite( new Number( 3.0 ) ); +* // returns true +* +* @example +* var bool = isPositiveFinite( new Number( 1.0/0.0 ) ); +* // returns false +*/ +function isPositiveFinite( value ) { + return ( + isNumber( value ) && value.valueOf() > 0.0 && !isInfiniteObject( value ) + ); +} + + +// EXPORTS // + +module.exports = isPositiveFinite; diff --git a/lib/node_modules/@stdlib/assert/is-positive-finite/lib/primitive.js b/lib/node_modules/@stdlib/assert/is-positive-finite/lib/primitive.js new file mode 100644 index 000000000000..2e71e2d9620c --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-positive-finite/lib/primitive.js @@ -0,0 +1,57 @@ +/** +* @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 isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var isInfinitePrimitive = require( '@stdlib/assert/is-infinite').isPrimitive; + + +// MAIN // + +/** +* Tests if a value is a number primitive having a non-infinite positive value. +* +* @param {*} value - value to test +* @returns {boolean} boolean indicating if a value is a number primitive having a non-infinite positive value +* +* @example +* var bool = isPositiveFinite( 3.0 ); +* // returns true +* +* @example +* var bool = isPositiveFinite( 3.0/0.0 ); +* // returns false +* +* @example +* var bool = isPositiveFinite( new Number( 3.0 ) ); +* // returns false +*/ +function isPositiveFinite( value ) { + return ( + isNumber( value ) && + value > 0.0 && !isInfinitePrimitive( value ) + ); +} + + +// EXPORTS // + +module.exports = isPositiveFinite; diff --git a/lib/node_modules/@stdlib/assert/is-positive-finite/package.json b/lib/node_modules/@stdlib/assert/is-positive-finite/package.json new file mode 100644 index 000000000000..23d8d2aa9111 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-positive-finite/package.json @@ -0,0 +1,71 @@ +{ + "name": "@stdlib/assert/is-positive-finite", + "version": "0.0.0", + "description": "Test if a value is a number having a non-infinite positive 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", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "number", + "numeric", + "positive", + "is", + "isnumber", + "isnumeric", + "type", + "check", + "primitive", + "object" + ] +} diff --git a/lib/node_modules/@stdlib/assert/is-positive-finite/test/test.js b/lib/node_modules/@stdlib/assert/is-positive-finite/test/test.js new file mode 100644 index 000000000000..ffad92b5ed37 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-positive-finite/test/test.js @@ -0,0 +1,43 @@ +/** +* @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 isPositiveFinite = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isPositiveFinite, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method to test for a primitive number having a non-infinite positive value', function test( t ) { + t.equal( typeof isPositiveFinite.isPrimitive, 'function', 'export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method to test for a number object having a non-infinite positive value', function test( t ) { + t.equal( typeof isPositiveFinite.isObject, 'function', 'export is a function' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/assert/is-positive-finite/test/test.main.js b/lib/node_modules/@stdlib/assert/is-positive-finite/test/test.main.js new file mode 100644 index 000000000000..7d0759b0198e --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-positive-finite/test/test.main.js @@ -0,0 +1,65 @@ +/** +* @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 Number = require( '@stdlib/number/ctor' ); +var isPositiveFinite = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isPositiveFinite, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided a number having a non-infinite positive number value', function test( t ) { + t.equal( isPositiveFinite( 5.0 ), true, 'returns true' ); + t.equal( isPositiveFinite( new Number( 5.0 ) ), true, 'returns true' ); + t.end(); +}); + +tape( 'the function returns `false` if not provided a number having a non-infinite positive number value', function test( t ) { + var values; + var i; + + values = [ + '5', + -3.14, + -1.0, + 0.0, + null, + true, + void 0, + [], + {}, + 5.00/0.00, + new Number( 5.0/0.00 ), + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.equal( isPositiveFinite( values[i] ), false, 'returns false when provided '+values[i] ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/assert/is-positive-finite/test/test.object.js b/lib/node_modules/@stdlib/assert/is-positive-finite/test/test.object.js new file mode 100644 index 000000000000..fc017fd99442 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-positive-finite/test/test.object.js @@ -0,0 +1,74 @@ +/** +* @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 Number = require( '@stdlib/number/ctor' ); +var isPositiveFinite = require( './../lib/object.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isPositiveFinite, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided a number object having a non-infinite positive value', function test( t ) { + t.equal( isPositiveFinite( new Number( 5.0 ) ), true, 'returns true' ); + t.end(); +}); + +tape( 'the function returns `false` if provided a primitive number, even if the number is a non-infinite positive value', function test( t ) { + t.equal( isPositiveFinite( 3.0 ), false, 'returns false' ); + t.end(); +}); + +tape( 'the function returns `false` if provided a positive infinite number', function test( t ) { + t.equal( isPositiveFinite( new Number(5.00/0.00) ), false, 'returns false' ); + t.end(); +}); + +tape( 'the function returns `false` if not provided a non-infinite positive number', function test( t ) { + var values; + var i; + + values = [ + '5', + null, + true, + void 0, + [], + {}, + new Date(), + 5.00/0.00, + + /./, + new RegExp( '.' ), // eslint-disable-line prefer-regex-literals + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.equal( isPositiveFinite( values[i] ), false, 'returns false when provided '+values[i] ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/assert/is-positive-finite/test/test.primitive.js b/lib/node_modules/@stdlib/assert/is-positive-finite/test/test.primitive.js new file mode 100644 index 000000000000..3d4dff43281c --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-positive-finite/test/test.primitive.js @@ -0,0 +1,64 @@ +/** +* @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 Number = require( '@stdlib/number/ctor' ); +var isPositiveFinite = require( './../lib/primitive.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isPositiveFinite, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided a primitive number having a non-infinite positive value', function test( t ) { + t.equal( isPositiveFinite( 3.0 ), true, 'returns true' ); + t.end(); +}); + +tape( 'the function returns `false` if provided a number object, even if the number has a non-infinite positive value', function test( t ) { + t.equal( isPositiveFinite( new Number( 5.0 ) ), false, 'returns false' ); + t.end(); +}); + +tape( 'the function returns `false` if not provided a number', function test( t ) { + var values; + var i; + + values = [ + '5', + null, + true, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.equal( isPositiveFinite( values[i] ), false, 'returns false when provided '+values[i] ); + } + t.end(); +});