@kaumlaut/pure 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/README.md ADDED
@@ -0,0 +1,23 @@
1
+ **@kaumlaut/pure v0.5.1**
2
+
3
+ ***
4
+
5
+ # @kaumlaut/pure v0.5.1
6
+
7
+ ## Modules
8
+
9
+ - [clone](clone.md)
10
+ - [fetch-state](fetch-state.md)
11
+ - [guard](guard.md)
12
+ - [maybe](maybe.md)
13
+ - [parse](parse.md)
14
+ - [pipe](pipe.md)
15
+ - [result](result.md)
16
+ - [runtime](runtime.md)
17
+ - [runtime/effect](runtime/effect.md)
18
+ - [runtime/effect/fetch](runtime/effect/fetch.md)
19
+ - [runtime/effect/none](runtime/effect/none.md)
20
+ - [runtime/persistence](runtime/persistence.md)
21
+ - [runtime/persistence/none](runtime/persistence/none.md)
22
+ - [runtime/persistence/storage](runtime/persistence/storage.md)
23
+ - [util](util.md)
package/docs/clone.md ADDED
@@ -0,0 +1,45 @@
1
+ [**@kaumlaut/pure v0.5.1**](README.md)
2
+
3
+ ***
4
+
5
+ [@kaumlaut/pure](README.md) / clone
6
+
7
+ # clone
8
+
9
+ Provides value cloning capabilities
10
+
11
+ ## Type Aliases
12
+
13
+ ### Cloneable
14
+
15
+ > **Cloneable** = `string` \| `number` \| `boolean` \| `null` \| [`Cloneable`](#cloneable)[] \| \{\[`key`: `string`\]: [`Cloneable`](#cloneable); \}
16
+
17
+ Defined in: [clone/index.ts:9](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/clone/index.ts#L9)
18
+
19
+ Defines the Cloneable type
20
+
21
+ ## Functions
22
+
23
+ ### clone()
24
+
25
+ > **clone**\<`T`\>(`value`): `T`
26
+
27
+ Defined in: [clone/index.ts:20](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/clone/index.ts#L20)
28
+
29
+ Recursively clones values to prevent changing of the original value.
30
+
31
+ #### Type Parameters
32
+
33
+ ##### T
34
+
35
+ `T` *extends* [`Cloneable`](#cloneable)
36
+
37
+ #### Parameters
38
+
39
+ ##### value
40
+
41
+ `T`
42
+
43
+ #### Returns
44
+
45
+ `T`
@@ -0,0 +1,345 @@
1
+ [**@kaumlaut/pure v0.5.1**](README.md)
2
+
3
+ ***
4
+
5
+ [@kaumlaut/pure](README.md) / fetch-state
6
+
7
+ # fetch-state
8
+
9
+ Provides types and functions to represent fetch request states
10
+
11
+ ## Type Aliases
12
+
13
+ ### Failed
14
+
15
+ > **Failed** = `object`
16
+
17
+ Defined in: [fetch-state/index.ts:10](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L10)
18
+
19
+ Represents a failed fetch request
20
+
21
+ #### Properties
22
+
23
+ ##### error
24
+
25
+ > **error**: `Readonly`\<`string`\>
26
+
27
+ Defined in: [fetch-state/index.ts:11](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L11)
28
+
29
+ ##### type
30
+
31
+ > **type**: `"Failed"`
32
+
33
+ Defined in: [fetch-state/index.ts:12](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L12)
34
+
35
+ ***
36
+
37
+ ### FetchState\<T\>
38
+
39
+ > **FetchState**\<`T`\> = [`Failed`](#failed) \| [`None`](#none) \| [`Loading`](#loading) \| [`Success`](#success)\<`T`\>
40
+
41
+ Defined in: [fetch-state/index.ts:39](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L39)
42
+
43
+ Represents all possible states of a fetch request
44
+
45
+ #### Type Parameters
46
+
47
+ ##### T
48
+
49
+ `T`
50
+
51
+ ***
52
+
53
+ ### Loading
54
+
55
+ > **Loading** = `object`
56
+
57
+ Defined in: [fetch-state/index.ts:25](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L25)
58
+
59
+ Represents a fetch request that is currently still running
60
+
61
+ #### Properties
62
+
63
+ ##### type
64
+
65
+ > **type**: `"Loading"`
66
+
67
+ Defined in: [fetch-state/index.ts:26](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L26)
68
+
69
+ ***
70
+
71
+ ### None
72
+
73
+ > **None** = `object`
74
+
75
+ Defined in: [fetch-state/index.ts:18](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L18)
76
+
77
+ Represents a fetch request that has not been executed
78
+
79
+ #### Properties
80
+
81
+ ##### type
82
+
83
+ > **type**: `"None"`
84
+
85
+ Defined in: [fetch-state/index.ts:19](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L19)
86
+
87
+ ***
88
+
89
+ ### Success\<T\>
90
+
91
+ > **Success**\<`T`\> = `object`
92
+
93
+ Defined in: [fetch-state/index.ts:32](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L32)
94
+
95
+ Represents a fetch request that succeeded
96
+
97
+ #### Type Parameters
98
+
99
+ ##### T
100
+
101
+ `T`
102
+
103
+ #### Properties
104
+
105
+ ##### data
106
+
107
+ > **data**: `Readonly`\<`T`\>
108
+
109
+ Defined in: [fetch-state/index.ts:33](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L33)
110
+
111
+ ##### type
112
+
113
+ > **type**: `"Success"`
114
+
115
+ Defined in: [fetch-state/index.ts:34](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L34)
116
+
117
+ ## Functions
118
+
119
+ ### attempt()
120
+
121
+ > **attempt**\<`T`\>(`guard`, `error`): (`data`) => [`Failed`](#failed) \| [`Success`](#success)\<`T`\>
122
+
123
+ Defined in: [fetch-state/index.ts:93](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L93)
124
+
125
+ Attempts to create a fetch state of type Success if the given guard passes.
126
+ Otherwise creates a fetch state of type Failed with the provided error.
127
+
128
+ #### Type Parameters
129
+
130
+ ##### T
131
+
132
+ `T`
133
+
134
+ #### Parameters
135
+
136
+ ##### guard
137
+
138
+ [`Guard`](guard.md#guard)\<`T`\>
139
+
140
+ ##### error
141
+
142
+ `string` = `"Guard did not pass. Ensure the attempted data has the correct type"`
143
+
144
+ #### Returns
145
+
146
+ > (`data`): [`Failed`](#failed) \| [`Success`](#success)\<`T`\>
147
+
148
+ ##### Parameters
149
+
150
+ ###### data
151
+
152
+ `unknown`
153
+
154
+ ##### Returns
155
+
156
+ [`Failed`](#failed) \| [`Success`](#success)\<`T`\>
157
+
158
+ ***
159
+
160
+ ### fail()
161
+
162
+ > **fail**(`error`): [`Failed`](#failed)
163
+
164
+ Defined in: [fetch-state/index.ts:67](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L67)
165
+
166
+ Creates a fetch state of type Failed
167
+
168
+ #### Parameters
169
+
170
+ ##### error
171
+
172
+ `string`
173
+
174
+ #### Returns
175
+
176
+ [`Failed`](#failed)
177
+
178
+ ***
179
+
180
+ ### isFailed()
181
+
182
+ > **isFailed**\<`T`\>(`state`): `state is Failed`
183
+
184
+ Defined in: [fetch-state/index.ts:49](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L49)
185
+
186
+ Checks whether or not the fetch state is Failed via a type guard
187
+
188
+ #### Type Parameters
189
+
190
+ ##### T
191
+
192
+ `T`
193
+
194
+ #### Parameters
195
+
196
+ ##### state
197
+
198
+ [`FetchState`](#fetchstate)\<`T`\>
199
+
200
+ #### Returns
201
+
202
+ `state is Failed`
203
+
204
+ ***
205
+
206
+ ### isLoading()
207
+
208
+ > **isLoading**\<`T`\>(`state`): `state is Loading`
209
+
210
+ Defined in: [fetch-state/index.ts:43](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L43)
211
+
212
+ Checks whether or not the fetch state is Loading via a type guard
213
+
214
+ #### Type Parameters
215
+
216
+ ##### T
217
+
218
+ `T`
219
+
220
+ #### Parameters
221
+
222
+ ##### state
223
+
224
+ [`FetchState`](#fetchstate)\<`T`\>
225
+
226
+ #### Returns
227
+
228
+ `state is Loading`
229
+
230
+ ***
231
+
232
+ ### isNone()
233
+
234
+ > **isNone**\<`T`\>(`state`): `state is None`
235
+
236
+ Defined in: [fetch-state/index.ts:55](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L55)
237
+
238
+ Checks whether or not the fetch state is None via a type guard
239
+
240
+ #### Type Parameters
241
+
242
+ ##### T
243
+
244
+ `T`
245
+
246
+ #### Parameters
247
+
248
+ ##### state
249
+
250
+ [`FetchState`](#fetchstate)\<`T`\>
251
+
252
+ #### Returns
253
+
254
+ `state is None`
255
+
256
+ ***
257
+
258
+ ### isSuccess()
259
+
260
+ > **isSuccess**\<`T`\>(`state`): `state is Success<T>`
261
+
262
+ Defined in: [fetch-state/index.ts:61](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L61)
263
+
264
+ Checks whether or not the fetch state is Success via a type guard
265
+
266
+ #### Type Parameters
267
+
268
+ ##### T
269
+
270
+ `T`
271
+
272
+ #### Parameters
273
+
274
+ ##### state
275
+
276
+ [`FetchState`](#fetchstate)\<`T`\>
277
+
278
+ #### Returns
279
+
280
+ `state is Success<T>`
281
+
282
+ ***
283
+
284
+ ### load()
285
+
286
+ > **load**(): [`Loading`](#loading)
287
+
288
+ Defined in: [fetch-state/index.ts:76](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L76)
289
+
290
+ Creates a fetch state of type Loading
291
+
292
+ #### Returns
293
+
294
+ [`Loading`](#loading)
295
+
296
+ ***
297
+
298
+ ### mapFailed()
299
+
300
+ > **mapFailed**\<`T`\>(`mapper`): (`state`) => [`FetchState`](#fetchstate)\<`T`\>
301
+
302
+ Defined in: [fetch-state/index.ts:115](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L115)
303
+
304
+ A Utility function that allows to map the Failed fetch state to any other fetch state.
305
+ The mapper function is only called if the given fetch state is Failed.
306
+
307
+ #### Type Parameters
308
+
309
+ ##### T
310
+
311
+ `T`
312
+
313
+ #### Parameters
314
+
315
+ ##### mapper
316
+
317
+ (`state`) => [`FetchState`](#fetchstate)\<`T`\>
318
+
319
+ #### Returns
320
+
321
+ > (`state`): [`FetchState`](#fetchstate)\<`T`\>
322
+
323
+ ##### Parameters
324
+
325
+ ###### state
326
+
327
+ [`FetchState`](#fetchstate)\<`T`\>
328
+
329
+ ##### Returns
330
+
331
+ [`FetchState`](#fetchstate)\<`T`\>
332
+
333
+ ***
334
+
335
+ ### none()
336
+
337
+ > **none**(): [`None`](#none)
338
+
339
+ Defined in: [fetch-state/index.ts:84](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/fetch-state/index.ts#L84)
340
+
341
+ Creates a fetch state of type None
342
+
343
+ #### Returns
344
+
345
+ [`None`](#none)