object-array-utils
Advanced tools
+1
-1
| { | ||
| "name": "object-array-utils", | ||
| "version": "2.7.0", | ||
| "version": "2.8.0", | ||
| "description": "Utilities for working with arrays and objects", | ||
@@ -5,0 +5,0 @@ "scripts": { |
+5
-0
@@ -83,2 +83,7 @@ # `object-array-utils` | ||
| import { removeArrayElements } from 'object-array-utils'; | ||
| removeArrayElements([1, 1, 2, 3], [1, 2]) // [1, 3] | ||
| removeArrayElements([1, 1, 2, 3], [1, 2, 1]) // [3] | ||
| import { isObjectSubset } from 'object-array-utils'; | ||
@@ -85,0 +90,0 @@ |
+13
-0
@@ -253,2 +253,14 @@ function isNullOrUndefined(v) { | ||
| function removeArrayElements(array, listOfValues) { | ||
| if (!isArray(array) || !isArray(listOfValues)) { | ||
| throw new Error('expected array'); | ||
| } | ||
| listOfValues.forEach((value) => { | ||
| array = removeArrayElement(array, value); | ||
| }); | ||
| return array; | ||
| } | ||
| function removeArrayElement(array, valueOrFun) { | ||
@@ -445,3 +457,4 @@ if (!isArray(array)) { | ||
| removeArrayElementByIndex, | ||
| removeArrayElements, | ||
| takeProperties | ||
| } |
+11
-0
@@ -17,2 +17,3 @@ import { | ||
| removeArrayElementByIndex, | ||
| removeArrayElements, | ||
| takeProperties | ||
@@ -196,1 +197,11 @@ } from './index'; | ||
| }); | ||
| test('removeArrayElements', () => { | ||
| expect(removeArrayElements([1, 2, 3, 1], [1, 2])).toEqual([3, 1]); | ||
| expect(removeArrayElements([1, 2, 3, 1], [2, 1, 1])).toEqual([3]); | ||
| expect(removeArrayElements([1, 2, 3, 1], [2, 2, 1, 1, 1])).toEqual([3]); | ||
| expect(removeArrayElements([1], [])).toEqual([1]); | ||
| expect(removeArrayElements([], [1])).toEqual([]); | ||
| expect(removeArrayElements([], [])).toEqual([]); | ||
| expect(removeArrayElements([1, 2, 3], [5, 6])).toEqual([1, 2, 3]); | ||
| }); |
36770
2.72%530
3.92%166
3.11%