@domql/utils
Advanced tools
Comparing version 2.5.13 to 2.5.14
@@ -24,2 +24,3 @@ "use strict"; | ||
deepCloneExclude: () => deepCloneExclude, | ||
deepContains: () => deepContains, | ||
deepDestringify: () => deepDestringify, | ||
@@ -410,2 +411,29 @@ deepMerge: () => deepMerge, | ||
}; | ||
const deepContains = (obj1, obj2) => { | ||
if (typeof obj1 !== typeof obj2) { | ||
return false; | ||
} | ||
if ((0, import_types.isObjectLike)(obj1)) { | ||
if (Array.isArray(obj1) && Array.isArray(obj2)) { | ||
if (obj1.length !== obj2.length) { | ||
return false; | ||
} | ||
for (let i = 0; i < obj1.length; i++) { | ||
if (!deepContains(obj1[i], obj2[i])) { | ||
return false; | ||
} | ||
} | ||
} else if ((0, import_types.isObjectLike)(obj1) && obj2 !== null) { | ||
for (const key in obj1) { | ||
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj2, key); | ||
if (!hasOwnProperty || !deepContains(obj1[key], obj2[key])) { | ||
return false; | ||
} | ||
} | ||
} | ||
} else { | ||
return obj2 === obj1; | ||
} | ||
return true; | ||
}; | ||
const removeFromObject = (obj, props) => { | ||
@@ -412,0 +440,0 @@ if (props === void 0 || props === null) |
@@ -452,2 +452,32 @@ 'use strict' | ||
export const deepContains = (obj1, obj2) => { | ||
if (typeof obj1 !== typeof obj2) { | ||
return false | ||
} | ||
if (isObjectLike(obj1)) { | ||
if (Array.isArray(obj1) && Array.isArray(obj2)) { | ||
if (obj1.length !== obj2.length) { | ||
return false | ||
} | ||
for (let i = 0; i < obj1.length; i++) { | ||
if (!deepContains(obj1[i], obj2[i])) { | ||
return false | ||
} | ||
} | ||
} else if (isObjectLike(obj1) && obj2 !== null) { | ||
for (const key in obj1) { | ||
const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj2, key) | ||
if (!hasOwnProperty || !deepContains(obj1[key], obj2[key])) { | ||
return false | ||
} | ||
} | ||
} | ||
} else { | ||
return obj2 === obj1 | ||
} | ||
return true | ||
} | ||
export const removeFromObject = (obj, props) => { | ||
@@ -454,0 +484,0 @@ if (props === undefined || props === null) return obj |
{ | ||
"name": "@domql/utils", | ||
"version": "2.5.13", | ||
"version": "2.5.14", | ||
"license": "MIT", | ||
@@ -26,3 +26,3 @@ "type": "module", | ||
}, | ||
"gitHead": "3bbff7f4e2ced6f104572489a2779a5cf0dbb450", | ||
"gitHead": "ab852cb3a435b154f6b32a9a664f65ec56a9c49f", | ||
"devDependencies": { | ||
@@ -29,0 +29,0 @@ "@babel/core": "^7.12.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61852
1971