Array item order matters, however When object in an Array change order, no diff is generated
dhwang opened this issue · comments
Darren Hwang commented
Need to be able to show that two items in an array switched order for example
{ a : [ { id: b, value: 1}, {id: a, value: 2}] }
{ a : [ { id: a, value: 2}, {id: b, value: 1}] }
should show a difference as order matters in an array
Manthan Mallikarjun commented
Looks like it works:
var changesets = require('diff-json');
console.log(changesets.diff(
{ a : [ { id: 'b', value: 1}, {id: 'a', value: 2}] },
{ a : [ { id: 'a', value: 2}, {id: 'b', value: 1}] }));
returns
[ { type: 'update',
key: 'a',
embededKey: '$index',
changes: [ [Object], [Object] ] } ]
Mr Cup commented
yes, it should work by default