# ts-array-as-tuple

> Function that asserts the length of an array and casts it to a tuple.

Latest version **1.0.1** (published 2018-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install ts-array-as-tuple
pnpm add ts-array-as-tuple
yarn add ts-array-as-tuple
bun add ts-array-as-tuple
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-07-23 |
| First published | 2018-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | David Brockman Smoliansky |
| Maintainers | springworks |

## Links

- npm: https://www.npmjs.com/package/ts-array-as-tuple
- Repository: git@github.com:dbrockman/ts-array-as-tuple
- npm.io page: https://npm.io/package/ts-array-as-tuple

## Recent versions

- 1.0.1 (latest) — 2018-07-23

## README

# ts-array-as-tuple

Function that asserts the length of an array and casts it to a tuple.

## Example

```ts
import { asTuple } from 'ts-array-as-tuple';

const array: string[] = 'hello world'.split(' ');

const tuple: [string, string] = asTuple(array, 2);

asTuple(array, 1);
// Error: Unexpected array length, expected 1 but got 2.

asTuple(array, 3);
// Error: Unexpected array length, expected 3 but got 2.
```

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