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

Modification to make array diff order independent. #107

Closed tarekz closed 7 years ago

tarekz commented 7 years ago

This modification is based on the work done in https://github.com/flitbit/diff/pull/101. I added logic to remove common objects between array to make sure a deletion result in 1 deletion change instead of numerous edition and 1 deletion. Ex: lhs = [1,2,3,4] rhs= [2,3,4]

should give [DiffArray{index: 0, item: DiffDeleted { lhs=1}}] and not [DiffEdit{lhs: 2, rhs:1}, DiffEdit{lhs: 3, rhs:2}, DiffEdit{lhs: 4, rhs:3}, DiffArray{index: 3, item: DiffDeleted { lhs=4}}]