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

Arrays returned as objects #94

Open StephenTHendrix opened 1 year ago

StephenTHendrix commented 1 year ago

I think I'm just re-reporting https://github.com/mattphillips/deep-object-diff/issues/79.

diff({ test: [] }, { test: ['apple'] }) returns { test: { 0: 'apple' }

obrunopolo commented 1 year ago

Same for me

mikila85 commented 1 year ago

same for me, is there a fix anyone found or should i find a different package? actually should even be ability to say ignoreArrays:true to just get the new array instead of each index which doesnt really matter to alot of people..

baermathias commented 1 year ago

It seems that this here doesn't work at all:

  diff(
    {
      v: {
        data: [
          {
            blabla: 3,
          },
        ],
      },
    },
    {
      v: {
        data: [
          {},
        ],
      },
    },
  ),

Returns:

[Object: null prototype] {
  v: [Object: null prototype] {
    data: [Object: null prototype] { '0': [Object: null prototype] }
  }
}