Closed zatziky closed 6 years ago
I like the proposal, it basically rolls up (or short-circuits) the changes for each array element. I can see that this may be handy for some use cases. I also like the ramda
library you're using - very cool. I try not to use any dependencies at all, that's why the code is so long-winded.
Here's my take: some use cases may benefit from different difference-reporting structures, therefore, it would be nice if deep-diff
had a pluggable difference-reporting mechanism.
With such a mechanism, many implementations are possible, including mine (default) and yours.
I'd second implementation of this suggestion, I've found myself needing to know which elements inside an object's attribute (which happens to be an array of values) has changed.
Array parsing feels important to be honest. You aren't just telling users that a difference existed, you've taken the steps to list out exactly what changed. I'd like to see this library fully embrace that role.
For our auditing system we needed to persist the whole array element and not just the difference.
The object difference for
would look in the original deep-diff like:
Our need is that the result keeps the original and changed elements. It also has the
kind
asA
and changes the structure a bit:You could add an option to change the default behavior so that it creates diffs of edited array elements in the proposed manner. I've made a small project deepdiff-keep-element where you can check our intentions in tests.