0.3.0 • Published 5 months ago

@stdlib/array-dtype v0.3.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 months ago

Data Type

NPM version Build Status Coverage Status

Return the data type of an array.

Installation

npm install @stdlib/array-dtype

Usage

var dtype = require( '@stdlib/array-dtype' );

dtype( array )

Returns the data type of an array.

var Float64Array = require( '@stdlib/array-float64' );
var arr = new Float64Array( 10 );

var dt = dtype( arr );
// returns 'float64'

If provided an argument having an unknown or unsupported data type, the function returns null.

var dt = dtype( 'beep' );
// returns null

Examples

var dtypes = require( '@stdlib/array-dtypes' );
var ctors = require( '@stdlib/array-ctors' );
var dtype = require( '@stdlib/array-dtype' );

var DTYPES;
var ctor;
var arr;
var len;
var dt;
var i;

// Get a list of supported array data types:
DTYPES = dtypes();

// Array length:
len = 10;

// For each supported data type, create an array and confirm its data type...
for ( i = 0; i < DTYPES.length; i++ ) {
    ctor = ctors( DTYPES[ i ] );
    arr = new ctor( len );
    dt = dtype( arr );
    console.log( '%s == %s => %s', DTYPES[ i ], dt, DTYPES[ i ] === dt );
}

See Also


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

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2024. The Stdlib Authors.

0.3.0

5 months ago

0.2.1

10 months ago

0.2.0

10 months ago

0.1.0

1 year ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

4 years ago

0.0.1

4 years ago