@nlozgachev/pipelined 0.66.0 → 0.67.0
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 +18 -5
- package/dist/{Core-D7_9dZpV.mjs → Core-BCN6WRzp.mjs} +761 -419
- package/dist/{Core-6SkC-fh5.cjs → Core-CfAL_21H.cjs} +761 -419
- package/dist/{InternalTypes-DzDey5Do.d.ts → InternalTypes-C0F5jyVQ.d.ts} +1 -1
- package/dist/{InternalTypes-B1Lh9uw_.d.cts → InternalTypes-DxSlzrpu.d.cts} +1 -1
- package/dist/composition.d.cts +2 -2
- package/dist/composition.d.ts +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.mjs +1 -1
- package/dist/data.cjs +991 -527
- package/dist/data.d.cts +479 -308
- package/dist/data.d.ts +479 -308
- package/dist/data.mjs +991 -527
- package/dist/{index-Bs8En5LJ.d.cts → index-CTe9CCHY.d.cts} +3 -0
- package/dist/{index-Bs8En5LJ.d.ts → index-CTe9CCHY.d.ts} +3 -0
- package/dist/{index-8A9NqJTq.d.cts → index-CdzHrj62.d.ts} +609 -298
- package/dist/{index-CY4ZLbjM.d.ts → index-NYjtX7XS.d.cts} +609 -298
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/types.cjs +5 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.mjs +5 -1
- package/package.json +20 -19
package/README.md
CHANGED
|
@@ -205,6 +205,19 @@ if (Validation.is.failed(outcome)) {
|
|
|
205
205
|
console.log(outcome.errors);
|
|
206
206
|
// ["Username must be at least 3 characters", "Email must contain an @ symbol"]
|
|
207
207
|
}
|
|
208
|
+
|
|
209
|
+
// Or keep errors partitioned per field for UI forms:
|
|
210
|
+
const validateForm = Validation.keyed.make({
|
|
211
|
+
username: validateUsername,
|
|
212
|
+
email: validateEmail,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
const formState = validateForm({ username: "a", email: "invalid" });
|
|
216
|
+
|
|
217
|
+
if (Validation.keyed.is.failed(formState)) {
|
|
218
|
+
const errors = Validation.keyed.getErrors(formState);
|
|
219
|
+
// Some({ username: ["Username must be at least 3 characters"], email: ["Email must contain an @ symbol"] })
|
|
220
|
+
}
|
|
208
221
|
```
|
|
209
222
|
|
|
210
223
|
### Eliminating impossible UI states
|
|
@@ -287,7 +300,7 @@ const fetchUser = Op.interpret(
|
|
|
287
300
|
Op.create(
|
|
288
301
|
(signal) => (id: string) =>
|
|
289
302
|
fetch(`/users/${id}`, { signal }).then((r) => r.json() as Promise<User>),
|
|
290
|
-
(e) => new ApiError(e),
|
|
303
|
+
{ onError: (e) => new ApiError(e) },
|
|
291
304
|
),
|
|
292
305
|
{
|
|
293
306
|
strategy: "restartable",
|
|
@@ -334,7 +347,7 @@ const searchOp = Op.create(
|
|
|
334
347
|
fetch(`/search?q=${query}`, { signal }).then((r) =>
|
|
335
348
|
r.json() as Promise<SearchResult[]>
|
|
336
349
|
),
|
|
337
|
-
(e) => new SearchError(e),
|
|
350
|
+
{ onError: (e) => new SearchError(e) },
|
|
338
351
|
);
|
|
339
352
|
|
|
340
353
|
const search = Op.interpret(searchOp, {
|
|
@@ -360,7 +373,7 @@ const submitOp = Op.create(
|
|
|
360
373
|
fetch("/orders", { method: "POST", body: data, signal }).then((r) =>
|
|
361
374
|
r.json()
|
|
362
375
|
),
|
|
363
|
-
(e) => new ApiError(e),
|
|
376
|
+
{ onError: (e) => new ApiError(e) },
|
|
364
377
|
);
|
|
365
378
|
|
|
366
379
|
const submit = Op.interpret(submitOp, {
|
|
@@ -552,11 +565,11 @@ if (Result.is.ok(email)) {
|
|
|
552
565
|
- **`@nlozgachev/pipelined/core`**: Core context containers, async runtimes, optics, and logic
|
|
553
566
|
abstractions (<11 KB gzipped).
|
|
554
567
|
- **`@nlozgachev/pipelined/data`**: Curried, data-last utilities for collections, numbers, strings,
|
|
555
|
-
and JSON (<
|
|
568
|
+
and JSON (<10 KB gzipped).
|
|
556
569
|
- **`@nlozgachev/pipelined/composition`**: Pure higher-order function combinators (`pipe`, `flow`,
|
|
557
570
|
`compose`, `curry`, `uncurry`, `converge`, `juxt`, `memoize`, `tap`, `on`, `not`, `flip`, `fn`)
|
|
558
571
|
(<2 KB gzipped).
|
|
559
|
-
- **`@nlozgachev/pipelined/types`**: Type-level utilities (`Brand`, `Duration`, `RetryPolicy`) (<
|
|
572
|
+
- **`@nlozgachev/pipelined/types`**: Type-level utilities (`Brand`, `Duration`, `RetryPolicy`) (<450
|
|
560
573
|
B gzipped).
|
|
561
574
|
|
|
562
575
|
Every utility in the library is benchmarked against its native equivalent. While currying introduces
|