fix(core): update
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../smartobject.plugins';
|
||||
import * as plugins from '../smartobject.plugins.js';
|
||||
|
||||
export interface IObjectCompareResult {
|
||||
presentInBothProperties: string[];
|
||||
@@ -27,41 +27,44 @@ export const compareObjects = (
|
||||
const allProperties = Object.keys(referenceObjectArg).concat(Object.keys(comparisonObjectArg));
|
||||
for (const currentProperty of allProperties) {
|
||||
// lets find presentInBothProperties
|
||||
if (referenceObjectArg[ currentProperty ] && comparisonObjectArg[ currentProperty ]) {
|
||||
if (referenceObjectArg[currentProperty] && comparisonObjectArg[currentProperty]) {
|
||||
returnComparisonObject.presentInBothProperties.push(currentProperty);
|
||||
}
|
||||
|
||||
// lets find missingProperties
|
||||
if (referenceObjectArg[ currentProperty ] && !comparisonObjectArg[ currentProperty ]) {
|
||||
if (referenceObjectArg[currentProperty] && !comparisonObjectArg[currentProperty]) {
|
||||
returnComparisonObject.missingProperties.push(currentProperty);
|
||||
}
|
||||
|
||||
// lets find additionalProperties
|
||||
if (!referenceObjectArg[ currentProperty ] && comparisonObjectArg[ currentProperty ]) {
|
||||
if (!referenceObjectArg[currentProperty] && comparisonObjectArg[currentProperty]) {
|
||||
returnComparisonObject.additionalProperties.push(currentProperty);
|
||||
}
|
||||
|
||||
// lets find nulledProperties
|
||||
if (comparisonObjectArg[ currentProperty ] === null) {
|
||||
if (comparisonObjectArg[currentProperty] === null) {
|
||||
returnComparisonObject.nulledProperties.push(currentProperty);
|
||||
}
|
||||
|
||||
// lets find undefinedProperties
|
||||
if (comparisonObjectArg[ currentProperty ] === undefined) {
|
||||
if (comparisonObjectArg[currentProperty] === undefined) {
|
||||
returnComparisonObject.undefinedProperties.push(currentProperty);
|
||||
}
|
||||
|
||||
// lets find divergingProperties
|
||||
if (
|
||||
JSON.stringify(referenceObjectArg[ currentProperty ]) !==
|
||||
JSON.stringify(comparisonObjectArg[ currentProperty ])
|
||||
JSON.stringify(referenceObjectArg[currentProperty]) !==
|
||||
JSON.stringify(comparisonObjectArg[currentProperty])
|
||||
) {
|
||||
returnComparisonObject.divergingProperties.push(currentProperty);
|
||||
}
|
||||
|
||||
// lets find equalProperties
|
||||
if (
|
||||
plugins.fastDeepEqual(referenceObjectArg[ currentProperty ], comparisonObjectArg[ currentProperty ])
|
||||
plugins.fastDeepEqual(
|
||||
referenceObjectArg[currentProperty],
|
||||
comparisonObjectArg[currentProperty]
|
||||
)
|
||||
) {
|
||||
returnComparisonObject.equalProperties.push(currentProperty);
|
||||
}
|
||||
@@ -71,9 +74,12 @@ export const compareObjects = (
|
||||
const onlyUnique = (value: any, index: number, self: Array<any>) => {
|
||||
return self.indexOf(value) === index;
|
||||
};
|
||||
const uniqueArray = returnComparisonObject[ currentProperty as keyof (typeof returnComparisonObject) ].filter(onlyUnique);
|
||||
returnComparisonObject[ currentProperty as keyof (typeof returnComparisonObject) ] = uniqueArray;
|
||||
const uniqueArray =
|
||||
returnComparisonObject[currentProperty as keyof typeof returnComparisonObject].filter(
|
||||
onlyUnique
|
||||
);
|
||||
returnComparisonObject[currentProperty as keyof typeof returnComparisonObject] = uniqueArray;
|
||||
}
|
||||
|
||||
return returnComparisonObject;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user