Closed zenati closed 7 years ago
I quickly hacked up a simple version of what you are asking for in my fork. See if that meets your needs. It's not very sophisticated since it does not return matching hashes or arrays, only matching lowest level items. But it's a start.
It's a nice to have feature. While @dennisfaust proposed a simple version to report common primitive values, a more complex and reasonable version should return matching hashes and arrays. I'm still thinking how to do that in a simple way.
Any inputs are welcome.
Recursion makes any use of the LCS table(s) a bit tricky. A crude but effective alternative would be to have a method 'same' which takes (a, b, diff_array) and returns an array containing the similarities by analyzing diff_array. Anything not in diff_array would be a similarity.
Was that feature implemented in the end? Would be very nice to have it
:+1:
Thanks for your interest in this lib. I'm wondering what would you like to be the output in following case:
diff({a: {x: 2} }, {a: {x: 2} })
Possible result A:
[['=', 'a', {x: 2}]]
Possible result B:
[['=', 'a.x', 2]]
To me, the result A is more natural, but it means the algorithm needs to traverse the object twice -- first check if they are exactly equal(without =
); if not, parse again to get all the =
cases.
Hello,
Actually Hashdiff can show
+
,-
and~
. Is it possible to also show same counts in the diff as=
?example output:
Thanks.