mariocasciaro / object-path-immutable

Modify deep object properties without modifying the original object (immutability). Works great with React and Redux.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected value after chaining

fdev opened this issue · comments

When chaining multiple assign/merge calls that need to change the object root, I was expecting them all to have an effect. Instead only the last assign/merge is applied.

const obj = { a: 1 }
const newObj = immutable(obj).assign(null, { b: 2 }).assign(null, { c: 3 }).value()

Expected output

{
  a: 1,
  b: 2,
  c: 3,
}

Actual output

{
  a: 1,
  c: 3,
}

If this is expected behavior it might be worth pointing it out in the documentation.