From bc568a7cf4f91f33396fe0686bd5f478f69f6145 Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Fri, 19 Apr 2024 19:46:39 -0700 Subject: [PATCH] removeInternalAndSame() tweak --- src/utils.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 9f223b2aa..e4bd6787f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -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] } } } }