Closed martinjo closed 1 month ago
Hi @martinjo ,
It's easy to add. I'll add some tests in the week and publish a release asap.
Oh, nice!
Thanks! 🙏
The option has been added and the library has been updated on npm. Let me know if it works for you!
If your company uses the project for commercial purposes, feel free to support it.
Have a great day!
EDIT: Please note that you should use getListDiff
to compare two arrays, and not getObjectDiff
, as in your exemple.
I was hoping to get this case to work:
describe('JSON Diff with Superdiff', () => { const options = { referenceProperty: 'id', ignoreArrayOrder: false };
it('should ignore position changes in arrays', () => { const original = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]; const updated = [{ id: 2, name: 'Bob' }, { id: 1, name: 'Alice' }];
});
But instead it will list both array items as updated. Is there a way to make superdiff disregard changes of items position in an array completely?