diff options
Diffstat (limited to 'web/src/js/utils.js')
-rw-r--r-- | web/src/js/utils.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/web/src/js/utils.js b/web/src/js/utils.js index eecacfbb..cc17c565 100644 --- a/web/src/js/utils.js +++ b/web/src/js/utils.js @@ -108,6 +108,18 @@ fetchApi.put = (url, json, options) => fetchApi( } ) +export function getDiff(obj1, obj2) { + let result = {...obj2}; + for(let key in obj1) { + if(_.isEqual(obj2[key], obj1[key])) + result[key] = undefined + else if(!(Array.isArray(obj2[key]) && Array.isArray(obj1[key])) && + typeof obj2[key] == 'object' && typeof obj1[key] == 'object') + result[key] = getDiff(obj1[key], obj2[key]) + } + return result +} + export const pure = renderFn => class extends React.Component { static displayName = renderFn.name |