UNPKG

bbo

Version:

bbo is a utility library of zero dependencies for javascript.

30 lines (26 loc) 755 B
import isObject from './is_object.js'; import './get_tag.js'; import './is_array.js'; import './is_string.js'; import './is_map.js'; import './is_set.js'; import isEmpty from './is_empty.js'; import properObject from './proper_object.js'; var deletedDiff = (lhs, rhs) => { if (lhs === rhs || !isObject(lhs) || !isObject(rhs)) return {}; var l = properObject(lhs); var r = properObject(rhs); return Object.keys(l).reduce((acc, key) => { if (r.hasOwnProperty(key)) { var difference = deletedDiff(l[key], r[key]); if (isObject(difference) && isEmpty(difference)) return acc; return { ...acc, [key]: difference }; } return { ...acc, [key]: undefined }; }, {}); }; export default deletedDiff;