diff --git a/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/README.md b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/README.md new file mode 100644 index 000000000000..888f8f49e7d3 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/README.md @@ -0,0 +1,149 @@ + + +# isBooleanDataType + +> Test if an input value is a supported ndarray boolean [data type][@stdlib/ndarray/dtypes]. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var isBooleanDataType = require( '@stdlib/ndarray/base/assert/is-boolean-data-type' ); +``` + +#### isBooleanDataType( value ) + +Tests if an input `value` is a supported ndarray boolean [data type][@stdlib/ndarray/dtypes]. + +```javascript +var bool = isBooleanDataType( 'bool' ); +// returns true + +bool = isBooleanDataType( 'uint32' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var isBooleanDataType = require( '@stdlib/ndarray/base/assert/is-boolean-data-type' ); + +var bool = isBooleanDataType( 'binary' ); +// returns false + +bool = isBooleanDataType( 'bool' ); +// returns true + +bool = isBooleanDataType( 'float32' ); +// returns false + +bool = isBooleanDataType( 'float64' ); +// returns false + +bool = isBooleanDataType( 'generic' ); +// returns false + +bool = isBooleanDataType( 'int16' ); +// returns false + +bool = isBooleanDataType( 'int32' ); +// returns false + +bool = isBooleanDataType( 'int8' ); +// returns false + +bool = isBooleanDataType( 'uint16' ); +// returns false + +bool = isBooleanDataType( 'uint32' ); +// returns false + +bool = isBooleanDataType( 'uint8' ); +// returns false + +bool = isBooleanDataType( 'uint8c' ); +// returns false + +bool = isBooleanDataType( '' ); +// returns false + +bool = isBooleanDataType( 'foo' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/benchmark/benchmark.js b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/benchmark/benchmark.js new file mode 100644 index 000000000000..58b56d3357a6 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/benchmark/benchmark.js @@ -0,0 +1,73 @@ +/** +* @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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var isBooleanDataType = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var v; + var i; + + values = [ + 'binary', + 'bool', + 'complex64', + 'complex128', + 'float32', + 'float64', + 'generic', + 'int16', + 'int32', + 'int8', + 'uint16', + 'uint32', + 'uint8', + 'uint8c', + 'foo', + 'bar', + '', + 'beep', + 'boop' + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = values[ i%values.length ]; + out = isBooleanDataType( v ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/docs/repl.txt b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/docs/repl.txt new file mode 100644 index 000000000000..fd0f0bf204d0 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/docs/repl.txt @@ -0,0 +1,47 @@ + +{{alias}}( value ) + Tests if an input value is a supported ndarray boolean data type. + + Parameters + ---------- + value: any + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating if an input value is a supported ndarray boolean + data type. + + Examples + -------- + > var bool = {{alias}}( 'binary' ) + false + > bool = {{alias}}( 'bool' ) + true + > bool = {{alias}}( 'float32' ) + false + > bool = {{alias}}( 'float64' ) + false + > bool = {{alias}}( 'int16' ) + false + > bool = {{alias}}( 'int32' ) + false + > bool = {{alias}}( 'int8' ) + false + > bool = {{alias}}( 'uint16' ) + false + > bool = {{alias}}( 'uint32' ) + false + > bool = {{alias}}( 'uint8' ) + false + > bool = {{alias}}( 'uint8c' ) + false + > bool = {{alias}}( '' ) + false + > bool = {{alias}}( 'beep' ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/docs/types/index.d.ts b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/docs/types/index.d.ts new file mode 100644 index 000000000000..96b6271c2ab1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/docs/types/index.d.ts @@ -0,0 +1,72 @@ +/* +* @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 + +/** +* Tests whether an input value is a supported ndarray boolean data type. +* +* @param v - value to test +* @returns boolean indicating whether an input value is a supported ndarray boolean data type +* +* @example +* var bool = isBooleanDataType( 'binary' ); +* // returns false +* +* bool = isBooleanDataType( 'bool' ); +* // returns true +* +* bool = isBooleanDataType( 'float32' ); +* // returns false +* +* bool = isBooleanDataType( 'float64' ); +* // returns false +* +* bool = isBooleanDataType( 'generic' ); +* // returns false +* +* bool = isBooleanDataType( 'int16' ); +* // returns false +* +* bool = isBooleanDataType( 'int32' ); +* // returns false +* +* bool = isBooleanDataType( 'int8' ); +* // returns false +* +* bool = isBooleanDataType( 'uint16' ); +* // returns false +* +* bool = isBooleanDataType( 'uint32' ); +* // returns false +* +* bool = isBooleanDataType( 'uint8' ); +* // returns false +* +* bool = isBooleanDataType( 'uint8c' ); +* // returns false +* +* bool = isBooleanDataType( 'foo' ); +* // returns false +*/ +declare function isBooleanDataType( v: any ): boolean; + + +// EXPORTS // + +export = isBooleanDataType; diff --git a/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/docs/types/test.ts b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/docs/types/test.ts new file mode 100644 index 000000000000..8bbb71c12bae --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/docs/types/test.ts @@ -0,0 +1,34 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2023 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 isFloatingPointDataType = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isFloatingPointDataType( 'binary' ); // $ExpectType boolean + isFloatingPointDataType( 'foo' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isFloatingPointDataType(); // $ExpectError + isFloatingPointDataType( undefined, 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/examples/index.js b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/examples/index.js new file mode 100644 index 000000000000..fadd35a411cc --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/examples/index.js @@ -0,0 +1,77 @@ +/** +* @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 isBooleanDataType = require( './../lib' ); + +var bool = isBooleanDataType( 'binary' ); +console.log( bool ); +// => false + +bool = isBooleanDataType( 'bool' ); +console.log( bool ); +// => true + +bool = isBooleanDataType( 'float32' ); +console.log( bool ); +// => false + +bool = isBooleanDataType( 'float64' ); +console.log( bool ); +// => false + +bool = isBooleanDataType( 'generic' ); +console.log( bool ); +// => false + +bool = isBooleanDataType( 'int16' ); +console.log( bool ); +// => false + +bool = isBooleanDataType( 'int32' ); +console.log( bool ); +// => false + +bool = isBooleanDataType( 'int8' ); +console.log( bool ); +// => false + +bool = isBooleanDataType( 'uint16' ); +console.log( bool ); +// => false + +bool = isBooleanDataType( 'uint32' ); +console.log( bool ); +// => false + +bool = isBooleanDataType( 'uint8' ); +console.log( bool ); +// => false + +bool = isBooleanDataType( 'uint8c' ); +console.log( bool ); +// => false + +bool = isBooleanDataType( '' ); +console.log( bool ); +// => false + +bool = isBooleanDataType( 'foo' ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/lib/index.js b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/lib/index.js new file mode 100644 index 000000000000..e84cda425337 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/lib/index.js @@ -0,0 +1,76 @@ +/** +* @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 whether an input value is a supported ndarray boolean data type. +* +* @module @stdlib/ndarray/base/assert/is-boolean-data-type +* +* @example +* var isBooleanDataType = require( '@stdlib/ndarray/base/assert/is-boolean-data-type' ); +* +* var bool = isBooleanDataType( 'binary' ); +* // returns false +* +* bool = isBooleanDataType( 'bool' ); +* // returns true +* +* bool = isBooleanDataType( 'float32' ); +* // returns false +* +* bool = isBooleanDataType( 'float64' ); +* // returns false +* +* bool = isBooleanDataType( 'generic' ); +* // returns false +* +* bool = isBooleanDataType( 'int16' ); +* // returns false +* +* bool = isBooleanDataType( 'int32' ); +* // returns false +* +* bool = isBooleanDataType( 'int8' ); +* // returns false +* +* bool = isBooleanDataType( 'uint16' ); +* // returns false +* +* bool = isBooleanDataType( 'uint32' ); +* // returns false +* +* bool = isBooleanDataType( 'uint8' ); +* // returns false +* +* bool = isBooleanDataType( 'uint8c' ); +* // returns false +* +* bool = isBooleanDataType( 'foo' ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/lib/main.js b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/lib/main.js new file mode 100644 index 000000000000..4a49de8a95ce --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/lib/main.js @@ -0,0 +1,82 @@ +/** +* @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 contains = require( '@stdlib/array/base/assert/contains' ).factory; +var dtypes = require( '@stdlib/ndarray/dtypes' ); + + +// MAIN // + +/** +* Tests whether an input value is a supported ndarray boolean data type. +* +* @name isBooleanDataType +* @type {Function} +* @param {*} v - value to test +* @returns {boolean} boolean indicating whether an input value is a supported ndarray boolean data type +* +* @example +* var bool = isBooleanDataType( 'binary' ); +* // returns false +* +* bool = isBooleanDataType( 'bool' ); +* // returns true +* +* bool = isBooleanDataType( 'float32' ); +* // returns false +* +* bool = isBooleanDataType( 'float64' ); +* // returns false +* +* bool = isBooleanDataType( 'generic' ); +* // returns false +* +* bool = isBooleanDataType( 'int16' ); +* // returns false +* +* bool = isBooleanDataType( 'int32' ); +* // returns false +* +* bool = isBooleanDataType( 'int8' ); +* // returns false +* +* bool = isBooleanDataType( 'uint16' ); +* // returns false +* +* bool = isBooleanDataType( 'uint32' ); +* // returns false +* +* bool = isBooleanDataType( 'uint8' ); +* // returns false +* +* bool = isBooleanDataType( 'uint8c' ); +* // returns false +* +* bool = isBooleanDataType( 'foo' ); +* // returns false +*/ +var isBooleanDataType = contains( dtypes( 'boolean' ) ); + + +// EXPORTS // + +module.exports = isBooleanDataType; diff --git a/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/package.json b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/package.json new file mode 100644 index 000000000000..b14dcbbee1c1 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/package.json @@ -0,0 +1,75 @@ +{ + "name": "@stdlib/ndarray/base/assert/is-boolean-data-type", + "version": "0.0.0", + "description": "Test if an input value is a supported ndarray boolean data type.", + "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", + "stdtypes", + "types", + "base", + "ndarray", + "dtype", + "data", + "multidimensional", + "array", + "utilities", + "utility", + "utils", + "util", + "assert", + "test", + "check", + "is", + "valid", + "validate", + "validation", + "isvalid" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/test/test.js b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/test/test.js new file mode 100644 index 000000000000..1ad3ef7a7256 --- /dev/null +++ b/lib/node_modules/@stdlib/ndarray/base/assert/is-boolean-data-type/test/test.js @@ -0,0 +1,95 @@ +/** +* @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 isBooleanDataType = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isBooleanDataType, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided a supported ndarray boolean data type', function test( t ) { + var values; + var bool; + var i; + + values = [ + 'bool' + ]; + for ( i = 0; i < values.length; i++ ) { + bool = isBooleanDataType( values[ i ] ); + t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +}); + +tape( 'the function returns `false` if not provided a supported ndarray boolean data type', function test( t ) { + var values; + var bool; + var i; + + values = [ + // Supported types: + 'binary', + 'complex64', + 'complex128', + 'float32', + 'float64', + 'uint16', + 'uint32', + 'uint8', + 'uint8c', + 'int16', + 'int32', + 'int8', + 'generic', + + // Unsupported dtypes: + 'float', + 'int', + 'bin', + '', + 'beep', + 'boop', + 'foo', + 'bar', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + bool = isBooleanDataType( values[ i ] ); + t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +});