From c05c119a7502a6679505f3fe9a956202e4ce025d Mon Sep 17 00:00:00 2001 From: Nickman87 Date: Wed, 10 Apr 2019 16:57:32 +0200 Subject: [PATCH] Update shallowObjectDiff --- src/util.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/util.js b/src/util.js index b52283b..dc537f1 100644 --- a/src/util.js +++ b/src/util.js @@ -123,9 +123,7 @@ export function debounce(func, wait, immediate) { }; export function isShallowObjectDifferent(a, b) { - let aValue = ''; - let bValue = ''; - Object.keys(a).sort().filter(v => typeof a[v] !== 'function').forEach(v => aValue += a[v]); - Object.keys(b).sort().filter(v => typeof a[v] !== 'function').forEach(v => bValue += b[v]); + let aValue = Object.keys(a).sort().map(k => typeof a[k] !== 'function' ? a[k] : k).reduce((result, v) => `${result}-${v}`); + let bValue = Object.keys(b).sort().map(k => typeof b[k] !== 'function' ? b[k] : k).reduce((result, v) => `${result}-${v}`); return aValue !== bValue; }