unthrown 5.0.0-beta.0 → 5.0.0-beta.10

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 CHANGED
@@ -10,6 +10,9 @@
10
10
  pnpm add unthrown
11
11
  ```
12
12
 
13
+ No peer dependencies — the exhaustive error matcher is built-in and exported as
14
+ `match` / `P`.
15
+
13
16
  ```ts
14
17
  import { fromPromise, P, TaggedError } from "unthrown";
15
18
 
@@ -22,23 +25,29 @@ const user = fromPromise(fetchUser(id), (cause, defect) =>
22
25
 
23
26
  const status = await user.match({
24
27
  ok: () => 200,
25
- err: (matcher) => matcher.with(P._, () => 404), // `err` takes the exhaustive matcher
28
+ // `errCases` takes the exhaustive matcher — every case of E named:
29
+ errCases: (matcher) => matcher.with(P.tag("NotFound"), () => 404),
26
30
  defect: () => 500,
27
31
  });
28
32
  ```
29
33
 
30
34
  - **Errors as values** via `Result<T, E>` / `AsyncResult<T, E>`.
31
35
  - **A separate defect channel** for the unexpected — invisible to the type,
32
- observable only via `match` / `recoverDefect`.
36
+ observable only via `match` / `recoverDefect` and the `tapDefect` /
37
+ `tapFailure` observers.
33
38
  - **Qualification at every boundary** — `fromPromise` / `fromThrowable` force you
34
39
  to triage each failure into a modeled error or a defect.
35
- - **Tagged errors** — `TaggedError(tag)` + `tag(t)`, folded exhaustively through
36
- `match`'s ts-pattern error matcher.
37
- - One tiny runtime dependency (`ts-pattern`), ESM-first, dual CJS/ESM.
40
+ - **Tagged errors** — `TaggedError(tag)` + `P.tag(t)`, folded exhaustively through
41
+ `match`'s built-in error matcher.
42
+ - **Zero runtime dependencies** (the matcher is built-in), ESM-first, dual
43
+ CJS/ESM.
38
44
 
39
45
  See the [full documentation](https://btravstack.github.io/unthrown/) for the guide
40
46
  and complete API.
41
47
 
48
+ **Upgrading from 4.x?** See
49
+ [Upgrade from 4.x to 5.0](https://btravstack.github.io/unthrown/how-to/upgrade-to-v5).
50
+
42
51
  ## License
43
52
 
44
53
  [MIT](https://github.com/btravstack/unthrown/blob/main/LICENSE) © Benoit TRAVERS