recursive-diff icon indicating copy to clipboard operation
recursive-diff copied to clipboard

applyDiff doesn't work for arrays with objects

Open baermathias opened this issue 2 years ago • 1 comments

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} ] } }

baermathias avatar Sep 05 '23 07:09 baermathias

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.

Chimukrate avatar Jan 29 '24 13:01 Chimukrate