fix(core): update
This commit is contained in:
21
ts/index.ts
21
ts/index.ts
@ -1,9 +1,7 @@
|
||||
import * as plugins from './smartobject.plugins';
|
||||
|
||||
const fastDeepEqual = plugins.fastDeepEqual;
|
||||
export {
|
||||
fastDeepEqual
|
||||
};
|
||||
export { fastDeepEqual };
|
||||
|
||||
export interface IObjectCompareResult {
|
||||
presentInBothProperties: string[];
|
||||
@ -15,7 +13,10 @@ export interface IObjectCompareResult {
|
||||
equalProperties: string[];
|
||||
}
|
||||
|
||||
export const compareObjects = (referenceObjectArg: any, comparisonObjectArg: any): IObjectCompareResult => {
|
||||
export const compareObjects = (
|
||||
referenceObjectArg: any,
|
||||
comparisonObjectArg: any
|
||||
): IObjectCompareResult => {
|
||||
const returnComparisonObject = {
|
||||
missingProperties: [],
|
||||
additionalProperties: [],
|
||||
@ -25,7 +26,7 @@ export const compareObjects = (referenceObjectArg: any, comparisonObjectArg: any
|
||||
divergingProperties: [],
|
||||
equalProperties: [],
|
||||
};
|
||||
|
||||
|
||||
const allProperties = Object.keys(referenceObjectArg).concat(Object.keys(comparisonObjectArg));
|
||||
for (const currentProperty of allProperties) {
|
||||
// lets find presentInBothProperties
|
||||
@ -54,12 +55,18 @@ export const compareObjects = (referenceObjectArg: any, comparisonObjectArg: any
|
||||
}
|
||||
|
||||
// lets find divergingProperties
|
||||
if (JSON.stringify(referenceObjectArg[currentProperty]) !== JSON.stringify(comparisonObjectArg[currentProperty])) {
|
||||
if (
|
||||
JSON.stringify(referenceObjectArg[currentProperty]) !==
|
||||
JSON.stringify(comparisonObjectArg[currentProperty])
|
||||
) {
|
||||
returnComparisonObject.divergingProperties.push(currentProperty);
|
||||
}
|
||||
|
||||
// lets find equalProperties
|
||||
if (JSON.stringify(referenceObjectArg[currentProperty]) === JSON.stringify(comparisonObjectArg[currentProperty])) {
|
||||
if (
|
||||
JSON.stringify(referenceObjectArg[currentProperty]) ===
|
||||
JSON.stringify(comparisonObjectArg[currentProperty])
|
||||
) {
|
||||
returnComparisonObject.equalProperties.push(currentProperty);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
// tslint:disable-next-line: no-submodule-imports
|
||||
import fastDeepEqual from 'fast-deep-equal/es6';
|
||||
|
||||
export {
|
||||
fastDeepEqual
|
||||
};
|
||||
export { fastDeepEqual };
|
||||
|
Reference in New Issue
Block a user