# dtype

> Return a data type from a string representing the type

Latest version **2.0.0** (published 2015-05-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install dtype
pnpm add dtype
yarn add dtype
bun add dtype
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2015-05-25 |
| First published | 2013-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/dtype) |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Kyle Robinson Young |
| Maintainers | shama, mattdesl |
| Keywords | ndarray, array, typed |

## Links

- npm: https://www.npmjs.com/package/dtype
- Repository: https://github.com/shama/dtype
- Issues: https://github.com/shama/dtype/issues
- npm.io page: https://npm.io/package/dtype

## Recent versions

- 2.0.0 (latest) — 2015-05-25
- 1.0.0 — 2015-05-07
- 0.1.0 — 2013-07-02

## README

# dtype

Return a data type from a string representing the data type.

Mostly useful for using with [ndarray](https://github.com/mikolalysenko/ndarray)
where you would like instantiate a typed array of the same `array.dtype`.

See [ndarray-dtype](https://www.npmjs.com/package/ndarray-dtype) if you need to support Buffer and other ndarray types.

## example

```js
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 type | String
--------: | :-----
`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](https://npmjs.org) do:

```
npm install dtype
```

Use [browserify](http://browserify.org) to `require('dtype')`.

## see also

- [ndarray-dtype](https://www.npmjs.com/package/ndarray-dtype)

## 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<br/>
Licensed under the MIT license.

---
_Source: https://npm.io/package/dtype · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
