array-differ
Advanced tools
+15
| /** | ||
| * Create an array with values that are present in the first array but not additional ones. | ||
| * | ||
| * @param array - The array to compare against. | ||
| * @param values - The arrays with values to be excluded. | ||
| * @returns A new array of filtered values. | ||
| * | ||
| * @example | ||
| * | ||
| * import arrayDiffer from 'array-differ'; | ||
| * | ||
| * arrayDiffer([2, 3, 4], [3, 50]); | ||
| * //=> [2, 4] | ||
| */ | ||
| export default function arrayDiffer<T>(array: ArrayLike<T>, ...values: ArrayLike<T>[]): T[]; |
+6
-2
| 'use strict'; | ||
| module.exports = (arr, ...values) => { | ||
| const arrayDiffer = (array, ...values) => { | ||
| const rest = new Set([].concat(...values)); | ||
| return arr.filter(x => !rest.has(x)); | ||
| return array.filter(x => !rest.has(x)); | ||
| }; | ||
| module.exports = arrayDiffer; | ||
| module.exports.default = arrayDiffer; |
+33
-34
| { | ||
| "name": "array-differ", | ||
| "version": "2.0.3", | ||
| "description": "Create an array with values that are present in the first input array but not additional ones", | ||
| "license": "MIT", | ||
| "repository": "sindresorhus/array-differ", | ||
| "author": { | ||
| "name": "Sindre Sorhus", | ||
| "email": "sindresorhus@gmail.com", | ||
| "url": "sindresorhus.com" | ||
| }, | ||
| "engines": { | ||
| "node": ">=6" | ||
| }, | ||
| "scripts": { | ||
| "test": "xo && ava" | ||
| }, | ||
| "files": [ | ||
| "index.js" | ||
| ], | ||
| "keywords": [ | ||
| "array", | ||
| "difference", | ||
| "diff", | ||
| "differ", | ||
| "filter", | ||
| "exclude" | ||
| ], | ||
| "devDependencies": { | ||
| "ava": "*", | ||
| "xo": "*" | ||
| }, | ||
| "xo": { | ||
| "esnext": true | ||
| } | ||
| "name": "array-differ", | ||
| "version": "2.1.0", | ||
| "description": "Create an array with values that are present in the first input array but not additional ones", | ||
| "license": "MIT", | ||
| "repository": "sindresorhus/array-differ", | ||
| "author": { | ||
| "name": "Sindre Sorhus", | ||
| "email": "sindresorhus@gmail.com", | ||
| "url": "sindresorhus.com" | ||
| }, | ||
| "engines": { | ||
| "node": ">=6" | ||
| }, | ||
| "scripts": { | ||
| "test": "xo && ava && tsd-check" | ||
| }, | ||
| "files": [ | ||
| "index.js", | ||
| "index.d.ts" | ||
| ], | ||
| "keywords": [ | ||
| "array", | ||
| "difference", | ||
| "diff", | ||
| "differ", | ||
| "filter", | ||
| "exclude" | ||
| ], | ||
| "devDependencies": { | ||
| "ava": "^1.2.1", | ||
| "tsd-check": "^0.3.0", | ||
| "xo": "^0.24.0" | ||
| } | ||
| } |
+4
-4
@@ -9,3 +9,3 @@ # array-differ [](https://travis-ci.org/sindresorhus/array-differ) | ||
| ``` | ||
| $ npm install --save array-differ | ||
| $ npm install array-differ | ||
| ``` | ||
@@ -25,3 +25,3 @@ | ||
| ### arrayDiffer(input, values, [values, ...]) | ||
| ### arrayDiffer(input, ...values) | ||
@@ -32,7 +32,7 @@ Returns a new array. | ||
| Type: `array` | ||
| Type: `unknown[]` | ||
| #### values | ||
| Type: `array` | ||
| Type: `unknown[]` | ||
@@ -39,0 +39,0 @@ Arrays of values to exclude. |
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
3072
20.05%5
25%22
340%0
-100%3
50%