Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const state = create(baseState, (draft) => {

In this basic example, the changes to the draft are 'mutative' within the draft callback, and `create()` is finally executed with a new immutable state.

The recipe can be an async function: `create()` then returns a Promise of the result, and the draft stays usable until that Promise settles. `create()` recognizes the Promises of the current JavaScript realm only, so an async function from another realm, such as a `vm` context or an iframe, needs a wrapper from this realm: `create(baseState, async (draft) => { return await recipe(draft); })`. TypeScript types the result as a Promise as well, except with an explicit state type that is a type parameter, as in `create<T>(base, async (draft) => { … })` in a generic function, or that includes Promises, such as `object` or `unknown`, which gives the state type itself. In generic code, leave out the type argument: `create(base, async (draft) => { … })` gives `Promise<T>`.
The recipe can be an async function: `create()` then returns a Promise of the result, and the draft stays usable until that Promise settles. `create()` recognizes the Promises of the current JavaScript realm only, so an async function from another realm, such as a `vm` context or an iframe, needs a wrapper from this realm: `create(baseState, async (draft) => { return await recipe(draft); })`. TypeScript types the result as a Promise as well, except with an explicit state type that is a type parameter, as in `create<T>(base, async (draft) => { … })` in a generic function, or that includes Promises, such as `object` or `unknown`, which gives the state type itself. In generic code, leave out the type argument: `create(base, async (draft) => { … })` gives `Promise<T>`, and `create(async (draft: T) => { … })` gives `(base: T) => Promise<T>`.

#### `create(state, fn, options)`

Expand Down Expand Up @@ -806,7 +806,7 @@ Mutative v2 keeps the v1 API. The changes below, made since v1.3.0, can affect e

- `create()` with an explicit state type and an async recipe, such as `create<State>(base, async (draft) => { … })`, returns `Promise<State>`, and so do curried producers; v1 typed the result as `State`. A state type that is a type parameter, as in a generic function, or that includes Promises, such as `object` or `unknown`, still gives the state type for async recipes and for recipes that may return a Promise, as in v1; leave out the type argument in generic code.
- `apply()` accepts `enableAutoFreeze: true` and then returns `Immutable<State>`, as `apply<State, true>()` does; v1 rejected the option and typed the frozen result as mutable. With `enableAutoFreeze` typed as `boolean` or optional `true`, the result is `State | Immutable<State>`. With `mutable` typed as `boolean`, optional `boolean`, or optional `true`, `apply()` returns `State | void`.
- A curried producer whose recipe annotates its draft and returns a new state, such as `create((draft: State) => ({ ...draft, count: 0 }))`, returns `State`, or `Promise<State>` for an async recipe. v1 typed such a call as a manual draft, so calling the producer did not compile.
- A curried producer whose recipe annotates its draft and returns a new state, such as `create((draft: State) => ({ ...draft, count: 0 }))`, returns `State`, or `Promise<State>` for an async recipe. v1 typed such a call as a manual draft, so calling the producer did not compile. A recipe whose draft is annotated with a type parameter, as in `create((draft: T) => { … })` in a generic function, also gives a producer, which v1 typed as a manual draft as well.
- With an explicit state type, a recipe that may or may not return a Promise, such as one typed `(draft: State) => void | Promise<void>`, gives `State | Promise<State>`, also for a primitive state type, such as `number`, and in curried producers and creators from `makeCreator()`. v1 typed the result as `State`.

### Fixes that change results
Expand Down
10 changes: 5 additions & 5 deletions docs/functions/apply.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

> **apply**\<`T`, `F`, `_A`\>(`state`, `patches`, `applyOptions?`): `ApplyState`\<`T`, `F`, `undefined`\>

Defined in: [apply.ts:63](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/apply.ts#L63)
Defined in: [apply.ts:63](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/apply.ts#L63)

`apply(state, patches)` to apply patches to state

Expand Down Expand Up @@ -68,7 +68,7 @@ expect(state).toEqual(apply(baseState, patches));

> **apply**\<`T`, `F`, `A`\>(`state`, `patches`, `applyOptions`): `ApplyResult`\<`T`, `F`, `A`\>

Defined in: [apply.ts:72](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/apply.ts#L72)
Defined in: [apply.ts:72](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/apply.ts#L72)

`apply(state, patches)` to apply patches to state

Expand Down Expand Up @@ -126,7 +126,7 @@ expect(state).toEqual(apply(baseState, patches));

> **apply**\<`T`, `F`, `A`\>(`state`, `patches`, `applyOptions?`): `ApplyResult`\<`T`, `F`, `undefined` \| `A`\>

Defined in: [apply.ts:79](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/apply.ts#L79)
Defined in: [apply.ts:79](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/apply.ts#L79)

`apply(state, patches)` to apply patches to state

Expand Down Expand Up @@ -184,7 +184,7 @@ expect(state).toEqual(apply(baseState, patches));

> **apply**\<`T`, `F`\>(`state`, `patches`, `applyOptions`): `void`

Defined in: [apply.ts:90](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/apply.ts#L90)
Defined in: [apply.ts:90](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/apply.ts#L90)

`apply(state, patches)` to apply patches to state

Expand Down Expand Up @@ -240,7 +240,7 @@ expect(state).toEqual(apply(baseState, patches));

> **apply**\<`T`, `F`\>(`state`, `patches`, `applyOptions`): `ApplyResult`\<`T`, `F`, `undefined` \| `ApplyMutableOptions`\>

Defined in: [apply.ts:95](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/apply.ts#L95)
Defined in: [apply.ts:95](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/apply.ts#L95)

`apply(state, patches)` to apply patches to state

Expand Down
2 changes: 1 addition & 1 deletion docs/functions/castDraft.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **castDraft**\<`T`\>(`value`): [`Draft`](../type-aliases/Draft.md)\<`T`\>

Defined in: [utils/cast.ts:6](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/utils/cast.ts#L6)
Defined in: [utils/cast.ts:6](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/utils/cast.ts#L6)

Cast a value to an Draft type value.

Expand Down
2 changes: 1 addition & 1 deletion docs/functions/castImmutable.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **castImmutable**\<`T`\>(`value`): [`Immutable`](../type-aliases/Immutable.md)\<`T`\>

Defined in: [utils/cast.ts:13](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/utils/cast.ts#L13)
Defined in: [utils/cast.ts:13](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/utils/cast.ts#L13)

Cast a value to an Immutable type value.

Expand Down
2 changes: 1 addition & 1 deletion docs/functions/castMutable.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **castMutable**\<`T`\>(`draft`): `T`

Defined in: [utils/cast.ts:20](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/utils/cast.ts#L20)
Defined in: [utils/cast.ts:20](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/utils/cast.ts#L20)

Cast a value to an Mutable type value.

Expand Down
4 changes: 2 additions & 2 deletions docs/functions/current.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

> **current**\<`T`\>(`target`): `T`

Defined in: [current.ts:198](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/current.ts#L198)
Defined in: [current.ts:198](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/current.ts#L198)

`current(draft)` to get current state in the draft mutation function.

Expand Down Expand Up @@ -49,7 +49,7 @@ const state = create(

> **current**\<`T`\>(`target`): `T`

Defined in: [current.ts:200](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/current.ts#L200)
Defined in: [current.ts:200](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/current.ts#L200)

### Type Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/functions/isDraft.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **isDraft**(`target`): `boolean`

Defined in: [utils/draft.ts:33](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/utils/draft.ts#L33)
Defined in: [utils/draft.ts:33](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/utils/draft.ts#L33)

Check if the value is a draft

Expand Down
2 changes: 1 addition & 1 deletion docs/functions/isDraftable.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **isDraftable**(`value`, `options?`): `boolean`

Defined in: [utils/draft.ts:59](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/utils/draft.ts#L59)
Defined in: [utils/draft.ts:59](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/utils/draft.ts#L59)

Check if a value is draftable

Expand Down
2 changes: 1 addition & 1 deletion docs/functions/markSimpleObject.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **markSimpleObject**(`value`): `undefined` \| `"immutable"`

Defined in: [utils/marker.ts:26](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/utils/marker.ts#L26)
Defined in: [utils/marker.ts:26](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/utils/marker.ts#L26)

## Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/functions/original.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **original**\<`T`\>(`target`): `T`

Defined in: [original.ts:22](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/original.ts#L22)
Defined in: [original.ts:22](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/original.ts#L22)

`original(draft)` to get original state in the draft mutation function.

Expand Down
2 changes: 1 addition & 1 deletion docs/functions/rawReturn.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **rawReturn**\<`T`\>(`value`): `T`

Defined in: [rawReturn.ts:22](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/rawReturn.ts#L22)
Defined in: [rawReturn.ts:22](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/rawReturn.ts#L22)

Use rawReturn() to wrap the return value to skip the draft check and thus improve performance.

Expand Down
2 changes: 1 addition & 1 deletion docs/functions/unsafe.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **unsafe**\<`T`\>(`callback`): `T`

Defined in: [unsafe.ts:57](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/unsafe.ts#L57)
Defined in: [unsafe.ts:57](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/unsafe.ts#L57)

`unsafe(callback)` to access mutable data directly in strict mode.

Expand Down
10 changes: 5 additions & 5 deletions docs/interfaces/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Interface: Options\<O, F\>

Defined in: [interface.ts:171](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/interface.ts#L171)
Defined in: [interface.ts:171](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/interface.ts#L171)

## Type Parameters

Expand All @@ -24,7 +24,7 @@ Defined in: [interface.ts:171](https://github.com/unadlib/mutative/blob/c2e96282

> `optional` **enableAutoFreeze**: `F`

Defined in: [interface.ts:184](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/interface.ts#L184)
Defined in: [interface.ts:184](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/interface.ts#L184)

Enable autoFreeze, and return frozen state.

Expand All @@ -34,7 +34,7 @@ Enable autoFreeze, and return frozen state.

> `optional` **enablePatches**: `O`

Defined in: [interface.ts:180](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/interface.ts#L180)
Defined in: [interface.ts:180](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/interface.ts#L180)

Enable patch, and return the patches and inversePatches.

Expand All @@ -44,7 +44,7 @@ Enable patch, and return the patches and inversePatches.

> `optional` **mark**: `Mark`\<`O`, `F`\> \| `Mark`\<`O`, `F`\>[]

Defined in: [interface.ts:189](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/interface.ts#L189)
Defined in: [interface.ts:189](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/interface.ts#L189)

Set a mark to determine if the object is mutable or if an instance is an immutable.
And it can also return a shallow copy function(AutoFreeze and Patches should both be disabled).
Expand All @@ -55,7 +55,7 @@ And it can also return a shallow copy function(AutoFreeze and Patches should bot

> `optional` **strict**: `boolean`

Defined in: [interface.ts:176](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/interface.ts#L176)
Defined in: [interface.ts:176](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/interface.ts#L176)

In strict mode, Forbid accessing non-draftable values and forbid returning a non-draft value.
Development builds also warn once when a recipe leaves 1,000 or more drafts unchanged.
2 changes: 1 addition & 1 deletion docs/type-aliases/Draft.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **Draft**\<`T`\> = `T` *extends* `Primitive` \| `AtomicObject` ? `T` : `T` *extends* `IfAvailable`\<`ReadonlyMap`\<infer K, infer V\>\> ? `DraftedMap`\<`K`, `V`\> : `T` *extends* `IfAvailable`\<`ReadonlySet`\<infer V\>\> ? `DraftedSet`\<`V`\> : `T` *extends* `WeakReferences` ? `T` : `T` *extends* `object` ? [`DraftedObject`](DraftedObject.md)\<`T`\> : `T`

Defined in: [interface.ts:229](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/interface.ts#L229)
Defined in: [interface.ts:229](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/interface.ts#L229)

## Type Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/type-aliases/DraftedObject.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **DraftedObject**\<`T`\> = `{ -readonly [K in keyof T]: Draft<T[K]> }`

Defined in: [interface.ts:225](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/interface.ts#L225)
Defined in: [interface.ts:225](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/interface.ts#L225)

## Type Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/type-aliases/Immutable.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **Immutable**\<`T`\> = `T` *extends* `Primitive` \| `AtomicObject` ? `T` : `T` *extends* `IfAvailable`\<`ReadonlyMap`\<infer K, infer V\>\> ? `ImmutableMap`\<`K`, `V`\> : `T` *extends* `IfAvailable`\<`ReadonlySet`\<infer V\>\> ? `ImmutableSet`\<`V`\> : `T` *extends* `WeakReferences` ? `T` : `T` *extends* `object` ? `ImmutableObject`\<`T`\> : `T`

Defined in: [interface.ts:211](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/interface.ts#L211)
Defined in: [interface.ts:211](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/interface.ts#L211)

## Type Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/type-aliases/Patch.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **Patch**\<`P`\> = `P` *extends* `object` ? `IPatch` & `object` : `P` *extends* `true` \| `object` ? `IPatch` & `object` : `IPatch` & `object`

Defined in: [interface.ts:96](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/interface.ts#L96)
Defined in: [interface.ts:96](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/interface.ts#L96)

## Type Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/type-aliases/Patches.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **Patches**\<`P`\> = [`Patch`](Patch.md)\<`P`\>[]

Defined in: [interface.ts:110](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/interface.ts#L110)
Defined in: [interface.ts:110](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/interface.ts#L110)

## Type Parameters

Expand Down
2 changes: 1 addition & 1 deletion docs/type-aliases/PatchesOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **PatchesOptions** = `boolean` \| \{ `arrayLengthAssignment?`: `boolean`; `pathAsArray?`: `boolean`; \}

Defined in: [interface.ts:18](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/interface.ts#L18)
Defined in: [interface.ts:18](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/interface.ts#L18)

## Type Declaration

Expand Down
58 changes: 56 additions & 2 deletions docs/variables/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

# Variable: create()

> `const` **create**: \{\<`T`, `F`, `O`\>(`base`, `mutate`, `options?`): `Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>; \<`T`, `F`, `O`\>(`base`, `mutate`, `options?`): `Promise`\<`Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>\>; \<`T`, `F`, `O`\>(`base`, `mutate`, `options?`): `Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>; \<`T`, `F`, `O`\>(`base`, `mutate`, `options?`): `Result`\<`ExplicitState`\<`T`\>, `O`, `F`\> \| `Promise`\<`Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>\>; \<`T`, `F`, `O`, `R`\>(`base`, `mutate`, `options?`): `CreateResult`\<`T`, `O`, `F`, `R`\>; \<`T`, `F`, `O`, `R`\>(`base`, `mutate`, `options?`): `CreateResult`\<`T`, `O`, `F`, `R`\>; \<`T`, `P`, `F`, `O`\>(`mutate`, `options?`): (`base`, ...`args`) => `Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>; \<`T`, `P`, `F`, `O`\>(`mutate`, `options?`): (`base`, ...`args`) => `Promise`\<`Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>\>; \<`T`, `P`, `F`, `O`\>(`mutate`, `options?`): (`base`, ...`args`) => `Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>; \<`T`, `P`, `F`, `O`\>(`mutate`, `options?`): (`base`, ...`args`) => `Result`\<`ExplicitState`\<`T`\>, `O`, `F`\> \| `Promise`\<`Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>\>; \<`T`, `P`, `F`, `O`, `R`\>(`mutate`, `options?`): (`base`, ...`args`) => `CreateResult`\<`T`, `O`, `F`, `R`\>; \<`T`, `O`, `F`\>(`base`, `options?`): \[[`Draft`](../type-aliases/Draft.md)\<`T`\>, () => `Result`\<`T`, `O`, `F`\>\]; \}
> `const` **create**: \{\<`T`, `F`, `O`\>(`base`, `mutate`, `options?`): `Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>; \<`T`, `F`, `O`\>(`base`, `mutate`, `options?`): `Promise`\<`Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>\>; \<`T`, `F`, `O`\>(`base`, `mutate`, `options?`): `Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>; \<`T`, `F`, `O`\>(`base`, `mutate`, `options?`): `Result`\<`ExplicitState`\<`T`\>, `O`, `F`\> \| `Promise`\<`Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>\>; \<`T`, `F`, `O`, `R`\>(`base`, `mutate`, `options?`): `CreateResult`\<`T`, `O`, `F`, `R`\>; \<`T`, `F`, `O`, `R`\>(`base`, `mutate`, `options?`): `CreateResult`\<`T`, `O`, `F`, `R`\>; \<`T`, `P`, `F`, `O`\>(`mutate`, `options?`): (`base`, ...`args`) => `Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>; \<`T`, `P`, `F`, `O`\>(`mutate`, `options?`): (`base`, ...`args`) => `Promise`\<`Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>\>; \<`T`, `P`, `F`, `O`\>(`mutate`, `options?`): (`base`, ...`args`) => `Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>; \<`T`, `P`, `F`, `O`\>(`mutate`, `options?`): (`base`, ...`args`) => `Result`\<`ExplicitState`\<`T`\>, `O`, `F`\> \| `Promise`\<`Result`\<`ExplicitState`\<`T`\>, `O`, `F`\>\>; \<`T`, `P`, `F`, `O`, `R`\>(`mutate`, `options?`): (`base`, ...`args`) => `CreateResult`\<`T`, `O`, `F`, `R`\>; \<`T`, `P`, `F`, `O`, `R`\>(`mutate`, `options?`): (`base`, ...`args`) => `CreateResult`\<`T`, `O`, `F`, `R`\>; \<`T`, `O`, `F`\>(`base`, `options?`): \[[`Draft`](../type-aliases/Draft.md)\<`T`\>, () => `Result`\<`T`, `O`, `F`\>\]; \}

Defined in: [create.ts:25](https://github.com/unadlib/mutative/blob/c2e96282fb77355d4c5f83d86c6d201dee734d45/src/create.ts#L25)
Defined in: [create.ts:25](https://github.com/unadlib/mutative/blob/cbcd06102ce38252b6fa8b2c9f28a18ba9d9fbe9/src/create.ts#L25)

`create(baseState, callback, options)` to create the next state

Expand Down Expand Up @@ -511,6 +511,60 @@ expect(state.arr).toBe(baseState.arr);

## Call Signature

> \<`T`, `P`, `F`, `O`, `R`\>(`mutate`, `options?`): (`base`, ...`args`) => `CreateResult`\<`T`, `O`, `F`, `R`\>

### Type Parameters

#### T

`T` *extends* `unknown`

#### P

`P` *extends* `any`[] = \[\]

#### F

`F` *extends* `boolean` = `false`

#### O

`O` *extends* [`PatchesOptions`](../type-aliases/PatchesOptions.md) = `false`

#### R

`R` *extends* `unknown` = `void`

### Parameters

#### mutate

(`draft`, ...`args`) => `R`

#### options?

[`Options`](../interfaces/Options.md)\<`O`, `F`\>

### Returns

> (`base`, ...`args`): `CreateResult`\<`T`, `O`, `F`, `R`\>

#### Parameters

##### base

`T`

##### args

...`P`

#### Returns

`CreateResult`\<`T`, `O`, `F`, `R`\>

## Call Signature

> \<`T`, `O`, `F`\>(`base`, `options?`): \[[`Draft`](../type-aliases/Draft.md)\<`T`\>, () => `Result`\<`T`, `O`, `F`\>\]

### Type Parameters
Expand Down
Loading
Loading