flitbit / diff

Javascript utility for calculating deep difference, capturing changes, and applying changes across objects; for nodejs and the browser.
MIT License
2.99k stars 213 forks source link

ignore order of keys? #122

Closed scramble45 closed 6 years ago

scramble45 commented 6 years ago

Is there a way to ignore the order of keys? I don't care about the order in which keys reside in the array of objects only that those keys exists and their values exists across both array of objects.

Something like this exists in the python version. https://github.com/seperman/deepdiff#ignore-order

var t1 = {1:1, 2:2, 3:3, 4:{"a":"hello", "b":[1, 2, 3]}}
var t2 = {1:1, 2:2, 3:3, 4:{"a":"hello", "b":[1, 3, 2, 3]}}
var diff = DeepDiff(t1, t2, ignore_order:true)
console.log(diff)
daweedm commented 6 years ago

I've the same problem, any news about this ? Thank you

scramble45 commented 6 years ago

Ended up just using lodash, _.map and filter to get them spitting out in order.

Probably wouldn't be too hard to get a PR pushed up for making this an option.

Sent from my iPhone

On Mar 18, 2018, at 9:19 PM, Daweed notifications@github.com wrote:

I've the same problem, any news about this ? Thank you

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

flitbit commented 6 years ago

@jsfuchs contributed some code that I finally got merged and tested. I'm pretty sure it was broken for a while after first merging... in any case, look at the tests here for an example.