Closed NanoDylan closed 2 years ago
Hi @NanoDylan you're correct there has been a change in behaviour around diff
and updatedDiff
(which is used in detailedDiff
) when comparing a nested value that has become an empty object / array. This change is a bugfix for: https://github.com/mattphillips/deep-object-diff/issues/66
Previously deep-object-diff would incorrectly consider values on the rhs of the diff that are empty to have no difference but in actuality they do.
Take your example:
const lhs = { someArray: [ 'a'] };
const rhs = { someArray: [] };
updatedDiff(lhs, rhs) // -> { someArray: {} }
The someArray
key in the right hand object has been updated to an empty Array. Which in DoD is represented as an empty object.
I'll close this for now too but again feel free to re-open / ping me if I've misunderstood or have got anything wrong above 😃
Perfect. :smile: I understand the logic of the #66 bugfix. I will update accordingly. Thanks!
The behavior of a detailedDiff result changed from deep-object-diff@1.1.0 and deep-object-diff@1.1.7. Based on my interpretation of the README.md example for detailedDiff, neither 1.1.0 nor 1.17 behavior matches the documentation ( See issue #74 ). In version 1.1.0, if the last item in the array is deleted, then the change is indicated in the deleted section of the diff results. In the current version, 1.1.7, if the last item in the array is deleted, then the change is indicated in both the deleted section and the updated section of the diff results.