From 96677ae9809547a439360922d1e01fa0dcb14fac Mon Sep 17 00:00:00 2001 From: unadlib Date: Wed, 21 Dec 2022 01:19:31 +0800 Subject: [PATCH] docs(readme): update doc --- README.md | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a1ac412..013dd161 100644 --- a/README.md +++ b/README.md @@ -8,17 +8,54 @@ Efficient creation of immutable state 10x faster than immer ## Motivation + +TBD ### Performance +TBD + ### Features + +- apply patches +- Supports optional freezing +- Custom shallow copy +- immutable and mutable markable +- Strict mode for safer mutable data access + ### Difference between Immer and Mutative +| - | Mutative | Immer | +| :---------------------------- | -------: | :-------------: | +| Best performance | ✅ | ❌ | +| Default common data structure | ✅ | ❌(auto freeze) | +| Non-invasive marking | ✅ | ❌ | +| Automatic type inference | ✅ | ❌ | +| Complete freeze data | ✅ | ❌ | + ## Installation +```sh +yarn install mutative # npm install mutative +``` + ## Examples +```ts +const baseState = { + foo: 'bar', + list: [{ text: 'coding' }], +}; + +const state = create(baseState, (draft) => { + draft.foo = 'foobar'; + draft.list.push({ text: 'learning' }); +}); +``` + ## Migration from Immer to Mutative +TBD + ## APIs - `create()` @@ -101,4 +138,4 @@ const state = create(baseState, (draft) => { ## FAQs - +TBD