2017-02-07 13:34:26 +00:00
|
|
|
import {module} from '../module';
|
2017-02-06 17:01:04 +00:00
|
|
|
import isEqual from './equals';
|
2017-01-31 13:13:06 +00:00
|
|
|
|
2017-02-06 17:01:04 +00:00
|
|
|
export default function getModifiedData(object, objectOld) {
|
|
|
|
var newObject = {};
|
|
|
|
for (var k in object) {
|
|
|
|
var val = object[k];
|
2017-10-04 08:54:29 +00:00
|
|
|
var valOld = objectOld[k] === undefined ? null : objectOld[k];
|
2017-01-31 13:13:06 +00:00
|
|
|
|
2017-02-28 11:07:16 +00:00
|
|
|
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 {
|
2017-02-28 11:07:16 +00:00
|
|
|
newObject[k] = val;
|
|
|
|
}
|
2017-01-31 13:13:06 +00:00
|
|
|
}
|
|
|
|
}
|
2017-02-06 17:01:04 +00:00
|
|
|
|
|
|
|
return newObject;
|
2017-01-31 13:13:06 +00:00
|
|
|
}
|
2017-02-06 17:01:04 +00:00
|
|
|
|
|
|
|
export const NAME = 'getDataModified';
|
|
|
|
module.value(NAME, getModifiedData);
|