🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

object-array-utils

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-array-utils - npm Package Compare versions

Comparing version
2.7.0
to
2.8.0
+1
-1
package.json
{
"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": {

@@ -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 @@

@@ -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
}

@@ -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]);
});