Skip to content

Commit

Permalink
docs(api): update api docs
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Nov 22, 2024
1 parent 7129237 commit 398c5a5
Show file tree
Hide file tree
Showing 22 changed files with 88 additions and 32 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ expect(state.simpleObject).not.toBe(baseState.simpleObject);

- `castDraft()`
- `castImmutable()`
- `castMutable()`
- `Draft<T>`
- `Immutable<T>`
- `Patches`
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- [apply](functions/apply.md)
- [castDraft](functions/castDraft.md)
- [castImmutable](functions/castImmutable.md)
- [castMutable](functions/castMutable.md)
- [create](functions/create.md)
- [current](functions/current.md)
- [isDraft](functions/isDraft.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/functions/apply.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ expect(state).toEqual(apply(baseState, patches));

## Defined in

[apply.ts:26](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/apply.ts#L26)
[apply.ts:26](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/apply.ts#L26)
2 changes: 1 addition & 1 deletion docs/functions/castDraft.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ Cast a value to an Draft type value.

## Defined in

[utils/cast.ts:6](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/utils/cast.ts#L6)
[utils/cast.ts:6](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/utils/cast.ts#L6)
2 changes: 1 addition & 1 deletion docs/functions/castImmutable.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ Cast a value to an Immutable type value.

## Defined in

[utils/cast.ts:13](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/utils/cast.ts#L13)
[utils/cast.ts:13](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/utils/cast.ts#L13)
27 changes: 27 additions & 0 deletions docs/functions/castMutable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[**mutative**](../README.md)**Docs**

***

[mutative](../README.md) / castMutable

# Function: castMutable()

> **castMutable**\<`T`\>(`draft`): `T`
Cast a value to an Mutable type value.

## Type Parameters

**T**

## Parameters

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

## Returns

`T`

## Defined in

[utils/cast.ts:20](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/utils/cast.ts#L20)
12 changes: 6 additions & 6 deletions docs/functions/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ expect(state.arr).toBe(baseState.arr);

### Defined in

[create.ts:25](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/create.ts#L25)
[create.ts:25](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/create.ts#L25)

## create(base, mutate, options)

Expand Down Expand Up @@ -127,7 +127,7 @@ expect(state.arr).toBe(baseState.arr);

### Defined in

[create.ts:25](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/create.ts#L25)
[create.ts:25](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/create.ts#L25)

## create(mutate, options)

Expand Down Expand Up @@ -188,11 +188,11 @@ expect(state.arr).toBe(baseState.arr);

### Defined in

[create.ts:25](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/create.ts#L25)
[create.ts:25](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/create.ts#L25)

## create(base, options)

> **create**\<`T`, `O`, `F`\>(`base`, `options`?): [`T`, () => `Result`\<`T`, `O`, `F`\>]
> **create**\<`T`, `O`, `F`\>(`base`, `options`?): [[`Draft`](../type-aliases/Draft.md)\<`T`\>, () => `Result`\<`T`, `O`, `F`\>]
`create(baseState, callback, options)` to create the next state

Expand Down Expand Up @@ -231,8 +231,8 @@ expect(state.arr).toBe(baseState.arr);

### Returns

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

### Defined in

[create.ts:25](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/create.ts#L25)
[create.ts:25](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/create.ts#L25)
36 changes: 31 additions & 5 deletions docs/functions/current.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

# Function: current()

## current(target)

> **current**\<`T`\>(`target`): `T`
`current(draft)` to get current state in the draft mutation function.
Expand All @@ -25,18 +27,42 @@ const state = create(
);
```

## Type Parameters
### Type Parameters

**T** *extends* `object`

### Parameters

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

### Returns

`T`

### Defined in

[current.ts:120](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/current.ts#L120)

## current(target)

> **current**\<`T`\>(`target`): `T`
### Type Parameters

**T** *extends* `object`

## Parameters
### Parameters

**target**: `T`

## Returns
### Returns

`T`

## Defined in
### Deprecated

You should call current only on `Draft<T>` types.

### Defined in

[current.ts:104](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/current.ts#L104)
[current.ts:122](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/current.ts#L122)
2 changes: 1 addition & 1 deletion docs/functions/isDraft.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ Check if the value is a draft

## Defined in

[utils/draft.ts:11](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/utils/draft.ts#L11)
[utils/draft.ts:12](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/utils/draft.ts#L12)
2 changes: 1 addition & 1 deletion docs/functions/isDraftable.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ Check if a value is draftable

## Defined in

[utils/draft.ts:28](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/utils/draft.ts#L28)
[utils/draft.ts:29](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/utils/draft.ts#L29)
6 changes: 3 additions & 3 deletions docs/functions/makeCreator.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Function: makeCreator()

> **makeCreator**\<`_F`, `_O`\>(`options`?): \<`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`, `R`\>(`mutate`, `options`?) => (`base`, ...`args`) => `CreateResult`\<`T`, `O`, `F`, `R`\>\<`T`, `O`, `F`\>(`base`, `options`?) => [`T`, () => `Result`\<`T`, `O`, `F`\>]
> **makeCreator**\<`_F`, `_O`\>(`options`?): \<`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`, `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`\>]
`makeCreator(options)` to make a creator function.

Expand Down Expand Up @@ -137,8 +137,8 @@ expect(Object.isFrozen(state)).toBeTruthy();

### Returns

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

## Defined in

[makeCreator.ts:87](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/makeCreator.ts#L87)
[makeCreator.ts:87](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/makeCreator.ts#L87)
2 changes: 1 addition & 1 deletion docs/functions/markSimpleObject.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

## Defined in

[utils/marker.ts:26](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/utils/marker.ts#L26)
[utils/marker.ts:26](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/utils/marker.ts#L26)
2 changes: 1 addition & 1 deletion docs/functions/original.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ const state = create(

## Defined in

[original.ts:21](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/original.ts#L21)
[original.ts:21](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/original.ts#L21)
2 changes: 1 addition & 1 deletion docs/functions/rawReturn.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ expect(state).toBe(baseState);

## Defined in

[rawReturn.ts:21](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/rawReturn.ts#L21)
[rawReturn.ts:21](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/rawReturn.ts#L21)
2 changes: 1 addition & 1 deletion docs/functions/unsafe.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ expect(state.foobar.bar).toBe(2);

## Defined in

[unsafe.ts:53](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/unsafe.ts#L53)
[unsafe.ts:53](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/unsafe.ts#L53)
8 changes: 4 additions & 4 deletions docs/interfaces/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Enable autoFreeze, and return frozen state.

#### Defined in

[interface.ts:137](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/interface.ts#L137)
[interface.ts:137](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/interface.ts#L137)

***

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

#### Defined in

[interface.ts:133](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/interface.ts#L133)
[interface.ts:133](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/interface.ts#L133)

***

Expand All @@ -47,7 +47,7 @@ And it can also return a shallow copy function(AutoFreeze and Patches should bot

#### Defined in

[interface.ts:142](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/interface.ts#L142)
[interface.ts:142](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/interface.ts#L142)

***

Expand All @@ -59,4 +59,4 @@ In strict mode, Forbid accessing non-draftable values and forbid returning a non

#### Defined in

[interface.ts:129](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/interface.ts#L129)
[interface.ts:129](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/interface.ts#L129)
2 changes: 1 addition & 1 deletion docs/type-aliases/Draft.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

## Defined in

[interface.ts:182](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/interface.ts#L182)
[interface.ts:182](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/interface.ts#L182)
2 changes: 1 addition & 1 deletion docs/type-aliases/Immutable.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

## Defined in

[interface.ts:164](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/interface.ts#L164)
[interface.ts:164](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/interface.ts#L164)
2 changes: 1 addition & 1 deletion docs/type-aliases/Patch.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

## Defined in

[interface.ts:58](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/interface.ts#L58)
[interface.ts:58](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/interface.ts#L58)
2 changes: 1 addition & 1 deletion docs/type-aliases/Patches.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

## Defined in

[interface.ts:72](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/interface.ts#L72)
[interface.ts:72](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/interface.ts#L72)
2 changes: 1 addition & 1 deletion docs/type-aliases/PatchesOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
## Defined in

[interface.ts:18](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/interface.ts#L18)
[interface.ts:18](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/interface.ts#L18)
1 change: 1 addition & 0 deletions website/docs/advanced-guides/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Mutative support is built into the typescript types. You can use the `Draft<T>`

- `castDraft()`
- `castImmutable()`
- `castMutable()`
- `Draft<T>`
- `Immutable<T>`
- `Patches`
Expand Down

0 comments on commit 398c5a5

Please sign in to comment.