# array-max-length

> Returns a new array with the given maximum length

Latest version **2.0.0** (published 2017-10-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install array-max-length
pnpm add array-max-length
yarn add array-max-length
bun add array-max-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 | 2.0.0 |
| Published | 2017-10-30 |
| First published | 2015-09-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Andreas Gillström |
| Maintainers | gillstrom |
| Keywords | arr, array, length, list, max, maximum, resize, shrink, size, values |

## Links

- npm: https://www.npmjs.com/package/array-max-length
- Repository: https://github.com/gillstrom/array-max-length
- Homepage: https://github.com/gillstrom/array-max-length#readme
- Issues: https://github.com/gillstrom/array-max-length/issues
- npm.io page: https://npm.io/package/array-max-length

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2017-10-30
- 1.0.1 — 2015-09-05
- 1.0.0 — 2015-09-05

## README

# array-max-length [![Build Status](https://travis-ci.org/gillstrom/array-max-length.svg?branch=master)](https://travis-ci.org/gillstrom/array-max-length)

> Returns a new `Array` with the given maximum length


## Install

```
$ npm install array-max-length
```


## Usage

```js
const arrayMaxLength = require('array-max-length');

const arr = [1, 2, 3, 4, 5];

arrayMaxLength(arr, 2);
// => [1, 2]

arrayMaxLength(arr, 10);
// => [1, 2, 3, 4, 5]
```


## API

### arrayMaxLength(input, length)

Returns a new `Array` with the given length.

#### input

Type: `Array`

Input to return the new `Array` from.

#### length

Type: `number`

The maximum length of the `Array`.


## License

MIT © [Andreas Gillström](http://github.com/gillstrom)

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