@kaumlaut/pure 0.5.1 → 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Max Kämmerer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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/blob/main/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;;;GAGG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxB,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IACvB,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAClB,IAAI,EAAE,SAAS,CAA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ACD;;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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functions for a state runtime inspired by Elm and functional programming",
5
5
  "author": "Max Kaemmerer",
6
6
  "license": "MIT",
@@ -8,6 +8,10 @@
8
8
  "types": "dist/index.d.ts",
9
9
  "type": "module",
10
10
  "module": "dist/index.js",
11
+ "repository": {
12
+ "url": "git+https://github.com/maxkaemmerer/pure.git",
13
+ "type": "git"
14
+ },
11
15
  "exports": {
12
16
  "./*": {
13
17
  "import": "./dist/*/index.js",
@@ -16,7 +20,6 @@
16
20
  },
17
21
  "files": [
18
22
  "dist",
19
- "docs",
20
23
  "README.md"
21
24
  ],
22
25
  "scripts": {
@@ -25,10 +28,12 @@
25
28
  "lint": "eslint -c eslint.config.js --fix",
26
29
  "format": "prettier . --write",
27
30
  "test": "vitest",
28
- "release": "npm run docs && npm run build && npm publish --access public"
31
+ "release-minor": "npm run docs && npm run build && git add ./docs && git commit -m 'update docs' && npm version minor && git push --tags && npm publish --access public",
32
+ "release-patch": "npm run docs && npm run build && git add ./docs && git commit -m 'update docs' && npm version patch && git push --tags && npm publish --access public",
33
+ "release-major": "npm run docs && npm run build && git add ./docs && git commit -m 'update docs' && npm version major && git push --tags && npm publish --access public"
29
34
  },
30
35
  "devDependencies": {
31
- "@eslint/js": "^9.22.0",
36
+ "@eslint/js": "^9.24.0",
32
37
  "@types/node": "^24.3.0",
33
38
  "eslint": "^9.22.0",
34
39
  "globals": "^16.0.0",
@@ -38,5 +43,8 @@
38
43
  "typescript": "^5.8.2",
39
44
  "typescript-eslint": "^8.26.1",
40
45
  "vitest": "^3.0.8"
46
+ },
47
+ "dependencies": {
48
+ "vite-tsconfig-paths": "^5.1.4"
41
49
  }
42
50
  }
@@ -1,5 +0,0 @@
1
- import { Persistence } from "@kaumlaut/pure/runtime/persistence";
2
- import { Message } from "@kaumlaut/pure/runtime";
3
- import { Cloneable } from "@kaumlaut/pure/clone";
4
- export declare const localStoragePersistence: <Model extends Cloneable, CustomMessage extends Message>(name: string) => Persistence<Model, CustomMessage>;
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/runtime/persistence/localStorage/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAChE,OAAO,EAAE,OAAO,EAAQ,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAIhD,eAAO,MAAM,uBAAuB,GAAI,KAAK,SAAS,SAAS,EAAE,aAAa,SAAS,OAAO,EAC5F,MAAM,MAAM,KACX,WAAW,CAAC,KAAK,EAAE,aAAa,CAwBjC,CAAA"}
@@ -1,25 +0,0 @@
1
- import { ok, err } from "@kaumlaut/pure/result";
2
- import { just, nothing } from "@kaumlaut/pure/maybe";
3
- export const localStoragePersistence = (name) => ({
4
- persist(model) {
5
- window.localStorage.setItem(name, btoa(JSON.stringify(model)));
6
- },
7
- read(guard, init) {
8
- const record = window.localStorage.getItem(name);
9
- if (record === null) {
10
- return ok(init(nothing())[0]);
11
- }
12
- try {
13
- const json = atob(record);
14
- const model = JSON.parse(json);
15
- if (guard(model)) {
16
- return ok(init(just(model))[0]);
17
- }
18
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
- }
20
- catch (e) {
21
- return err('Could not decode stored model');
22
- }
23
- return err('Your guard did not match the retrieved model');
24
- },
25
- });
package/docs/README.md DELETED
@@ -1,23 +0,0 @@
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 DELETED
@@ -1,45 +0,0 @@
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`
@@ -1,345 +0,0 @@
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)