Skip to content

Commit

Permalink
removeInternalAndSame() tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
adumesny committed Apr 20, 2024
1 parent 1a6fd4b commit bc568a7
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 bc568a7

Please sign in to comment.