You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reason diff({}, {}) returns undefined is because my own prevailing pattern was if(diff(a,b)).
Your diff(a,b).length pattern also makes sense. I'd happily take a PR supporting both patterns. Such could be accomplished by exporting a slightly different accumulateDiff implementation; I'd probably call it listDiff but that's just me.
I must say I just got bit by this. My build scripts never hit a build that didn't have differences until today and then 💥 . Can you at least update the README to call out this completely unexpected behavior?
Why does
diff({}, {a: 4})
return an array of differences, butdiff({}, {})
returnundefined
? I would expect it to return[]
instead.This makes iteration over the changes much easier. No check for
undefined
is needed.We also occasionally use
diff
only to count the number of differences. This means code likediff(a, b).length
will break on equal objects.The text was updated successfully, but these errors were encountered: