Skip to content

Commit

Permalink
Merge pull request #2662 from adumesny/master
Browse files Browse the repository at this point in the history
removeInternalAndSame() tweak
  • Loading branch information
adumesny committed Apr 20, 2024
2 parents e144046 + bc568a7 commit 44b5a72
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,13 @@ export class Utils {
static removeInternalAndSame(a: unknown, b: unknown):void {
if (typeof a !== 'object' || typeof b !== 'object') return;
for (let key in a) {
let val = a[key];
if (key[0] === '_' || val === b[key]) {
const aVal = a[key];
const bVal = b[key];
if (key[0] === '_' || aVal === bVal) {
delete a[key]
} else if (val && typeof val === 'object' && b[key] !== undefined) {
for (let i in val) {
if (val[i] === b[key][i] || i[0] === '_') { delete val[i] }
}
if (!Object.keys(val).length) { delete a[key] }
} else if (aVal && typeof aVal === 'object' && bVal !== undefined) {
Utils.removeInternalAndSame(aVal, bVal);
if (!Object.keys(aVal).length) { delete a[key] }
}
}
}
Expand Down

0 comments on commit 44b5a72

Please sign in to comment.