mattphillips / deep-object-diff

Deep diffs two objects, including nested structures of arrays and objects, and returns the difference. ❄️
https://www.npmjs.com/package/deep-object-diff
MIT License
1.05k stars 89 forks source link

Not clear behaviour of non-ordered arrays comparison with addedDiff #90

Closed yahacom closed 1 year ago

yahacom commented 1 year ago

Example:

const old = { foo: [1, 2] };
const new = { foo: [3, 1, 2, 4, 0] };

const d = addedDiff(old, new);
// Returns: {"foo": {"2": 2, "3": 4, "4": 0}}

Is it expected? No, from my perspective it should be like: {"foo": {"0": 3, "3": 4, "4": 0}}. Because current behaviour more answer question - what was changed in array instead of what was added to array.