Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bc568a7

Browse files
committed
removeInternalAndSame() tweak
1 parent 1a6fd4b commit bc568a7

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/utils.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,13 @@ export class Utils {
305305
static removeInternalAndSame(a: unknown, b: unknown):void {
306306
if (typeof a !== 'object' || typeof b !== 'object') return;
307307
for (let key in a) {
308-
let val = a[key];
309-
if (key[0] === '_' || val === b[key]) {
308+
const aVal = a[key];
309+
const bVal = b[key];
310+
if (key[0] === '_' || aVal === bVal) {
310311
delete a[key]
311-
} else if (val && typeof val === 'object' && b[key] !== undefined) {
312-
for (let i in val) {
313-
if (val[i] === b[key][i] || i[0] === '_') { delete val[i] }
314-
}
315-
if (!Object.keys(val).length) { delete a[key] }
312+
} else if (aVal && typeof aVal === 'object' && bVal !== undefined) {
313+
Utils.removeInternalAndSame(aVal, bVal);
314+
if (!Object.keys(aVal).length) { delete a[key] }
316315
}
317316
}
318317
}

0 commit comments

Comments
 (0)