arr-exclude
Advanced tools
Comparing version 1.0.0 to 2.0.0
13
index.js
@@ -1,10 +0,7 @@ | ||
'use strict'; | ||
module.exports = function (input, exclude) { | ||
if (!Array.isArray(input)) { | ||
return []; | ||
export default function arrayExclude(array, exclusions) { | ||
if (!Array.isArray(array)) { | ||
throw new TypeError(`Expected an array, got \`${typeof array}\``); | ||
} | ||
return input.filter(function (x) { | ||
return exclude.indexOf(x) === -1; | ||
}); | ||
}; | ||
return array.filter(item => !exclusions.includes(item)); | ||
} |
{ | ||
"name": "arr-exclude", | ||
"version": "1.0.0", | ||
"description": "Exclude certain items from an array", | ||
"license": "MIT", | ||
"repository": "sindresorhus/arr-exclude", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"array", | ||
"arr", | ||
"list", | ||
"exclude", | ||
"blacklist", | ||
"ignore", | ||
"without", | ||
"items", | ||
"elements", | ||
"values", | ||
"filter" | ||
], | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
"name": "arr-exclude", | ||
"version": "2.0.0", | ||
"description": "Exclude certain items from an array", | ||
"license": "MIT", | ||
"repository": "sindresorhus/arr-exclude", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"array", | ||
"list", | ||
"exclude", | ||
"ignore", | ||
"without", | ||
"items", | ||
"elements", | ||
"values", | ||
"filter" | ||
], | ||
"devDependencies": { | ||
"ava": "^3.15.0", | ||
"xo": "^0.44.0" | ||
} | ||
} |
@@ -1,30 +0,22 @@ | ||
# arr-exclude [![Build Status](https://travis-ci.org/sindresorhus/arr-exclude.svg?branch=master)](https://travis-ci.org/sindresorhus/arr-exclude) | ||
# arr-exclude | ||
> Exclude certain items from an array | ||
## Install | ||
``` | ||
$ npm install --save arr-exclude | ||
$ npm install arr-exclude | ||
``` | ||
## Usage | ||
```js | ||
var arrExclude = require('arr-exclude'); | ||
import arrayExclude from 'arr-exclude'; | ||
arrExclude(['a', 'b', 'c'], ['b']); | ||
arrayExclude(['a', 'b', 'c'], ['b']); | ||
//=> ['a', 'c'] | ||
``` | ||
## Related | ||
- [arr-include](https://github.com/sindresorhus/arr-include) - Include only certain items in an array | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) |
Sorry, the diff of this file is not supported yet
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Yes
2374
6
23