|
||
---|---|---|
.. | ||
docs | ||
lib | ||
package.json | ||
README.md |
isSymbolArray
Test if a value is an array-like object containing only symbols.
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 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 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