t-comm
Version:
专业、稳定、纯粹的工具库
33 lines (30 loc) • 704 B
JavaScript
import { isObjectEqual as _isObjectEqual } from './equal.mjs';
function compareTwoObj(originObj, newObj) {
if (originObj === void 0) {
originObj = {};
}
if (newObj === void 0) {
newObj = {};
}
var res = {
ADDED: [],
UPDATED: [],
DELETED: [],
originObj: originObj,
newObj: newObj
};
Object.keys(originObj).map(function (key) {
if (newObj[key] === undefined) {
res.DELETED.push(key);
} else if (!_isObjectEqual(newObj[key], originObj[key])) {
res.UPDATED.push(key);
}
});
Object.keys(newObj).map(function (key) {
if (originObj[key] === undefined) {
res.ADDED.push(key);
}
});
return res;
}
export { compareTwoObj };