array-dtype
Returns an array data type corresponding to an array constructor name.
Installation
$ npm install dstructs-array-dtype
For use in the browser, use browserify.
Usage
var getType = ;
getType( name )
Returns an array
data type corresponding to an array
constructor name.
var dtype = ;// returns 'float32'var arr = 10 ;dtype = ;// returns 'float32'// Note: not supported in IEdtype = ;// returns 'float32'
The following array
constructors are supported:
Constructor | Data Type |
---|---|
Int8Array |
int8 |
Uint8Array |
uint8 |
Uint8ClampedArray |
uint8_clamped |
Int16Array |
int16 |
Uint16Array |
uint16 |
Int32Array |
int32 |
Uint32Array |
uint32 |
Float32Array |
float32 |
Float64Array |
float64 |
Array |
generic |
Examples
var getType = ;console;// returns 'int8'console;// returns 'uint8'console;// returns 'uint8_clamped'console;// returns 'int16'console;// returns 'uint16'console;// returns 'int32'console;// returns 'uint32'console;// returns 'float32'console;// returns 'float64'console;// returns 'generic'console;// returns nullconsole;// returns nullconsole;// returns nullconsole;// returns nullconsole;// returns nullconsole;// returns nullconsole;// returns nullconsole;// returns null
To run the example code from the top-level application directory,
$ node ./examples/index.js
Tests
Unit
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ make view-cov
License
Copyright
Copyright © 2015. The Compute.io Authors.