|
|
@ -15,14 +15,14 @@ |
|
|
|
* @param breakAtFirstMismatch : default true. returns false on first field mismatch |
|
|
|
* @param breakAtFirstMismatch : default true. returns false on first field mismatch |
|
|
|
* @returns |
|
|
|
* @returns |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
export function deepCompare( |
|
|
|
export async function deepCompare( |
|
|
|
obj1: any, |
|
|
|
obj1: any, |
|
|
|
obj2: any, |
|
|
|
obj2: any, |
|
|
|
ignoredFields?: Set<string>, |
|
|
|
ignoredFields?: Set<string>, |
|
|
|
ignoredKeys?: Set<string>, |
|
|
|
ignoredKeys?: Set<string>, |
|
|
|
keyId = '', |
|
|
|
keyId = '', |
|
|
|
breakAtFirstMismatch = true |
|
|
|
breakAtFirstMismatch = true |
|
|
|
): boolean { |
|
|
|
): Promise<boolean> { |
|
|
|
if (ignoredKeys !== undefined && ignoredKeys.has(keyId)) { |
|
|
|
if (ignoredKeys !== undefined && ignoredKeys.has(keyId)) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -56,7 +56,7 @@ export function deepCompare( |
|
|
|
// console.log(`${keyId} ignored in comparison`)
|
|
|
|
// console.log(`${keyId} ignored in comparison`)
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
keyId = keyId + '.' + key; |
|
|
|
keyId = keyId + '.' + key; |
|
|
|
if (!deepCompare(obj1[key], obj2[key], ignoredFields, ignoredKeys, keyId, breakAtFirstMismatch)) { |
|
|
|
if (!(await deepCompare(obj1[key], obj2[key], ignoredFields, ignoredKeys, keyId, breakAtFirstMismatch))) { |
|
|
|
return !breakAtFirstMismatch; |
|
|
|
return !breakAtFirstMismatch; |
|
|
|
// return false;
|
|
|
|
// return false;
|
|
|
|
} |
|
|
|
} |
|
|
|