diff --git a/lib/node_modules/@stdlib/assert/is-booleanarray/README.md b/lib/node_modules/@stdlib/assert/is-booleanarray/README.md new file mode 100644 index 000000000000..1f19f41fd9c7 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-booleanarray/README.md @@ -0,0 +1,138 @@ + + +# isBooleanArray + +> Test if a value is a [BooleanArray][@stdlib/array/bool]. + +
+ +## Usage + +```javascript +var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); +``` + +#### isBooleanArray( value ) + +Tests if a value is a [`BooleanArray`][@stdlib/array/bool]. + +```javascript +var BooleanArray = require( '@stdlib/array/bool' ); + +var bool = isBooleanArray( new BooleanArray( 10 ) ); +// returns true + +bool = isBooleanArray( [] ); +// returns false +``` + +
+ + + +
+ +## Examples + + + +```javascript +var Int8Array = require( '@stdlib/array/int8' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +var Int16Array = require( '@stdlib/array/int16' ); +var Uint16Array = require( '@stdlib/array/uint16' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Uint32Array = require( '@stdlib/array/uint32' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); + +var bool = isBooleanArray( new BooleanArray( 10 ) ); +// returns true + +bool = isBooleanArray( new Complex64Array( 10 ) ); +// returns false + +bool = isBooleanArray( new Complex128Array( 10 ) ); +// returns false + +bool = isBooleanArray( new Float64Array( 10 ) ); +// returns false + +bool = isBooleanArray( new Int8Array( 10 ) ); +// returns false + +bool = isBooleanArray( new Uint8Array( 10 ) ); +// returns false + +bool = isBooleanArray( new Uint8ClampedArray( 10 ) ); +// returns false + +bool = isBooleanArray( new Int16Array( 10 ) ); +// returns false + +bool = isBooleanArray( new Uint16Array( 10 ) ); +// returns false + +bool = isBooleanArray( new Int32Array( 10 ) ); +// returns false + +bool = isBooleanArray( new Uint32Array( 10 ) ); +// returns false + +bool = isBooleanArray( new Float32Array( 10 ) ); +// returns false + +bool = isBooleanArray( new Array( 10 ) ); +// returns false + +bool = isBooleanArray( {} ); +// returns false + +bool = isBooleanArray( null ); +// returns false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/assert/is-booleanarray/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/is-booleanarray/benchmark/benchmark.js new file mode 100644 index 000000000000..3ba08e944a41 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-booleanarray/benchmark/benchmark.js @@ -0,0 +1,135 @@ +/** +* @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 Int8Array = require( '@stdlib/array/int8' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +var Int16Array = require( '@stdlib/array/int16' ); +var Uint16Array = require( '@stdlib/array/uint16' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Uint32Array = require( '@stdlib/array/uint32' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var isBooleanArray = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + new Float64Array( 10 ), + new Float32Array( 10 ), + new Int32Array( 10 ), + new Uint32Array( 10 ), + new Int16Array( 10 ), + new Uint16Array( 10 ), + new Int8Array( 10 ), + new Uint8Array( 10 ), + new Uint8ClampedArray( 10 ), + new Complex64Array( 10 ), + new Complex128Array( 10 ), + new BooleanArray( 10 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isBooleanArray( 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+'::true', function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + new BooleanArray( 10 ), + new BooleanArray( 10 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isBooleanArray( 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+'::false', function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + new Complex128Array( 10 ), + new Complex64Array( 10 ), + new Float64Array( 10 ), + new Float32Array( 10 ), + new Int32Array( 10 ), + new Uint32Array( 10 ), + new Int16Array( 10 ), + new Uint16Array( 10 ), + new Int8Array( 10 ), + new Uint8Array( 10 ), + new Uint8ClampedArray( 10 ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isBooleanArray( 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-booleanarray/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-booleanarray/docs/repl.txt new file mode 100644 index 000000000000..94de4cb2164c --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-booleanarray/docs/repl.txt @@ -0,0 +1,24 @@ + +{{alias}}( value ) + Tests if a value is a BooleanArray. + + Parameters + ---------- + value: any + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating whether a value is a BooleanArray. + + Examples + -------- + > var bool = {{alias}}( new {{alias:@stdlib/array/bool}}( 10 ) ) + true + > bool = {{alias}}( [] ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/assert/is-booleanarray/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-booleanarray/docs/types/index.d.ts new file mode 100644 index 000000000000..eb2baf3e7b74 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-booleanarray/docs/types/index.d.ts @@ -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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { BooleanArray } from '@stdlib/types/array'; + +/** +* Tests if a value is a BooleanArray. +* +* @param value - value to test +* @returns boolean indicating whether a value is a BooleanArray +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* +* var bool = isBooleanArray( new BooleanArray( 10 ) ); +* // returns true +* +* @example +* var bool = isBooleanArray( [] ); +* // returns false +*/ +declare function isBooleanArray( value: any ): value is BooleanArray; + + +// EXPORTS // + +export = isBooleanArray; diff --git a/lib/node_modules/@stdlib/assert/is-booleanarray/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-booleanarray/docs/types/test.ts new file mode 100644 index 000000000000..dd955f8b2eaf --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-booleanarray/docs/types/test.ts @@ -0,0 +1,33 @@ +/* +* @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 isBooleanArray = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isBooleanArray( [] ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isBooleanArray(); // $ExpectError + isBooleanArray( [], 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/is-booleanarray/examples/index.js b/lib/node_modules/@stdlib/assert/is-booleanarray/examples/index.js new file mode 100644 index 000000000000..d6bc45d671e2 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-booleanarray/examples/index.js @@ -0,0 +1,93 @@ +/** +* @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 Int8Array = require( '@stdlib/array/int8' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +var Int16Array = require( '@stdlib/array/int16' ); +var Uint16Array = require( '@stdlib/array/uint16' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Uint32Array = require( '@stdlib/array/uint32' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var isBooleanArray = require( './../lib' ); + +var bool = isBooleanArray( new BooleanArray( 10 ) ); +console.log( bool ); +// => true + +bool = isBooleanArray( new Complex64Array( 10 ) ); +console.log( bool ); +// => false + +bool = isBooleanArray( new Complex128Array( 10 ) ); +console.log( bool ); +// => false + +bool = isBooleanArray( new Float64Array( 10 ) ); +console.log( bool ); +// => false + +bool = isBooleanArray( new Int8Array( 10 ) ); +console.log( bool ); +// => false + +bool = isBooleanArray( new Uint8Array( 10 ) ); +console.log( bool ); +// => false + +bool = isBooleanArray( new Uint8ClampedArray( 10 ) ); +console.log( bool ); +// => false + +bool = isBooleanArray( new Int16Array( 10 ) ); +console.log( bool ); +// => false + +bool = isBooleanArray( new Uint16Array( 10 ) ); +console.log( bool ); +// => false + +bool = isBooleanArray( new Int32Array( 10 ) ); +console.log( bool ); +// => false + +bool = isBooleanArray( new Uint32Array( 10 ) ); +console.log( bool ); +// => false + +bool = isBooleanArray( new Float32Array( 10 ) ); +console.log( bool ); +// => false + +bool = isBooleanArray( new Array( 10 ) ); +console.log( bool ); +// => false + +bool = isBooleanArray( {} ); +console.log( bool ); +// => false + +bool = isBooleanArray( null ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/assert/is-booleanarray/lib/index.js b/lib/node_modules/@stdlib/assert/is-booleanarray/lib/index.js new file mode 100644 index 000000000000..ff6200e0364e --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-booleanarray/lib/index.js @@ -0,0 +1,44 @@ +/** +* @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 BooleanArray. +* +* @module @stdlib/assert/is-booleanarray +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); +* +* var bool = isBooleanArray( new BooleanArray( 10 ) ); +* // returns true +* +* bool = isBooleanArray( [] ); +* // returns false +*/ + +// MODULES // + +var isBooleanArray = require( './main.js' ); + + +// EXPORTS // + +module.exports = isBooleanArray; diff --git a/lib/node_modules/@stdlib/assert/is-booleanarray/lib/main.js b/lib/node_modules/@stdlib/assert/is-booleanarray/lib/main.js new file mode 100644 index 000000000000..85290e8b5fd2 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-booleanarray/lib/main.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 BooleanArray = require( '@stdlib/array/bool' ); +var constructorName = require( '@stdlib/utils/constructor-name' ); + + +// MAIN // + +/** +* Tests if a value is a Complex64Array. +* +* @param {*} value - value to test +* @returns {boolean} boolean indicating whether a value is a BooleanArray +* +* @example +* var BooleanArray = require( '@stdlib/array/bool' ); +* +* var bool = isBooleanArray( new BooleanArray( 10 ) ); +* // returns true +* +* @example +* var bool = isBooleanArray( [] ); +* // returns false +*/ +function isBooleanArray( value ) { + return ( + value instanceof BooleanArray || + constructorName( value ) === 'BooleanArray' + ); +} + + +// EXPORTS // + +module.exports = isBooleanArray; diff --git a/lib/node_modules/@stdlib/assert/is-booleanarray/package.json b/lib/node_modules/@stdlib/assert/is-booleanarray/package.json new file mode 100644 index 000000000000..12b184303d82 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-booleanarray/package.json @@ -0,0 +1,76 @@ +{ + "name": "@stdlib/assert/is-booleanarray", + "version": "0.0.0", + "description": "Test if a value is a BooleanArray.", + "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", + "booleanarray", + "boolean", + "typed", + "typed array", + "typed-array", + "array", + "is", + "isarray", + "istypedarray", + "type", + "check", + "validate", + "valid", + "isvalid", + "test" + ] +} diff --git a/lib/node_modules/@stdlib/assert/is-booleanarray/test/test.js b/lib/node_modules/@stdlib/assert/is-booleanarray/test/test.js new file mode 100644 index 000000000000..dfd3007212b9 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-booleanarray/test/test.js @@ -0,0 +1,84 @@ +/** +* @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 Int8Array = require( '@stdlib/array/int8' ); +var Uint8Array = require( '@stdlib/array/uint8' ); +var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); +var Int16Array = require( '@stdlib/array/int16' ); +var Uint16Array = require( '@stdlib/array/uint16' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Uint32Array = require( '@stdlib/array/uint32' ); +var Float32Array = require( '@stdlib/array/float32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var BooleanArray = require( '@stdlib/array/bool' ); +var isBooleanArray = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isBooleanArray, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided a BooleanArray', function test( t ) { + t.strictEqual( isBooleanArray( new BooleanArray( 10 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `false` if not provided a BooleanArray', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + null, + void 0, + [], + {}, + function noop() {}, + new Array( 10 ), + new Float64Array( 10 ), + new Float32Array( 10 ), + new Uint32Array( 10 ), + new Int32Array( 10 ), + new Uint16Array( 10 ), + new Int16Array( 10 ), + new Uint8Array( 10 ), + new Int8Array( 10 ), + new Uint8ClampedArray( 10 ), + new Complex128Array( 10 ), + new Complex64Array( 10 ) + ]; + + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isBooleanArray( values[i] ), false, 'returns expected value when provided ' + values[i] ); + } + t.end(); +});