Last active
May 27, 2020 19:45
-
-
Save leonidkuznetsov18/5797a20ca2f9e8ecbac11f3f896e6851 to your computer and use it in GitHub Desktop.
Deep diff between two object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function difference(object, base) { | |
return _.transform(object, (result, value, key) => { | |
if (!_.isEqual(value, base[key])) { | |
result[key] = _.isObject(value) && _.isObject(base[key]) ? difference(value, base[key]) : value; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment