unadlib / mutative

Efficient immutable updates, 2-6x faster than naive handcrafted reducer, and more than 10x faster than Immer.
http://mutative.js.org/
MIT License
1.58k stars 18 forks source link

fix(marker): `markSimpleObject` add null check #24

Closed exuanbo closed 9 months ago

exuanbo commented 9 months ago

Currently:

const { create, markSimpleObject, rawReturn } = require('mutative');

create(null, (_draft) => rawReturn({}), {
  mark: markSimpleObject,
});

will throw error:

TypeError: Cannot convert undefined or null to object

Reproduction: https://stackblitz.com/edit/stackblitz-starters-k3gwyj?file=index.js

Reference: https://github.com/unadlib/mutative/blob/ed780e0dc0e3ff864fbb9c7d0af3439ccf4100cc/test/immer/src/immer.ts#L164-L181

unadlib commented 9 months ago

Thank you for your contribution. I will release v1.0.1 after adding tests.