Comparing version 2.0.0 to 2.1.0
{ | ||
"name": "js-utl", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "A collection of JS utility functions to be used across several applications or libraries.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -834,2 +834,22 @@ /* | ||
/** | ||
* Tests if a partial object is a subset of another object. | ||
* | ||
* @param {Object} obj An object. | ||
* @param {Object} partialObj A partial object which may not have all the keys of "obj" | ||
* or may even have different keys, or keys with different values. | ||
* @return {boolean} False if "partialObj" has a key which is not in "obj", | ||
* or has at least one key which is also in "obj" but with a different value | ||
* (shallow comparison), true otherwise. | ||
*/ | ||
export function partialShallowEqual(obj, partialObj) { | ||
return shallowEqual( | ||
Object.keys(partialObj).reduce((carry, key) => { | ||
carry[key] = obj[key]; | ||
return carry; | ||
}, {}), | ||
partialObj | ||
); | ||
} | ||
/** | ||
* Returns a shallow object diff, returning an object with two keys "objA" and "objB", | ||
@@ -836,0 +856,0 @@ * each containing an object with all the properties of one of the two objects which are not within |
@@ -73,2 +73,3 @@ /* | ||
shallowEqual, | ||
partialShallowEqual, | ||
shallowObjectDiff, | ||
@@ -75,0 +76,0 @@ nestedMapHas, |
127538
3605