# dstructs-cast-arrays

> Casts an array to an array of a different data type.

Latest version **1.0.3** (published 2015-12-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install dstructs-cast-arrays
pnpm add dstructs-cast-arrays
yarn add dstructs-cast-arrays
bun add dstructs-cast-arrays
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2015-12-04 |
| First published | 2015-11-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Athan Reines |
| Maintainers | kgryte |
| Keywords | compute.io, compute, computation, dstructs, cast, typed-array, typed, array, array-like, constructor, ctor, dtype, data, type, copy, clone |

## Links

- npm: https://www.npmjs.com/package/dstructs-cast-arrays
- Repository: https://github.com/dstructs/cast-arrays
- Homepage: https://github.com/dstructs/cast-arrays#readme
- Issues: https://github.com/dstructs/cast-arrays/issues
- npm.io page: https://npm.io/package/dstructs-cast-arrays

## Dependencies (4)

- [type-name](https://npm.io/package/type-name.md) ^1.0.1
- [dstructs-array-dtype](https://npm.io/package/dstructs-array-dtype.md) ^1.0.2
- [validate.io-array-like](https://npm.io/package/validate.io-array-like.md) ^1.0.1
- [dstructs-array-constructors](https://npm.io/package/dstructs-array-constructors.md) ^1.0.2

## Alternatives

- [@libsql/sqlite3](https://npm.io/package/@libsql/sqlite3.md) — 39.8K weekly downloads
- [@fortemi/core](https://npm.io/package/@fortemi/core.md) — 461 weekly downloads
- [cdb-converter](https://npm.io/package/cdb-converter.md) — 341 weekly downloads
- [@uplo/adapter-prisma](https://npm.io/package/@uplo/adapter-prisma.md) — 75 weekly downloads
- [typeorm-aios](https://npm.io/package/typeorm-aios.md) — 30 weekly downloads

## Recent versions

- 1.0.3 (latest) — 2015-12-04
- 1.0.2 — 2015-11-28

## README

cast-arrays
===
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependencies][dependencies-image]][dependencies-url]

> Casts an array to an array of a different data type.


## Installation

``` bash
$ npm install dstructs-cast-arrays
```

For use in the browser, use [browserify][browserify].


## Usage

``` javascript
var cast = require( 'dstructs-cast-arrays' );
```

#### cast( x, type )

Casts an input `array` or [`array-like`][array-like] object to a specified `array` type.

``` javascript
var arr = Int32Array( 10 );

var out = cast( arr, 'float32' );
// returns Float32Array
```

`type` may be either a `string` specifying the desired output `array` data type or a value from which the desired data type should be inferred.

``` javascript
var x = Int32Array( 10 ),
	y = Float32Array( 25 );

// Cast `x` to be the same data type as `y`:
var out = cast( x, y );
// returns Float32Array
```

For a list of supported output `array` data types, see [dstructs-array-constructors][dstructs-array-constructors].



## Examples

``` javascript
var cast = require( 'dstructs-cast-arrays' ),
	arr,
	x, y, z;

arr = new Int8Array( 10 );
x = cast( arr, 'int16' );
// returns Int16Array

arr = new Array( 100 );
y = cast( arr, 'float64' );
// returns Float64Array

z = cast( x, y );
// returns Float64Array
```

To run the example code from the top-level application directory,

``` bash
$ node ./examples/index.js
```


## Tests

### Unit

Unit tests use the [Mocha][mocha] test framework with [Chai][chai] assertions. To run the tests, execute the following command in the top-level application directory:

``` bash
$ make test
```

All new feature development should have corresponding unit tests to validate correct functionality.


### Test Coverage

This repository uses [Istanbul][istanbul] as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

``` bash
$ make test-cov
```

Istanbul creates a `./reports/coverage` directory. To access an HTML version of the report,

``` bash
$ make view-cov
```


---
## License

[MIT license](http://opensource.org/licenses/MIT).


## Copyright

Copyright &copy; 2015. The Compute.io Authors.


[npm-image]: http://img.shields.io/npm/v/dstructs-cast-arrays.svg
[npm-url]: https://npmjs.org/package/dstructs-cast-arrays

[travis-image]: http://img.shields.io/travis/dstructs/cast-arrays/master.svg
[travis-url]: https://travis-ci.org/dstructs/cast-arrays

[codecov-image]: https://img.shields.io/codecov/c/github/dstructs/cast-arrays/master.svg
[codecov-url]: https://codecov.io/github/dstructs/cast-arrays?branch=master

[dependencies-image]: http://img.shields.io/david/dstructs/cast-arrays.svg
[dependencies-url]: https://david-dm.org/dstructs/cast-arrays

[dev-dependencies-image]: http://img.shields.io/david/dev/dstructs/cast-arrays.svg
[dev-dependencies-url]: https://david-dm.org/dev/dstructs/cast-arrays

[github-issues-image]: http://img.shields.io/github/issues/dstructs/cast-arrays.svg
[github-issues-url]: https://github.com/dstructs/cast-arrays/issues

[browserify]: https://github.com/substack/node-browserify
[mocha]: http://mochajs.org/
[chai]: http://chaijs.com
[istanbul]: https://github.com/gotwarlost/istanbul

[array-like]: https://github.com/validate-io/array-like
[dstructs-array-constructors]: https://github.com/dstructs/array-constructors

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