# flow-vect

> Statically typed Vect

Latest version **0.9.0** (published 2018-08-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install flow-vect
pnpm add flow-vect
yarn add flow-vect
bun add flow-vect
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.0 |
| Published | 2018-08-16 |
| First published | 2018-07-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 81.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Bannerets |
| Maintainers | save14 |
| Keywords | flow, flowtype |

## Links

- npm: https://www.npmjs.com/package/flow-vect
- Repository: https://github.com/Bannerets/flow-vect
- Homepage: https://github.com/Bannerets/flow-vect#readme
- Issues: https://github.com/Bannerets/flow-vect/issues
- npm.io page: https://npm.io/package/flow-vect

## Dependencies (1)

- [immutable](https://npm.io/package/immutable.md) ^4.0.0-rc.9

## Recent versions

- 0.9.0 (latest) — 2018-08-16
- 0.8.0 — 2018-08-13
- 0.7.1 — 2018-08-13
- 0.7.0 — 2018-08-12
- 0.6.0 — 2018-07-29
- 0.5.0 — 2018-07-29
- 0.4.0 — 2018-07-29
- 0.3.0 — 2018-07-28
- 0.2.1 — 2018-07-16
- 0.2.0 — 2018-07-16
- 0.1.0 — 2018-07-16

## README

# flow-vect

Statically typed `Vect`

[![npm](https://img.shields.io/npm/v/flow-vect.svg)](https://www.npmjs.com/package/flow-vect)

## Installation

```console
$ npm i flow-vect
```

## Usage

```js
// @flow

import {
  createVect,
  push,
  unshift,
  shift,
  head,
  append,
  index,
  indexOf,

  type Vect,
  type GetLength,
  type IsEmpty,
  type IsNotEmpty
} from 'flow-vect'


const vect = createVect() // Vect<0, string>   (type inferred from usage)
// or
//   createVect<string>()
//   createVect('str')

const vect1 = push('foo', vect) // Vect<1, string>
const vect2 = push('bar', vect1) // Vect<2, string>


type Length = GetLength<typeof vect2>
;(2: Length)
// $ExpectError
;(3: Length) // error


;(true: IsNotEmpty<typeof vect2>)
// $ExpectError
;(true: IsEmpty<typeof vect2>) // error

;(true: IsEmpty<typeof vect>)
;(false: IsEmpty<typeof vect1>)


console.log(vect2) //=> Vect

const vect22: Vect<2, string> = vect2


const [ value, vect11 ] = shift(vect22)
console.log(value) //=> 'foo'
;(1: GetLength<typeof vect11>)
;(vect11: Vect<1, string>)


const vect3 = unshift('abc', vect22)
;(vect3: Vect<3, string>)


const el = head(vect3)
;(el: string)
console.log(el) //=> 'abc'


const vect50 = append(vect22, (vect3: Vect<3, string>))
;(vect50: Vect<5, string>)


const el0 = index(1, vect22)
;(el0: string)
console.log('index', el0) //=> 'bar'


;(indexOf('bar', vect22): number | void)


function sum2 (vect: Vect<2, number>): number {
  const [x, xs] = shift(vect)
  const [y] = shift(xs)
  return x + y
}
```

See also [index.test.js](tests/typings/index.test.js).

#### Functions:

- `createVect`
- `push`
- `pop`
- `unshift`
- `shift`
- `head`
- `last`
- `append`
- `index`
- `indexOf`
- `equals`
- `isVect`

#### Types:

- `Vect<N, T>`
- `GetLength<V>`
- `IsEmpty<V>`
- `IsNotEmpty<V>`
- `IsVect<V>`

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