@kaumlaut/pure 0.5.2 → 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](https://github.com/maxkaemmerer/pure-vue-poc/blob/main/pure/docs/README.md)
5
+ - [API Reference](https://github.com/maxkaemmerer/pure/blob/main/docs/README.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaumlaut/pure",
3
- "version": "0.5.2",
3
+ "version": "1.0.1",
4
4
  "description": "Types and 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
  }
package/docs/README.md DELETED
@@ -1,23 +0,0 @@
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 DELETED
@@ -1,45 +0,0 @@
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`
@@ -1,368 +0,0 @@
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)