array-max-length
Advanced tools
Comparing version
'use strict'; | ||
module.exports = function (input, length) { | ||
module.exports = (input, length) => { | ||
if (!Array.isArray(input)) { | ||
throw new TypeError('Expected an array'); | ||
throw new TypeError(`Expected an \`Array\`, got \`${typeof input}\``); | ||
} | ||
var ret = input.slice(); | ||
const ret = input.slice(); | ||
@@ -9,0 +9,0 @@ if (ret.length > length) { |
{ | ||
"name": "array-max-length", | ||
"version": "1.0.1", | ||
"description": "Returns a new array with the given maximum length", | ||
"license": "MIT", | ||
"repository": "gillstrom/array-max-length", | ||
"author": { | ||
"name": "Andreas Gillström", | ||
"email": "andreasgillstrom@gmail.com", | ||
"url": "github.com/gillstrom" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"arr", | ||
"array", | ||
"length", | ||
"list", | ||
"max", | ||
"maximum", | ||
"resize", | ||
"shrink", | ||
"size", | ||
"values" | ||
], | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
"name": "array-max-length", | ||
"version": "2.0.0", | ||
"description": "Returns a new array with the given maximum length", | ||
"license": "MIT", | ||
"repository": "gillstrom/array-max-length", | ||
"author": { | ||
"name": "Andreas Gillström", | ||
"email": "andreasgillstrom@gmail.com", | ||
"url": "github.com/gillstrom" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"arr", | ||
"array", | ||
"length", | ||
"list", | ||
"max", | ||
"maximum", | ||
"resize", | ||
"shrink", | ||
"size", | ||
"values" | ||
], | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
} |
# array-max-length [](https://travis-ci.org/gillstrom/array-max-length) | ||
> Returns a new array with the given maximum length | ||
> Returns a new `Array` with the given maximum length | ||
@@ -9,3 +9,3 @@ | ||
``` | ||
$ npm install --save array-max-length | ||
$ npm install array-max-length | ||
``` | ||
@@ -17,5 +17,6 @@ | ||
```js | ||
var arrayMaxLength = require('array-max-length'); | ||
var arr = [1, 2, 3, 4, 5]; | ||
const arrayMaxLength = require('array-max-length'); | ||
const arr = [1, 2, 3, 4, 5]; | ||
arrayMaxLength(arr, 2); | ||
@@ -33,8 +34,10 @@ // => [1, 2] | ||
Returns the new array. | ||
Returns a new `Array` with the given length. | ||
#### input | ||
Type: `array` | ||
Type: `Array` | ||
Input to return the new `Array` from. | ||
#### length | ||
@@ -44,3 +47,3 @@ | ||
The maximum length of the array. | ||
The maximum length of the `Array`. | ||
@@ -47,0 +50,0 @@ |
Sorry, the diff of this file is not supported yet
2717
0.74%50
6.38%