object-array-utils
Advanced tools
+1
-1
| { | ||
| "name": "object-array-utils", | ||
| "version": "2.5.0", | ||
| "version": "2.6.0", | ||
| "description": "Utilities for working with arrays and objects", | ||
@@ -5,0 +5,0 @@ "scripts": { |
+5
-0
@@ -129,2 +129,7 @@ # `object-array-utils` | ||
| isArrayWhereEvery([], isObjectLiteral) // false | ||
| import { isObjectLiteralWhereEvery, isArray } from 'object-array-utils'; | ||
| isObjectLiteralWhereEvery({ foo: [1], bar: [2, 3] }, isArray) // true | ||
| isObjectLiteralWhereEvery({}, isArray) // false | ||
| ``` | ||
@@ -131,0 +136,0 @@ |
+9
-0
@@ -72,2 +72,10 @@ function isNullOrUndefined(v) { | ||
| function isObjectLiteralWhereEvery(o, fun) { | ||
| if (!isObjectLiteral(o) || isEmptyObjectLiteral(o)) { | ||
| return false; | ||
| } | ||
| return isArrayWhereEvery(Object.values(o), fun); | ||
| } | ||
| function areObjectsEqual(a, b, options = {}) { | ||
@@ -375,2 +383,3 @@ if (!isObject(a) || !isObject(b)) { | ||
| isObjectLiteral, | ||
| isObjectLiteralWhereEvery, | ||
| isObjectSubset, | ||
@@ -377,0 +386,0 @@ isPrimitive, |
@@ -13,2 +13,3 @@ import { | ||
| isObjectLiteral, | ||
| isObjectLiteralWhereEvery, | ||
| isPrimitive, | ||
@@ -161,2 +162,9 @@ takeProperties | ||
| test('isObjectLiteralWhereEvery', () => { | ||
| expect(isObjectLiteralWhereEvery([[], []], isEmptyArray)).toBeFalsy(); | ||
| expect(isObjectLiteralWhereEvery({ foo: [], bar: [] }, isEmptyArray)).toBeTruthy(); | ||
| expect(isObjectLiteralWhereEvery({}, isEmptyObjectLiteral)).toBeFalsy(); | ||
| expect(isObjectLiteralWhereEvery({ foo: { a: 1 }, bar: { b: 2 } }, isObjectLiteral)).toBeTruthy(); | ||
| }); | ||
| test('isEmptyObjectLiteral', () => { | ||
@@ -163,0 +171,0 @@ expect(isEmptyObjectLiteral({})).toBeTruthy(); |
32753
2.61%446
3.24%152
3.4%