@stdlib/assert-is-symbol-array
v0.2.2
Published
Test if a value is an array-like object containing only symbols.
Downloads
15
Readme
isSymbolArray
Test if a value is an array-like object containing only symbols.
Installation
npm install @stdlib/assert-is-symbol-array
Usage
var isSymbolArray = require( '@stdlib/assert-is-symbol-array' );
isSymbolArray( value )
Tests if a value
is an array-like object containing only symbols.
var Symbol = require( '@stdlib/symbol-ctor' );
var bool = isSymbolArray( [ Symbol( 'beep' ), Symbol( 'boop' ) ] );
// returns true
bool = isSymbolArray( [ 'beep', 'boop' ] );
// returns false
isSymbolArray.primitives( value )
Tests if a value
is an array-like object containing only symbol
primitives.
var Object = require( '@stdlib/object-ctor' );
var Symbol = require( '@stdlib/symbol-ctor' );
var bool = isSymbolArray.primitives( [ Symbol( 'beep' ), Symbol( 'boop' ) ] );
// returns true
bool = isSymbolArray.primitives( [ Symbol( 'beep' ), Object( Symbol( 'boop' ) ) ] );
// returns false
isSymbolArray.objects( value )
Tests if a value
is an array-like object containing only Symbol
objects.
var Object = require( '@stdlib/object-ctor' );
var Symbol = require( '@stdlib/symbol-ctor' );
var bool = isSymbolArray.objects( [ Object( Symbol( 'beep' ) ), Object( Symbol( 'boop' ) ) ] );
// returns true
bool = isSymbolArray.objects( [ Symbol( 'beep' ), Symbol( 'boop' ) ] );
// returns false
Examples
var hasSymbolSupport = require( '@stdlib/assert-has-symbol-support' );
var Symbol = require( '@stdlib/symbol-ctor' );
var isSymbolArray = require( '@stdlib/assert-is-symbol-array' );
var hasSymbols = hasSymbolSupport();
var bool;
if ( hasSymbols ) {
bool = isSymbolArray( [ Symbol( 'beep' ), Symbol( 'boop' ) ] );
// returns true
bool = isSymbolArray( [ Symbol( 'beep' ), 'boop' ] );
// returns false
bool = isSymbolArray( Symbol( 'beep' ) );
// returns false
} else {
console.log( 'Environment does not support symbols.' );
}
bool = isSymbolArray( [ 'beep', 'boop' ] );
// returns false
bool = isSymbolArray( [] );
// returns false
bool = isSymbolArray( 'abc' );
// returns false
bool = isSymbolArray( null );
// returns false
See Also
@stdlib/assert-is-array
: test if a value is an array.@stdlib/assert-is-symbol
: test if a value is a symbol.
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.