UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

37 lines (32 loc) 787 B
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var object_equal = require('./equal.js'); 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 (!object_equal.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; } exports.compareTwoObj = compareTwoObj;