# @emilbayes/capped-array

> > CappedArray inherited from Array

Latest version **1.0.0** (published 2020-02-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install @emilbayes/capped-array
pnpm add @emilbayes/capped-array
yarn add @emilbayes/capped-array
bun add @emilbayes/capped-array
```

## 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 | 1.0.0 |
| Published | 2020-02-13 |
| First published | 2020-02-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | separate (@types/emilbayes__capped-array) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Emil Bay |
| Maintainers | emilbayes |

## Links

- npm: https://www.npmjs.com/package/@emilbayes/capped-array
- Repository: https://github.com/emilbayes/capped-array
- Homepage: https://github.com/emilbayes/capped-array#readme
- Issues: https://github.com/emilbayes/capped-array/issues
- npm.io page: https://npm.io/package/@emilbayes/capped-array

## Recent versions

- 1.0.0 (latest) — 2020-02-13

## README

# `@emilbayes/capped-array`

> CappedArray inherited from Array

## Usage

```js
var CappedArray = require('@emilbayes/capped-array')

var arr = new CappedArray(2) // max 100 elements

arr.push('foo')
arr.deleted // === 0
arr.length // === 1
arr.size // === 2

arr.push('bar')
arr.deleted // === 0
arr.length // === 2
arr.size // === 2

arr.push('baz')
arr.deleted // === 1
arr.length // === 2
arr.size // === 2
// arr is now ['bar', 'baz']
```

## API

### `const arr = new CappedArray(size)`

Create a new `CappedArray` with a maximum size of `size`

### `arr.deleted`

This property is updated on each mutation (`push`, `unshift`) that might have
delete elements

### `arr.size`

The maximum size of the capped array

### Inherited

Otherwise this module just inherits all methods and properties from `Array`.
Eg. `.length` will give you the current number of elements in the array, maxed
at the size

## Install

```sh
npm install @emilbayes/capped-array
```

## License

[ISC](LICENSE)

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