benjamine / jsondiffpatch

Diff & patch JavaScript objects
MIT License
4.83k stars 472 forks source link

Incorrect Comment? #281

Open ccorcos opened 4 years ago

ccorcos commented 4 years ago

Reading through the code here and I think this comment is incorrect:

https://github.com/benjamine/jsondiffpatch/blob/ef38c5d97c349b0a3672c08710d1625307d3de94/src/filters/arrays.js#L338

We're performing inserts in order. And the logic is correct because that's the only way we can build up a really long array.

Just thought I'd let you know. And nice job -- your code is pretty clean!

benjamine commented 4 years ago

hi @ccorcos , sorry for the delay, and thanks for the comment! I read it again and I think you're right!, probably my mistake copying the comment from the removals a bit above, but inserts make sense to make them in incremental index order, as those indices in the delta are already expressed as in the final (right) array.