@kaumlaut/pure 0.5.1 → 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 +1 -1
- package/dist/fetch-state/index.d.ts +16 -1
- package/dist/fetch-state/index.d.ts.map +1 -1
- package/dist/fetch-state/index.js +15 -0
- package/dist/result/index.d.ts.map +1 -1
- package/docs/README.md +2 -2
- package/docs/clone.md +3 -3
- package/docs/fetch-state.md +44 -21
- package/docs/guard.md +25 -25
- package/docs/maybe.md +20 -20
- package/docs/parse.md +3 -3
- package/docs/pipe.md +5 -5
- package/docs/result.md +16 -16
- package/docs/runtime/effect/fetch.md +12 -12
- package/docs/runtime/effect/none.md +2 -2
- package/docs/runtime/effect.md +12 -12
- package/docs/runtime/persistence/none.md +2 -2
- package/docs/runtime/persistence/storage.md +2 -2
- package/docs/runtime/persistence.md +4 -4
- package/docs/runtime.md +9 -9
- package/docs/util.md +2 -2
- package/package.json +1 -1
- package/dist/runtime/persistence/localStorage/index.d.ts +0 -5
- package/dist/runtime/persistence/localStorage/index.d.ts.map +0 -1
- package/dist/runtime/persistence/localStorage/index.js +0 -25
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**@kaumlaut/pure v0.5.
|
|
1
|
+
[**@kaumlaut/pure v0.5.2**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
> **Persistence**\<`Model`, `CustomMessage`\> = `object`
|
|
14
14
|
|
|
15
|
-
Defined in: [runtime/persistence/index.ts:6](https://github.com/maxkaemmerer/pure-vue-poc/blob/
|
|
15
|
+
Defined in: [runtime/persistence/index.ts:6](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/runtime/persistence/index.ts#L6)
|
|
16
16
|
|
|
17
17
|
#### Type Parameters
|
|
18
18
|
|
|
@@ -30,7 +30,7 @@ Defined in: [runtime/persistence/index.ts:6](https://github.com/maxkaemmerer/pur
|
|
|
30
30
|
|
|
31
31
|
> **persist**(`model`): `void`
|
|
32
32
|
|
|
33
|
-
Defined in: [runtime/persistence/index.ts:10](https://github.com/maxkaemmerer/pure-vue-poc/blob/
|
|
33
|
+
Defined in: [runtime/persistence/index.ts:10](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/runtime/persistence/index.ts#L10)
|
|
34
34
|
|
|
35
35
|
###### Parameters
|
|
36
36
|
|
|
@@ -46,7 +46,7 @@ Defined in: [runtime/persistence/index.ts:10](https://github.com/maxkaemmerer/pu
|
|
|
46
46
|
|
|
47
47
|
> **read**(`guard`, `init`): [`Result`](../result.md#result)\<`Model`, `string`\>
|
|
48
48
|
|
|
49
|
-
Defined in: [runtime/persistence/index.ts:11](https://github.com/maxkaemmerer/pure-vue-poc/blob/
|
|
49
|
+
Defined in: [runtime/persistence/index.ts:11](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/runtime/persistence/index.ts#L11)
|
|
50
50
|
|
|
51
51
|
###### Parameters
|
|
52
52
|
|
package/docs/runtime.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**@kaumlaut/pure v0.5.
|
|
1
|
+
[**@kaumlaut/pure v0.5.2**](README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
> **Change**\<`CustomMessage`, `Model`\> = \[`CustomMessage` \| `null`, `Model`, \{ `meta`: `object` \| `null`; `name`: `string`; \} \| `null`\]
|
|
14
14
|
|
|
15
|
-
Defined in: [runtime/index.ts:20](https://github.com/maxkaemmerer/pure-vue-poc/blob/
|
|
15
|
+
Defined in: [runtime/index.ts:20](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/runtime/index.ts#L20)
|
|
16
16
|
|
|
17
17
|
#### Type Parameters
|
|
18
18
|
|
|
@@ -30,7 +30,7 @@ Defined in: [runtime/index.ts:20](https://github.com/maxkaemmerer/pure-vue-poc/b
|
|
|
30
30
|
|
|
31
31
|
> **Changes**\<`CustomMessage`, `Model`\> = [`Change`](#change)\<`CustomMessage`, `Model`\>[]
|
|
32
32
|
|
|
33
|
-
Defined in: [runtime/index.ts:29](https://github.com/maxkaemmerer/pure-vue-poc/blob/
|
|
33
|
+
Defined in: [runtime/index.ts:29](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/runtime/index.ts#L29)
|
|
34
34
|
|
|
35
35
|
#### Type Parameters
|
|
36
36
|
|
|
@@ -48,7 +48,7 @@ Defined in: [runtime/index.ts:29](https://github.com/maxkaemmerer/pure-vue-poc/b
|
|
|
48
48
|
|
|
49
49
|
> **Init**\<`Model`, `CustomMessage`\> = (`persistedModel`) => \[`Model`, [`Effect`](runtime/effect.md#effect)\<`CustomMessage`\>\]
|
|
50
50
|
|
|
51
|
-
Defined in: [runtime/index.ts:16](https://github.com/maxkaemmerer/pure-vue-poc/blob/
|
|
51
|
+
Defined in: [runtime/index.ts:16](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/runtime/index.ts#L16)
|
|
52
52
|
|
|
53
53
|
#### Type Parameters
|
|
54
54
|
|
|
@@ -76,7 +76,7 @@ Defined in: [runtime/index.ts:16](https://github.com/maxkaemmerer/pure-vue-poc/b
|
|
|
76
76
|
|
|
77
77
|
> **Message**\<`N`, `T`\> = `object`
|
|
78
78
|
|
|
79
|
-
Defined in: [runtime/index.ts:6](https://github.com/maxkaemmerer/pure-vue-poc/blob/
|
|
79
|
+
Defined in: [runtime/index.ts:6](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/runtime/index.ts#L6)
|
|
80
80
|
|
|
81
81
|
#### Type Parameters
|
|
82
82
|
|
|
@@ -94,13 +94,13 @@ Defined in: [runtime/index.ts:6](https://github.com/maxkaemmerer/pure-vue-poc/bl
|
|
|
94
94
|
|
|
95
95
|
> **name**: `N`
|
|
96
96
|
|
|
97
|
-
Defined in: [runtime/index.ts:8](https://github.com/maxkaemmerer/pure-vue-poc/blob/
|
|
97
|
+
Defined in: [runtime/index.ts:8](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/runtime/index.ts#L8)
|
|
98
98
|
|
|
99
99
|
##### value
|
|
100
100
|
|
|
101
101
|
> **value**: `T`
|
|
102
102
|
|
|
103
|
-
Defined in: [runtime/index.ts:7](https://github.com/maxkaemmerer/pure-vue-poc/blob/
|
|
103
|
+
Defined in: [runtime/index.ts:7](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/runtime/index.ts#L7)
|
|
104
104
|
|
|
105
105
|
***
|
|
106
106
|
|
|
@@ -108,7 +108,7 @@ Defined in: [runtime/index.ts:7](https://github.com/maxkaemmerer/pure-vue-poc/bl
|
|
|
108
108
|
|
|
109
109
|
> **Update**\<`Model`, `CustomMessage`\> = (`model`, `msg`) => \[`Model`, [`Effect`](runtime/effect.md#effect)\<`CustomMessage`\>\]
|
|
110
110
|
|
|
111
|
-
Defined in: [runtime/index.ts:11](https://github.com/maxkaemmerer/pure-vue-poc/blob/
|
|
111
|
+
Defined in: [runtime/index.ts:11](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/runtime/index.ts#L11)
|
|
112
112
|
|
|
113
113
|
#### Type Parameters
|
|
114
114
|
|
|
@@ -140,7 +140,7 @@ Defined in: [runtime/index.ts:11](https://github.com/maxkaemmerer/pure-vue-poc/b
|
|
|
140
140
|
|
|
141
141
|
> **is**\<`CustomMessage`, `A`\>(`name`, `message`): `message is CustomMessage`
|
|
142
142
|
|
|
143
|
-
Defined in: [runtime/index.ts:34](https://github.com/maxkaemmerer/pure-vue-poc/blob/
|
|
143
|
+
Defined in: [runtime/index.ts:34](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/runtime/index.ts#L34)
|
|
144
144
|
|
|
145
145
|
#### Type Parameters
|
|
146
146
|
|
package/docs/util.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**@kaumlaut/pure v0.5.
|
|
1
|
+
[**@kaumlaut/pure v0.5.2**](README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
> **id**\<`T`\>(`value`): `T`
|
|
14
14
|
|
|
15
|
-
Defined in: [util/index.ts:4](https://github.com/maxkaemmerer/pure-vue-poc/blob/
|
|
15
|
+
Defined in: [util/index.ts:4](https://github.com/maxkaemmerer/pure-vue-poc/blob/1f00f47d2f3c329e3dda9a01eb5ed8ebf93253d3/pure/src/util/index.ts#L4)
|
|
16
16
|
|
|
17
17
|
Returns the given value.
|
|
18
18
|
|
package/package.json
CHANGED
|
@@ -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
|
-
});
|