recursive-diff
recursive-diff copied to clipboard
applyDiff doesn't work for arrays with objects
Let's assume I have the following objects:
const initialVal = {
v: {
data: [
{},
],
},
}
const changedVal = {
v: {
data: [
{
blabla: 3,
},
],
},
}
const delta = getDiff(initialVal, changedVal);
const diff = applyDiff(initialVal, delta);
console.log(delta);
console.log(diff);
The output of this would be:
[ { op: 'add', path: [ 'v', 'data', 0, 'blabla' ], val: 3 } ]
{ v: { data: [ [Object] ] } }
It this the wanted output [Object] ?
Should't it be:
{ v: { data: [ {blabla: 3} ] } }
Greetings, I hope this has been resolved as inaccurate, as the console.log() is to blame here. See this stack overflow answer for printing deep objects from console.