str2enum
Return the enumeration constant associated with an ndarray data type string.
Usage
var str2enum = require( '@stdlib/ndarray/base/dtype-str2enum' );
str2enum( dtype )
Returns the enumeration constant associated with an ndarray data type string
.
var v = str2enum( 'float64' );
// returns <number>
If unable to resolve an enumeration constant, the function returns null
.
var v = str2enum( 'beep' );
// returns null
Notes
- Downstream consumers of this function should not rely on specific integer values (e.g.,
INT8 == 0
). Instead, the function should be used in an opaque manner.
Examples
var str2enum = require( '@stdlib/ndarray/base/dtype-str2enum' );
var v = str2enum( 'float64' );
// returns <number>
v = str2enum( 'float32' );
// returns <number>
v = str2enum( 'int32' );
// returns <number>
v = str2enum( 'int16' );
// returns <number>
v = str2enum( 'int8' );
// returns <number>
v = str2enum( 'uint32' );
// returns <number>
v = str2enum( 'uint16' );
// returns <number>
v = str2enum( 'uint8' );
// returns <number>