JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14159
  • Score
    100M100P100Q145917F
  • License Apache-2.0

Return the data type of an array.

Package Exports

  • @stdlib/array-dtype

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@stdlib/array-dtype) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Data Type

NPM version Build Status Coverage Status dependencies

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 );
}

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 © 2016-2021. The Stdlib Authors.