array2dtype
Return the WebAssembly data type for a provided array.
Usage
var array2dtype = require( '@stdlib/wasm/base/array2dtype' );
array2dtype( array )
Returns the WebAssembly data type for a provided array
.
var Float64Array = require( '@stdlib/array/float64' );
var arr = new Float64Array( 10 );
var dt = array2dtype( arr );
// returns 'float64'
If provided an argument having "generic" or an unknown/unsupported data type, the function assumes that array values can be stored as double-precision floating-point numbers and returns 'float64'
.
var dt = array2dtype( [] );
// returns 'float64'
Examples
var dtypes = require( '@stdlib/array/dtypes' );
var empty = require( '@stdlib/array/empty' );
var array2dtype = require( '@stdlib/wasm/base/array2dtype' );
// Get a list of supported array data types:
var dt = dtypes();
// For each supported data type, create an array and return its WebAssembly data type...
var v;
var i;
for ( i = 0; i < dt.length; i++ ) {
v = array2dtype( empty( 10, dt[ i ] ) );
console.log( '%s => %s', dt[ i ], v );
}