Mutative 1.0 – A New Era in Efficient Immutable Updates
mutative.js.org
mutative.js.org
``` const state = { ...baseState, key0: { ...baseState.key0, value: i, }, }; ```
Compared to the spread operation ("naive handcrafted reducer"):
> [Mutative] focuses on shallow copy optimization, more complete lazy drafts, finalization process optimization, and more.
Compared to Immer:
> Immer relies on auto-freeze to be enabled, if auto-freeze is disabled, Immer will have a huge performance drop and Mutative will have a huge performance lead, especially with large data structures.
Oh, I didn't notice this: Full compliance with JSON Patch specification. Interesting!
> Immer must have auto-freeze enabled by default(Performance will be worse if auto-freeze is disabled), such immutable state with Immer is not common. In scenarios such as cross-processing, remote data transfer, etc., we have to constantly freeze these immutable data.
> There are more parts that could be improved, such as better type inference, non-intrusive markup, support for more types of immutability, Safer immutability, more edge cases, and so on.
Also compared to native spread operation(naive handcrafted reducer):
> The spread operation has performance pitfalls...
> And Mutative optimization focus on shallow copy optimization, more complete lazy drafts, finalization process optimization, and more.