Skip to content

gillstrom/array-max-length

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

array-max-length Build Status

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

About

Returns a new array with the given maximum length

Resources

License

Stars

Watchers

Forks

Packages

No packages published