Socket
Socket
Sign inDemoInstall

dtype

Package Overview
Dependencies
0
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dtype

Return a data type from a string representing the type


Version published
Weekly downloads
220K
decreased by-5.7%
Maintainers
2
Install size
5.08 kB
Created
Weekly downloads
 

Readme

Source

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.

See ndarray-dtype if you need to support Buffer and other ndarray types.

example

var dtype = require('dtype')
var ndarray = require('ndarray')

var arr = ndarray(new Int8Array(32))

// some time later

var newarr = ndarray(new (dtype(arr.dtype)))

API

dtype(string) will return the following data types based on the strings given:

Data typeString
Int8Array"int8"
Int16Array"int16"
Int32Array"int32"
Uint8Array"uint8"
Uint16Array"uint16"
Uint32Array"uint32"
Float32Array"float32"
Float64Array"float64"
Array"array"
Uint8ClampedArray"uint8_clamped"

Returns undefined if the type isn't recognized.

install

With npm do:

npm install dtype

Use browserify to require('dtype').

see also

release history

  • 2.0.0 - moving buffer, generic and data to a different module
  • 1.0.0 - Add uint8_clamped, generic, data, dataview and buffer types
  • 0.1.0 - initial release

license

Copyright (c) 2015 Kyle Robinson Young
Licensed under the MIT license.

Keywords

FAQs

Last updated on 25 May 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc