salix/client/core/src/lib/modified.js

24 lines
573 B
JavaScript
Raw Normal View History

2017-02-07 13:34:26 +00:00
import {module} from '../module';
import isEqual from './equals';
export default function getModifiedData(object, objectOld) {
var newObject = {};
for (var k in object) {
var val = object[k];
var valOld = objectOld[k];
if (!isEqual(val, valOld)) {
if (val instanceof Object) {
2017-02-28 10:46:18 +00:00
newObject[k] = getModifiedData(val, valOld);
2017-09-21 06:48:25 +00:00
} else {
newObject[k] = val;
}
}
}
return newObject;
}
export const NAME = 'getDataModified';
module.value(NAME, getModifiedData);