1.0.1 • Published 9 years ago
ndarray-dtype v1.0.1
ndarray-dtype
Return a data type from a string representing the data type.
Mostly useful for using with ndarray
where you would like instantiate a typed array of the same array.dtype
.
This builds on dtype, but includes some ndarray-specific features like 'buffer'
(at the expense of increasing bundle size due to including Buffer).
Usage
arr = dtype(str)
Returns the constructor for the given data type, or undefined
if the string type isn't recognized.
Data type | String |
---|---|
Int8Array | "int8" |
Int16Array | "int16" |
Int32Array | "int32" |
Uint8Array | "uint8" |
Uint16Array | "uint16" |
Uint32Array | "uint32" |
Float32Array | "float32" |
Float64Array | "float64" |
Array | "array" |
Uint8ClampedArray | "uint8_clamped" |
Buffer | "buffer" |
ArrayBuffer | "generic" |
ArrayBuffer | "data" |
ArrayBuffer | "dataview" |
Note: If Buffer
isn't exposed globally, using "buffer"
returns undefined
.
Install
With npm do:
npm install dtype
Use browserify to require('ndarray-dtype')
.
See Also
License
MIT, see LICENSE.md for details.