@typed/async-data 1.0.0-beta.0 → 1.0.0-beta.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/README.md +6 -8
- package/package.json +16 -12
- package/tsconfig.json +0 -6
package/README.md
CHANGED
|
@@ -72,8 +72,8 @@ data.pipe(
|
|
|
72
72
|
Failure: (cause, data) => R3,
|
|
73
73
|
Success: (value, data) => R4,
|
|
74
74
|
Optimistic: (value, data) => R5,
|
|
75
|
-
})
|
|
76
|
-
)
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
Returns a unified result type from the matching branch. Callbacks receive the variant payload (and full variant for `Failure`/`Success`/`Optimistic`).
|
|
@@ -103,21 +103,19 @@ Extract the success value, failure cause, or first error from the variant (or `O
|
|
|
103
103
|
### Transformers
|
|
104
104
|
|
|
105
105
|
```ts
|
|
106
|
-
data.pipe(AsyncData.map((a: A) => B))
|
|
106
|
+
data.pipe(AsyncData.map((a: A) => B));
|
|
107
107
|
```
|
|
108
108
|
|
|
109
109
|
Maps the success/optimistic value; NoData, Loading, and Failure are unchanged.
|
|
110
110
|
|
|
111
111
|
```ts
|
|
112
|
-
data.pipe(
|
|
113
|
-
AsyncData.flatMap((value: A, data: Success<A> | Optimistic<A, E>) => AsyncData<B, E2>)
|
|
114
|
-
)
|
|
112
|
+
data.pipe(AsyncData.flatMap((value: A, data: Success<A> | Optimistic<A, E>) => AsyncData<B, E2>));
|
|
115
113
|
```
|
|
116
114
|
|
|
117
115
|
Chains on success or optimistic; NoData, Loading, and Failure are unchanged.
|
|
118
116
|
|
|
119
117
|
```ts
|
|
120
|
-
data.pipe(AsyncData.mapError((e: E) => E2))
|
|
118
|
+
data.pipe(AsyncData.mapError((e: E) => E2));
|
|
121
119
|
```
|
|
122
120
|
|
|
123
121
|
Maps the failure error type; Success, NoData, Loading unchanged; Optimistic recurs on `previous`.
|
|
@@ -144,7 +142,7 @@ const message = data.pipe(
|
|
|
144
142
|
Failure: (cause) => `error: ${cause}`,
|
|
145
143
|
Success: (user) => `user: ${user.name}`,
|
|
146
144
|
Optimistic: (user) => `optimistic: ${user.name}`,
|
|
147
|
-
})
|
|
145
|
+
}),
|
|
148
146
|
);
|
|
149
147
|
// message === "user: Alice"
|
|
150
148
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typed/async-data",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
4
|
-
"publishConfig": {
|
|
5
|
-
"access": "public"
|
|
6
|
-
},
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
7
4
|
"type": "module",
|
|
8
5
|
"exports": {
|
|
9
6
|
".": {
|
|
@@ -15,15 +12,22 @@
|
|
|
15
12
|
"import": "./dist/*.js"
|
|
16
13
|
}
|
|
17
14
|
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "[ -d dist ] || rm -f tsconfig.tsbuildinfo; tsc",
|
|
20
|
+
"test": "vitest run --passWithNoTests"
|
|
21
|
+
},
|
|
18
22
|
"dependencies": {
|
|
19
|
-
"effect": "
|
|
23
|
+
"effect": "catalog:"
|
|
20
24
|
},
|
|
21
25
|
"devDependencies": {
|
|
22
|
-
"typescript": "
|
|
23
|
-
"vitest": "
|
|
26
|
+
"typescript": "catalog:",
|
|
27
|
+
"vitest": "catalog:"
|
|
24
28
|
},
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
}
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"src"
|
|
32
|
+
]
|
|
33
|
+
}
|