object-path-immutable icon indicating copy to clipboard operation
object-path-immutable copied to clipboard

Unexpected value after chaining

Open fdev opened this issue 5 years ago • 0 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.

fdev avatar Apr 09 '19 09:04 fdev