Array Constructors
Returns an array constructor corresponding to an array data type.
Installation
$ npm install dstructs-array-constructors
For use in the browser, use browserify.
Usage
var getCtor = ;
getCtor( dtype )
Returns an array
constructor corresponding to an array
data type.
var ctor = ;// returns Int8Array
The following array
data types are supported:
Data Type | Constructor |
---|---|
int8 | Int8Array |
uint8 | Uint8Array |
uint8_clamped | Uint8ClampedArray |
int16 | Int16Array |
uint16 | Uint16Array |
int32 | Int32Array |
uint32 | Uint32Array |
float32 | Float32Array |
float64 | Float64Array |
generic | Array |
Examples
var getCtor = ;console;// returns Int8Arrayconsole;// returns Uint8Arrayconsole;// returns Uint8ClampedArrayconsole;// returns Int16Arrayconsole;// returns Uint16Arrayconsole;// returns Int32Arrayconsole;// returns Uint32Arrayconsole;// returns Float32Arrayconsole;// returns Float64Arrayconsole;// returns Arrayconsole;// 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.