array-max-length
v2.0.0
Published
Returns a new array with the given maximum length
Downloads
3
Maintainers
Readme
array-max-length
Returns a new
Array
with the given maximum length
Install
$ npm install array-max-length
Usage
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