@domql/utils
Advanced tools
Comparing version 2.5.114 to 2.5.116
@@ -470,29 +470,28 @@ "use strict"; | ||
}; | ||
const deepContains = (obj1, obj2) => { | ||
const stack = [{ obj1, obj2 }]; | ||
while (stack.length) { | ||
const { obj1: obj12, obj2: obj22 } = stack.pop(); | ||
if (typeof obj12 !== typeof obj22) { | ||
const deepContains = (obj1, obj2, ignoredKeys = ["node", "__ref"]) => { | ||
if (obj1 === obj2) | ||
return true; | ||
if (!(0, import_types.isObjectLike)(obj1) || !(0, import_types.isObjectLike)(obj2)) | ||
return false; | ||
const stack = [[obj1, obj2]]; | ||
const visited = /* @__PURE__ */ new WeakSet(); | ||
while (stack.length > 0) { | ||
const [current1, current2] = stack.pop(); | ||
if (visited.has(current1)) | ||
continue; | ||
visited.add(current1); | ||
const keys1 = Object.keys(current1).filter((key) => !ignoredKeys.includes(key)); | ||
const keys2 = Object.keys(current2).filter((key) => !ignoredKeys.includes(key)); | ||
if (keys1.length !== keys2.length) | ||
return false; | ||
} | ||
if ((0, import_types.isObjectLike)(obj12)) { | ||
if (Array.isArray(obj12) && Array.isArray(obj22)) { | ||
if (obj12.length !== obj22.length) { | ||
return false; | ||
for (const key of keys1) { | ||
if (!Object.prototype.hasOwnProperty.call(current2, key)) | ||
return false; | ||
const value1 = current1[key]; | ||
const value2 = current2[key]; | ||
if ((0, import_types.isObjectLike)(value1) && (0, import_types.isObjectLike)(value2)) { | ||
if (value1 !== value2) { | ||
stack.push([value1, value2]); | ||
} | ||
for (let i = 0; i < obj12.length; i++) { | ||
stack.push({ obj1: obj12[i], obj2: obj22[i] }); | ||
} | ||
} else if ((0, import_types.isObjectLike)(obj12) && obj22 !== null) { | ||
for (const key in obj12) { | ||
if (Object.prototype.hasOwnProperty.call(obj12, key)) { | ||
if (!Object.prototype.hasOwnProperty.call(obj22, key)) { | ||
return false; | ||
} | ||
stack.push({ obj1: obj12[key], obj2: obj22[key] }); | ||
} | ||
} | ||
} | ||
} else { | ||
if (obj12 !== obj22) { | ||
} else if (value1 !== value2) { | ||
return false; | ||
@@ -499,0 +498,0 @@ } |
@@ -541,32 +541,31 @@ 'use strict' | ||
export const deepContains = (obj1, obj2) => { | ||
const stack = [{ obj1, obj2 }] | ||
export const deepContains = (obj1, obj2, ignoredKeys = ['node', '__ref']) => { | ||
if (obj1 === obj2) return true | ||
if (!isObjectLike(obj1) || !isObjectLike(obj2)) return false | ||
while (stack.length) { | ||
const { obj1, obj2 } = stack.pop() | ||
const stack = [[obj1, obj2]] | ||
const visited = new WeakSet() | ||
if (typeof obj1 !== typeof obj2) { | ||
return false | ||
} | ||
while (stack.length > 0) { | ||
const [current1, current2] = stack.pop() | ||
if (isObjectLike(obj1)) { | ||
if (Array.isArray(obj1) && Array.isArray(obj2)) { | ||
if (obj1.length !== obj2.length) { | ||
return false | ||
if (visited.has(current1)) continue | ||
visited.add(current1) | ||
const keys1 = Object.keys(current1).filter(key => !ignoredKeys.includes(key)) | ||
const keys2 = Object.keys(current2).filter(key => !ignoredKeys.includes(key)) | ||
if (keys1.length !== keys2.length) return false | ||
for (const key of keys1) { | ||
if (!Object.prototype.hasOwnProperty.call(current2, key)) return false | ||
const value1 = current1[key] | ||
const value2 = current2[key] | ||
if (isObjectLike(value1) && isObjectLike(value2)) { | ||
if (value1 !== value2) { | ||
stack.push([value1, value2]) | ||
} | ||
for (let i = 0; i < obj1.length; i++) { | ||
stack.push({ obj1: obj1[i], obj2: obj2[i] }) | ||
} | ||
} else if (isObjectLike(obj1) && obj2 !== null) { | ||
for (const key in obj1) { | ||
if (Object.prototype.hasOwnProperty.call(obj1, key)) { | ||
if (!Object.prototype.hasOwnProperty.call(obj2, key)) { | ||
return false | ||
} | ||
stack.push({ obj1: obj1[key], obj2: obj2[key] }) | ||
} | ||
} | ||
} | ||
} else { | ||
if (obj1 !== obj2) { | ||
} else if (value1 !== value2) { | ||
return false | ||
@@ -578,3 +577,3 @@ } | ||
return true | ||
} | ||
}; | ||
@@ -581,0 +580,0 @@ export const removeFromObject = (obj, props) => { |
{ | ||
"name": "@domql/utils", | ||
"version": "2.5.114", | ||
"version": "2.5.116", | ||
"license": "MIT", | ||
@@ -26,3 +26,3 @@ "type": "module", | ||
}, | ||
"gitHead": "61b7ecee05aaf0d6682e5f3cdb11f0091e880f3d", | ||
"gitHead": "cff7d465161d804f31e3b350081bb751da209eeb", | ||
"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
85591
2601