# is-array-of-length

> Returns true if a value is an array containing the specified number of elements.

Latest version **1.1.0** (published 2019-09-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install is-array-of-length
pnpm add is-array-of-length
yarn add is-array-of-length
bun add is-array-of-length
```

## 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.1.0 |
| Published | 2019-09-01 |
| First published | 2018-02-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 3 |
| Unpacked size | 3.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Fr. John Lamansky |
| Maintainers | lamansky |
| Keywords | test, array, elements, length, bind operator |

## Links

- npm: https://www.npmjs.com/package/is-array-of-length
- Repository: https://github.com/lamansky/is-array-of-length
- Issues: https://github.com/lamansky/is-array-of-length/issues
- npm.io page: https://npm.io/package/is-array-of-length

## Dependencies (3)

- [sbo](https://npm.io/package/sbo.md) ^1.1.0
- [arrify](https://npm.io/package/arrify.md) ^1.0.1
- [is-instance-of](https://npm.io/package/is-instance-of.md) ^1.0.2

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2019-09-01
- 1.0.0 — 2018-02-03

## README

# is-array-of-length

Returns true if a value is an array containing the specified number of elements.

## Installation

Requires [Node.js](https://nodejs.org/) 6.0.0 or above.

```bash
npm i is-array-of-length
```

## API

The module exports a single function.

### Parameters

1. `arr` (any): What may or may not be an array
2. `lengths` (integer or array): One or more integers, each of which represents an acceptable number of items in the array.
3. Optional: Object argument:
    * `arrays` (class, string, or array): One or more classes or names of classes that should be treated as equivalent to `Array`.

### Return Values

* `true` if `arr` is an array with a length given in `lengths`
* `false` otherwise

## Example

```javascript
const isArrayOfLength = require('is-array-of-length')

isArrayOfLength(['a', 'b'], 2) // true
isArrayOfLength(['a', 'b'], 3) // false
isArrayOfLength(['a', 'b'], [2, 3]) // true
isArrayOfLength('7 chars', 7) // false

// Supports the bind operator
['a', 'b']::isArrayOfLength(2) // true
```

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