diff --git a/lib/node_modules/@stdlib/array/base/any/lib/main.js b/lib/node_modules/@stdlib/array/base/any/lib/main.js index 76b384e61a2f..04b50cd464a4 100644 --- a/lib/node_modules/@stdlib/array/base/any/lib/main.js +++ b/lib/node_modules/@stdlib/array/base/any/lib/main.js @@ -22,9 +22,11 @@ var isComplex128Array = require( '@stdlib/array/base/assert/is-complex128array' ); var isComplex64Array = require( '@stdlib/array/base/assert/is-complex64array' ); +var isBooleanArray = require( '@stdlib/array/base/assert/is-booleanarray' ); var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); +var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); // FUNCTIONS // @@ -130,6 +132,10 @@ function any( x ) { if ( isComplex64Array( x ) ) { return internal( reinterpret64( x, 0 ) ); } + // If provided a boolean array, reinterpret as typed array and test for truthiness... + if ( isBooleanArray( x ) ) { + return internal( reinterpretBoolean( x, 0 ) ); + } return accessors( obj ); } return internal( x ); diff --git a/lib/node_modules/@stdlib/array/base/any/test/test.js b/lib/node_modules/@stdlib/array/base/any/test/test.js index 1fa564c6983d..9e3b55275006 100644 --- a/lib/node_modules/@stdlib/array/base/any/test/test.js +++ b/lib/node_modules/@stdlib/array/base/any/test/test.js @@ -25,6 +25,7 @@ var AccessorArray = require( '@stdlib/array/base/accessor' ); 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 any = require( './../lib' ); @@ -74,6 +75,17 @@ tape( 'if provided an empty collection, the function returns `false` (complex ty t.end(); }); +tape( 'if provided an empty collection, the function returns `false` (boolean array)', function test( t ) { + var out; + var arr; + + arr = new BooleanArray( [] ); + out = any( arr ); + + t.strictEqual( out, false, 'returns expected value' ); + t.end(); +}); + tape( 'if provided an empty collection, the function returns `false` (accessor)', function test( t ) { var out; var arr; @@ -107,7 +119,7 @@ tape( 'the function returns `true` if at least one element is truthy (real typed t.end(); }); -tape( 'the function returns `true` if at least one element is truthy (real typed array)', function test( t ) { +tape( 'the function returns `true` if at least one element is truthy (complex typed array)', function test( t ) { var out; var arr; @@ -123,6 +135,17 @@ tape( 'the function returns `true` if at least one element is truthy (real typed t.end(); }); +tape( 'the function returns `true` if at least one element is truthy (boolean array)', function test( t ) { + var out; + var arr; + + arr = new BooleanArray( [ false, false, true ] ); + out = any( arr ); + + t.strictEqual( out, true, 'returns expected value' ); + t.end(); +}); + tape( 'the function returns `true` if at least one element is truthy (accessor)', function test( t ) { var out; var arr; @@ -188,6 +211,17 @@ tape( 'the function returns `false` if all elements are falsy (complex typed arr t.end(); }); +tape( 'the function returns `false` if all elements are falsy (boolean array)', function test( t ) { + var out; + var arr; + + arr = new BooleanArray( [ false, false, false, false ] ); + out = any( arr ); + + t.strictEqual( out, false, 'returns expected value' ); + t.end(); +}); + tape( 'the function returns `false` if all elements are falsy (accessor)', function test( t ) { var out; var arr;