aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/js/utils.js')
-rw-r--r--web/src/js/utils.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/web/src/js/utils.js b/web/src/js/utils.js
index eceda195..ba07b00a 100644
--- a/web/src/js/utils.js
+++ b/web/src/js/utils.js
@@ -105,3 +105,17 @@ fetchApi.put = (url, json, options) => fetchApi(
...options
}
)
+
+
+export function getDiff(obj1, obj2) {
+ let result = {...obj2};
+ _.forIn(obj1, (value, key) => {
+ if(_.isEqual(obj2[key], obj1[key]))
+ result[key] = undefined;
+ else if(typeof Array.isArray(obj2[key]) && Array.isArray(obj2[key]))
+ result[key] = {...obj2[key]};
+ else if(typeof obj2[key] == 'object' && typeof obj1[key] == 'object')
+ result[key] = getDiff(obj1[key], obj2[key]);
+ });
+ return result;
+}