str2enum
Return the enumeration constant associated with an output ndarray data type policy string.
Usage
var str2enum = require( '@stdlib/ndarray/base/output-policy-str2enum' );
str2enum( policy )
Returns the enumeration constant associated with an output ndarray data type policy string.
var v = str2enum( 'same' );
// 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.,
SAME == 0
). Instead, the function should be used in an opaque manner.
Examples
var str2enum = require( '@stdlib/ndarray/base/output-policy-str2enum' );
var v = str2enum( 'same' );
// returns <number>
v = str2enum( 'promoted' );
// returns <number>
v = str2enum( 'floating_point' );
// returns <number>
v = str2enum( 'real_floating_point' );
// returns <number>
v = str2enum( 'signed_integer' );
// returns <number>
v = str2enum( 'unsigned_integer' );
// returns <number>
v = str2enum( 'complex_floating_point' );
// returns <number>
v = str2enum( 'integer' );
// returns <number>