@kaumlaut/pure 0.5.0 → 0.5.2

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/README.md CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  Types and functions for a state runtime inspired by Elm and functional programming
4
4
 
5
- - [API Reference](./docs/README.md)
5
+ - [API Reference](https://github.com/maxkaemmerer/pure-vue-poc/blob/main/pure/docs/README.md)
@@ -2,7 +2,7 @@
2
2
  * Provides types and functions to represent fetch request states
3
3
  * @module fetch-state
4
4
  */
5
- import type { Guard } from "@kaumlaut/pure/guard";
5
+ import { type Guard } from "@kaumlaut/pure/guard";
6
6
  /**
7
7
  * Represents a failed fetch request
8
8
  */
@@ -64,11 +64,26 @@ export declare function none(): None;
64
64
  /**
65
65
  * Attempts to create a fetch state of type Success if the given guard passes.
66
66
  * Otherwise creates a fetch state of type Failed with the provided error.
67
+ * @example
68
+ const value = attempt(isString, "Not a String")(3);
69
+ if(isSuccess(value)){
70
+ console.log(value.data)
71
+ } else if (isFailed(value)){
72
+ console.error(value.error)
73
+ }
67
74
  */
68
75
  export declare function attempt<T>(guard: Guard<T>, error?: string): (data: unknown) => Success<T> | Failed;
69
76
  /**
70
77
  * A Utility function that allows to map the Failed fetch state to any other fetch state.
71
78
  * The mapper function is only called if the given fetch state is Failed.
79
+ * @example
80
+ const value = attempt(isString, "Not a String")(3);
81
+ const mappedValue = mapFailed<string>(state => state.error.includes("404") ? fail("Not Found") : state)(value)
82
+ if(isSuccess(mappedValue)){
83
+ console.log(mappedValue.data)
84
+ } else if (isFailed(mappedValue)){
85
+ console.error(mappedValue.error)
86
+ }
72
87
  */
73
88
  export declare function mapFailed<T>(mapper: (state: Failed) => FetchState<T>): (state: FetchState<T>) => FetchState<T>;
74
89
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fetch-state/index.ts"],"names":[],"mappings":"AAAA;;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,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,OAAO,CAEnE;AACD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,MAAM,CAEjE;AACD;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,IAAI,CAE7D;AACD;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAEtE;AACD;;GAEG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAK1C;AACD;;GAEG;AACH,wBAAgB,IAAI,IAAI,OAAO,CAI9B;AACD;;GAEG;AACH,wBAAgB,IAAI,IAAI,IAAI,CAI3B;AACD;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EACf,KAAK,GAAE,MAA6E,GACnF,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAcxC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,GACvC,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAQzC"}
@@ -50,6 +50,13 @@ export function none() {
50
50
  /**
51
51
  * Attempts to create a fetch state of type Success if the given guard passes.
52
52
  * Otherwise creates a fetch state of type Failed with the provided error.
53
+ * @example
54
+ const value = attempt(isString, "Not a String")(3);
55
+ if(isSuccess(value)){
56
+ console.log(value.data)
57
+ } else if (isFailed(value)){
58
+ console.error(value.error)
59
+ }
53
60
  */
54
61
  export function attempt(guard, error = "Guard did not pass. Ensure the attempted data has the correct type") {
55
62
  return (data) => {
@@ -68,6 +75,14 @@ export function attempt(guard, error = "Guard did not pass. Ensure the attempted
68
75
  /**
69
76
  * A Utility function that allows to map the Failed fetch state to any other fetch state.
70
77
  * The mapper function is only called if the given fetch state is Failed.
78
+ * @example
79
+ const value = attempt(isString, "Not a String")(3);
80
+ const mappedValue = mapFailed<string>(state => state.error.includes("404") ? fail("Not Found") : state)(value)
81
+ if(isSuccess(mappedValue)){
82
+ console.log(mappedValue.data)
83
+ } else if (isFailed(mappedValue)){
84
+ console.error(mappedValue.error)
85
+ }
71
86
  */
72
87
  export function mapFailed(mapper) {
73
88
  return (state) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/result/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,EAAW,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,EAAE,CAAC,CAAC,IAAI;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI;IACnB,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AAE1C;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,CAEhE;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,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AAE,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAQxC;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC9B,YAAY,EAAE,CAAC,GACd,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAQ7B;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAE5D"}
package/docs/README.md ADDED
@@ -0,0 +1,23 @@
1
+ **@kaumlaut/pure v0.5.2**
2
+
3
+ ***
4
+
5
+ # @kaumlaut/pure v0.5.2
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.2**](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/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/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/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/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,368 @@
1
+ [**@kaumlaut/pure v0.5.2**](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/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/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/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/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/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/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/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/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/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/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/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/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/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/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/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/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/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/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/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/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/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/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:100](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/fetch-state/index.ts#L100)
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
+ #### Example
159
+
160
+ ```ts
161
+ const value = attempt(isString, "Not a String")(3);
162
+ if(isSuccess(value)){
163
+ console.log(value.data)
164
+ } else if (isFailed(value)){
165
+ console.error(value.error)
166
+ }
167
+ ```
168
+
169
+ ***
170
+
171
+ ### fail()
172
+
173
+ > **fail**(`error`): [`Failed`](#failed)
174
+
175
+ Defined in: [fetch-state/index.ts:67](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/fetch-state/index.ts#L67)
176
+
177
+ Creates a fetch state of type Failed
178
+
179
+ #### Parameters
180
+
181
+ ##### error
182
+
183
+ `string`
184
+
185
+ #### Returns
186
+
187
+ [`Failed`](#failed)
188
+
189
+ ***
190
+
191
+ ### isFailed()
192
+
193
+ > **isFailed**\<`T`\>(`state`): `state is Failed`
194
+
195
+ Defined in: [fetch-state/index.ts:49](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/fetch-state/index.ts#L49)
196
+
197
+ Checks whether or not the fetch state is Failed via a type guard
198
+
199
+ #### Type Parameters
200
+
201
+ ##### T
202
+
203
+ `T`
204
+
205
+ #### Parameters
206
+
207
+ ##### state
208
+
209
+ [`FetchState`](#fetchstate)\<`T`\>
210
+
211
+ #### Returns
212
+
213
+ `state is Failed`
214
+
215
+ ***
216
+
217
+ ### isLoading()
218
+
219
+ > **isLoading**\<`T`\>(`state`): `state is Loading`
220
+
221
+ Defined in: [fetch-state/index.ts:43](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/fetch-state/index.ts#L43)
222
+
223
+ Checks whether or not the fetch state is Loading via a type guard
224
+
225
+ #### Type Parameters
226
+
227
+ ##### T
228
+
229
+ `T`
230
+
231
+ #### Parameters
232
+
233
+ ##### state
234
+
235
+ [`FetchState`](#fetchstate)\<`T`\>
236
+
237
+ #### Returns
238
+
239
+ `state is Loading`
240
+
241
+ ***
242
+
243
+ ### isNone()
244
+
245
+ > **isNone**\<`T`\>(`state`): `state is None`
246
+
247
+ Defined in: [fetch-state/index.ts:55](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/fetch-state/index.ts#L55)
248
+
249
+ Checks whether or not the fetch state is None via a type guard
250
+
251
+ #### Type Parameters
252
+
253
+ ##### T
254
+
255
+ `T`
256
+
257
+ #### Parameters
258
+
259
+ ##### state
260
+
261
+ [`FetchState`](#fetchstate)\<`T`\>
262
+
263
+ #### Returns
264
+
265
+ `state is None`
266
+
267
+ ***
268
+
269
+ ### isSuccess()
270
+
271
+ > **isSuccess**\<`T`\>(`state`): `state is Success<T>`
272
+
273
+ Defined in: [fetch-state/index.ts:61](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/fetch-state/index.ts#L61)
274
+
275
+ Checks whether or not the fetch state is Success via a type guard
276
+
277
+ #### Type Parameters
278
+
279
+ ##### T
280
+
281
+ `T`
282
+
283
+ #### Parameters
284
+
285
+ ##### state
286
+
287
+ [`FetchState`](#fetchstate)\<`T`\>
288
+
289
+ #### Returns
290
+
291
+ `state is Success<T>`
292
+
293
+ ***
294
+
295
+ ### load()
296
+
297
+ > **load**(): [`Loading`](#loading)
298
+
299
+ Defined in: [fetch-state/index.ts:76](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/fetch-state/index.ts#L76)
300
+
301
+ Creates a fetch state of type Loading
302
+
303
+ #### Returns
304
+
305
+ [`Loading`](#loading)
306
+
307
+ ***
308
+
309
+ ### mapFailed()
310
+
311
+ > **mapFailed**\<`T`\>(`mapper`): (`state`) => [`FetchState`](#fetchstate)\<`T`\>
312
+
313
+ Defined in: [fetch-state/index.ts:131](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/fetch-state/index.ts#L131)
314
+
315
+ A Utility function that allows to map the Failed fetch state to any other fetch state.
316
+ The mapper function is only called if the given fetch state is Failed.
317
+
318
+ #### Type Parameters
319
+
320
+ ##### T
321
+
322
+ `T`
323
+
324
+ #### Parameters
325
+
326
+ ##### mapper
327
+
328
+ (`state`) => [`FetchState`](#fetchstate)\<`T`\>
329
+
330
+ #### Returns
331
+
332
+ > (`state`): [`FetchState`](#fetchstate)\<`T`\>
333
+
334
+ ##### Parameters
335
+
336
+ ###### state
337
+
338
+ [`FetchState`](#fetchstate)\<`T`\>
339
+
340
+ ##### Returns
341
+
342
+ [`FetchState`](#fetchstate)\<`T`\>
343
+
344
+ #### Example
345
+
346
+ ```ts
347
+ const value = attempt(isString, "Not a String")(3);
348
+ const mappedValue = mapFailed<string>(state => state.error.includes("404") ? fail("Not Found") : state)(value)
349
+ if(isSuccess(mappedValue)){
350
+ console.log(mappedValue.data)
351
+ } else if (isFailed(mappedValue)){
352
+ console.error(mappedValue.error)
353
+ }
354
+ ```
355
+
356
+ ***
357
+
358
+ ### none()
359
+
360
+ > **none**(): [`None`](#none)
361
+
362
+ Defined in: [fetch-state/index.ts:84](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/fetch-state/index.ts#L84)
363
+
364
+ Creates a fetch state of type None
365
+
366
+ #### Returns
367
+
368
+ [`None`](#none)