Skip to content

Commit 398c5a5

Browse files
committed
docs(api): update api docs
1 parent 7129237 commit 398c5a5

22 files changed

+88
-32
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ expect(state.simpleObject).not.toBe(baseState.simpleObject);
533533

534534
- `castDraft()`
535535
- `castImmutable()`
536+
- `castMutable()`
536537
- `Draft<T>`
537538
- `Immutable<T>`
538539
- `Patches`

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- [apply](functions/apply.md)
2222
- [castDraft](functions/castDraft.md)
2323
- [castImmutable](functions/castImmutable.md)
24+
- [castMutable](functions/castMutable.md)
2425
- [create](functions/create.md)
2526
- [current](functions/current.md)
2627
- [isDraft](functions/isDraft.md)

docs/functions/apply.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ expect(state).toEqual(apply(baseState, patches));
4848

4949
## Defined in
5050

51-
[apply.ts:26](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/apply.ts#L26)
51+
[apply.ts:26](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/apply.ts#L26)

docs/functions/castDraft.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ Cast a value to an Draft type value.
2424

2525
## Defined in
2626

27-
[utils/cast.ts:6](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/utils/cast.ts#L6)
27+
[utils/cast.ts:6](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/utils/cast.ts#L6)

docs/functions/castImmutable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ Cast a value to an Immutable type value.
2424

2525
## Defined in
2626

27-
[utils/cast.ts:13](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/utils/cast.ts#L13)
27+
[utils/cast.ts:13](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/utils/cast.ts#L13)

docs/functions/castMutable.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[**mutative**](../README.md)**Docs**
2+
3+
***
4+
5+
[mutative](../README.md) / castMutable
6+
7+
# Function: castMutable()
8+
9+
> **castMutable**\<`T`\>(`draft`): `T`
10+
11+
Cast a value to an Mutable type value.
12+
13+
## Type Parameters
14+
15+
**T**
16+
17+
## Parameters
18+
19+
**draft**: [`Draft`](../type-aliases/Draft.md)\<`T`\>
20+
21+
## Returns
22+
23+
`T`
24+
25+
## Defined in
26+
27+
[utils/cast.ts:20](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/utils/cast.ts#L20)

docs/functions/create.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ expect(state.arr).toBe(baseState.arr);
7676

7777
### Defined in
7878

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

8181
## create(base, mutate, options)
8282

@@ -127,7 +127,7 @@ expect(state.arr).toBe(baseState.arr);
127127

128128
### Defined in
129129

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

132132
## create(mutate, options)
133133

@@ -188,11 +188,11 @@ expect(state.arr).toBe(baseState.arr);
188188

189189
### Defined in
190190

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

193193
## create(base, options)
194194

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

@@ -231,8 +231,8 @@ expect(state.arr).toBe(baseState.arr);
231231

232232
### Returns
233233

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

236236
### Defined in
237237

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

docs/functions/current.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
# Function: current()
88

9+
## current(target)
10+
911
> **current**\<`T`\>(`target`): `T`
1012
1113
`current(draft)` to get current state in the draft mutation function.
@@ -25,18 +27,42 @@ const state = create(
2527
);
2628
```
2729

28-
## Type Parameters
30+
### Type Parameters
31+
32+
**T** *extends* `object`
33+
34+
### Parameters
35+
36+
**target**: [`Draft`](../type-aliases/Draft.md)\<`T`\>
37+
38+
### Returns
39+
40+
`T`
41+
42+
### Defined in
43+
44+
[current.ts:120](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/current.ts#L120)
45+
46+
## current(target)
47+
48+
> **current**\<`T`\>(`target`): `T`
49+
50+
### Type Parameters
2951

3052
**T** *extends* `object`
3153

32-
## Parameters
54+
### Parameters
3355

3456
**target**: `T`
3557

36-
## Returns
58+
### Returns
3759

3860
`T`
3961

40-
## Defined in
62+
### Deprecated
63+
64+
You should call current only on `Draft<T>` types.
65+
66+
### Defined in
4167

42-
[current.ts:104](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/current.ts#L104)
68+
[current.ts:122](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/current.ts#L122)

docs/functions/isDraft.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ Check if the value is a draft
2020

2121
## Defined in
2222

23-
[utils/draft.ts:11](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/utils/draft.ts#L11)
23+
[utils/draft.ts:12](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/utils/draft.ts#L12)

docs/functions/isDraftable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ Check if a value is draftable
2424

2525
## Defined in
2626

27-
[utils/draft.ts:28](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/utils/draft.ts#L28)
27+
[utils/draft.ts:29](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/utils/draft.ts#L29)

docs/functions/makeCreator.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Function: makeCreator()
88

9-
> **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`\>]
9+
> **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`\>]
1010
1111
`makeCreator(options)` to make a creator function.
1212

@@ -137,8 +137,8 @@ expect(Object.isFrozen(state)).toBeTruthy();
137137

138138
### Returns
139139

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

142142
## Defined in
143143

144-
[makeCreator.ts:87](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/makeCreator.ts#L87)
144+
[makeCreator.ts:87](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/makeCreator.ts#L87)

docs/functions/markSimpleObject.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818

1919
## Defined in
2020

21-
[utils/marker.ts:26](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/utils/marker.ts#L26)
21+
[utils/marker.ts:26](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/utils/marker.ts#L26)

docs/functions/original.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ const state = create(
3939

4040
## Defined in
4141

42-
[original.ts:21](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/original.ts#L21)
42+
[original.ts:21](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/original.ts#L21)

docs/functions/rawReturn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ expect(state).toBe(baseState);
3939

4040
## Defined in
4141

42-
[rawReturn.ts:21](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/rawReturn.ts#L21)
42+
[rawReturn.ts:21](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/rawReturn.ts#L21)

docs/functions/unsafe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ expect(state.foobar.bar).toBe(2);
5151

5252
## Defined in
5353

54-
[unsafe.ts:53](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/unsafe.ts#L53)
54+
[unsafe.ts:53](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/unsafe.ts#L53)

docs/interfaces/Options.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Enable autoFreeze, and return frozen state.
2222

2323
#### Defined in
2424

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

2727
***
2828

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

3535
#### Defined in
3636

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

3939
***
4040

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

4848
#### Defined in
4949

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

5252
***
5353

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

6060
#### Defined in
6161

62-
[interface.ts:129](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/interface.ts#L129)
62+
[interface.ts:129](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/interface.ts#L129)

docs/type-aliases/Draft.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
## Defined in
1616

17-
[interface.ts:182](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/interface.ts#L182)
17+
[interface.ts:182](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/interface.ts#L182)

docs/type-aliases/Immutable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
## Defined in
1616

17-
[interface.ts:164](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/interface.ts#L164)
17+
[interface.ts:164](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/interface.ts#L164)

docs/type-aliases/Patch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
## Defined in
1616

17-
[interface.ts:58](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/interface.ts#L58)
17+
[interface.ts:58](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/interface.ts#L58)

docs/type-aliases/Patches.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
## Defined in
1616

17-
[interface.ts:72](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/interface.ts#L72)
17+
[interface.ts:72](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/interface.ts#L72)

docs/type-aliases/PatchesOptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
1111
## Defined in
1212

13-
[interface.ts:18](https://github.com/unadlib/mutative/blob/4e5a64df3bd670123a9179420fc5820dbbf11915/src/interface.ts#L18)
13+
[interface.ts:18](https://github.com/unadlib/mutative/blob/7129237bc42b8475743ffff427a1f8f85e8e1e51/src/interface.ts#L18)

website/docs/advanced-guides/typescript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Mutative support is built into the typescript types. You can use the `Draft<T>`
1010

1111
- `castDraft()`
1212
- `castImmutable()`
13+
- `castMutable()`
1314
- `Draft<T>`
1415
- `Immutable<T>`
1516
- `Patches`

0 commit comments

Comments
 (0)