You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

array-max-length

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-max-length - npm Package Compare versions

Comparing version

to
2.0.0

6

index.js
'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 [![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
> 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.