@pvorona/failable 0.3.0 → 0.4.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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Typed success/failure results for expected failures in TypeScript.
4
4
 
5
- `Failable<T, E>` is a discriminated union of `Success<T>` and `Failure<E>`. In normal application code, return `success(...)` / `failure(...)`, then branch with `result.isSuccess` / `result.isError`. Keep `isSuccess(...)` / `isFailure(...)` for validating hydrated unknown values, and use `isFailableLike(...)` for plain transport shapes.
5
+ `Failable<T, E>` is a discriminated union of `Success<T>` and `Failure<E>`. In normal application code, return `success(...)` / `failure(...)`, then branch with `result.isSuccess` / `result.isError` on that local result. Reserve `isSuccess(...)` / `isFailure(...)` for validating hydrated values that arrive as `unknown`, and use `isFailableLike(...)` for plain transport shapes.
6
6
 
7
7
  ## Install
8
8
 
@@ -35,6 +35,14 @@ if (result.isError) {
35
35
 
36
36
  ## Everyday Usage
37
37
 
38
+ ### Quick chooser
39
+
40
+ - Use `createFailable(() => ...)` when the boundary is synchronous code that might throw.
41
+ - Use `await createFailable(promise)` when the boundary is async code that might reject.
42
+ - Use `run(...)` when each step already returns `Failable` and you want to compose the happy path.
43
+ - Use `throwIfError(result)` when you want to keep using the same `result` variable after narrowing.
44
+ - Use `result.getOrThrow()` when you want the success value itself in expression or return position.
45
+
38
46
  ### Return `success(...)` and `failure(...)`
39
47
 
40
48
  Use the explicit constructors when your function already knows which branch it should return:
@@ -46,9 +54,9 @@ const ok = success({ id: '1' });
46
54
  const err = failure({ code: 'bad_request' });
47
55
  ```
48
56
 
49
- ### Branch and unwrap with instance methods
57
+ ### Branch and unwrap with helpers
50
58
 
51
- Hydrated `Failable` values carry booleans and convenience methods, so everyday code can stay local and direct:
59
+ Hydrated `Failable` values carry booleans and convenience methods. Start with ordinary branching on the result, then pick the helper that matches how you want to unwrap:
52
60
 
53
61
  ```ts
54
62
  import { failure, success } from '@pvorona/failable';
@@ -60,8 +68,7 @@ const portResult = Math.random() > 0.5
60
68
  if (portResult.isError) {
61
69
  console.error(portResult.error);
62
70
  } else {
63
- const requiredPort = portResult.getOrThrow();
64
- console.log(requiredPort);
71
+ console.log(portResult.data);
65
72
  }
66
73
 
67
74
  const port = portResult.getOr(3000);
@@ -72,10 +79,36 @@ console.log(port, ensuredPort.data);
72
79
  - `result.isSuccess` / `result.isError`: branch on a hydrated result
73
80
  - `result.getOr(fallback)`: eagerly get the success value or a fallback
74
81
  - `result.getOrElse(() => fallback)`: lazily compute a fallback value only on failure
75
- - `result.or(fallback)`: eagerly end up with `Success<T>`
76
- - `result.orElse(() => fallback)`: lazily recover to `Success<T>` only on failure
82
+ - `result.or(fallback)`: eagerly recover to a `Success` result
83
+ - `result.orElse(() => fallback)`: lazily recover to a `Success` result only on failure
77
84
  - `result.match(onSuccess, onFailure)`: map both branches to one output type
78
- - `result.getOrThrow()`: unwrap success or throw the failure value
85
+ - `throwIfError(result)`: throw the stored failure unchanged and keep using the same result on success
86
+ - `result.getOrThrow()`: unwrap success as a value or throw the stored failure unchanged
87
+
88
+ Use `throwIfError(result)` when you want to keep the same result variable and continue with narrowed access to `result.data`:
89
+
90
+ ```ts
91
+ import {
92
+ failure,
93
+ success,
94
+ throwIfError,
95
+ type Failable,
96
+ } from '@pvorona/failable';
97
+
98
+ const portResult: Failable<number, string> = Math.random() > 0.5
99
+ ? success(3000)
100
+ : failure('Missing port');
101
+
102
+ throwIfError(portResult);
103
+ console.log(portResult.data);
104
+ ```
105
+
106
+ Use `getOrThrow()` when you want the success value itself in expression or return position:
107
+
108
+ ```ts
109
+ const requiredPort = portResult.getOrThrow();
110
+ console.log(requiredPort);
111
+ ```
79
112
 
80
113
  Use the lazy forms when the fallback is expensive or has side effects:
81
114
 
@@ -117,16 +150,18 @@ const status = portResult.match(
117
150
 
118
151
  ### `createFailable(...)` for throwy or rejecting code
119
152
 
120
- `createFailable(...)` is the convenience entrypoint when you want to capture sync throws, promise rejections, or reuse an existing result shape:
153
+ `createFailable(...)` is the boundary helper for non-`Failable` code. Use it when you need to capture sync throws, promise rejections, or rehydrate an existing result shape. Unlike `run(...)`, it is not for `Failable`-to-`Failable` composition:
121
154
 
122
155
  - `createFailable(failable)` returns the same tagged hydrated instance
123
156
  - `createFailable(failableLike)` rehydrates a strict wire shape into a real `Success` / `Failure`
124
- - `createFailable(() => value)` captures sync throws into `Failure`
125
- - `createFailable(promise)` captures promise rejections into `Failure`
157
+ - `createFailable(() => value)` captures synchronous throws into `Failure`
158
+ - `createFailable(promise)` captures async rejections into `Failure`
126
159
  - If a callback returns, or a promise resolves to, a `Failable` or `FailableLike`, `createFailable(...)` preserves that result instead of nesting it inside `Success`
127
160
 
128
161
  Plain lookalike objects are not treated as hydrated `Failable` instances. If you have plain `{ status, data }` or `{ status, error }` transport data, validate it with `isFailableLike(...)` or pass it to `createFailable(...)` to rehydrate before calling instance methods.
129
162
 
163
+ If a helper already returns `Failable`, branch on it directly or compose it with `run(...)` instead of wrapping it again with `createFailable(...)`.
164
+
130
165
  ```ts
131
166
  import {
132
167
  createFailable,
@@ -150,7 +185,7 @@ const configResult = createFailable(() => JSON.parse(rawConfig));
150
185
  if (configResult.isError) {
151
186
  console.error('Invalid JSON:', configResult.error);
152
187
  } else {
153
- const portResult = createFailable(() => readPort(configResult.data.port));
188
+ const portResult = readPort(configResult.data.port);
154
189
 
155
190
  if (portResult.isError) {
156
191
  console.error(portResult.error.code);
@@ -169,9 +204,81 @@ const responseResult = await createFailable(fetch(url));
169
204
  if (responseResult.isError) console.error(responseResult.error);
170
205
  ```
171
206
 
207
+ `createFailable(() => promise)` is not the supported API. In TypeScript, obviously promise-returning callbacks such as `async () => ...` and `() => Promise.resolve(...)` are rejected. JS callers, plus `any`/`unknown`-typed callbacks, still rely on the runtime guard; those cases stay in the failure channel as an `Error` telling you to pass the promise directly instead. That guard error is preserved even when you pass a custom `normalizeError`.
208
+
209
+ ### `run(...)` for `Failable` composition
210
+
211
+ Use `run(...)` when each step already returns `Failable` and you want the happy path to read top-down. Inside both the sync and async builder forms, use `yield* get(result)` to unwrap success values. The mental model is simple: success values keep flowing forward, and the first yielded `Failure` short-circuits with that same `Failure` instance.
212
+
213
+ ```ts
214
+ import { failure, run, success, type Failable } from '@pvorona/failable';
215
+
216
+ function divide(a: number, b: number): Failable<number, string> {
217
+ if (b === 0) return failure('Cannot divide by zero');
218
+
219
+ return success(a / b);
220
+ }
221
+
222
+ const result = run(function* ({ get }) {
223
+ const first = yield* get(divide(20, 2));
224
+ const second = yield* get(divide(first, 5));
225
+
226
+ return success(second);
227
+ });
228
+
229
+ if (result.isError) {
230
+ console.error(result.error);
231
+ } else {
232
+ console.log(result.data); // 2
233
+ }
234
+ ```
235
+
236
+ Async builders use the same composition pattern. Keep using `yield* get(...)`; do not switch to `await get(...)`:
237
+
238
+ ```ts
239
+ import { failure, run, success, type Failable } from '@pvorona/failable';
240
+
241
+ function divide(a: number, b: number): Failable<number, string> {
242
+ if (b === 0) return failure('Cannot divide by zero');
243
+
244
+ return success(a / b);
245
+ }
246
+
247
+ async function divideAsync(
248
+ a: number,
249
+ b: number,
250
+ ): Promise<Failable<number, string>> {
251
+ return divide(a, b);
252
+ }
253
+
254
+ const result = await run(async function* ({ get }) {
255
+ const first = yield* get(divide(20, 2));
256
+ const second = yield* get(divideAsync(first, 5));
257
+
258
+ return success(second);
259
+ });
260
+
261
+ if (result.isError) {
262
+ console.error(result.error);
263
+ } else {
264
+ console.log(result.data); // 2
265
+ }
266
+ ```
267
+
268
+ Important `run(...)` rules:
269
+
270
+ - Use `run(...)` for `Failable`-to-`Failable` composition. Use `createFailable(...)` when you need to capture sync throws, promise rejections, or rehydrate a `FailableLike`.
271
+ - In async builders, keep using `yield* get(...)`. Do not write `await get(...)`.
272
+ - `get(...)` accepts `Failable` sources in both modes and `PromiseLike<Failable>` sources in async builders only.
273
+ - Use `yield* get(failable)` inside the callback. Other interaction with `get` internals is unsupported and not part of the API contract.
274
+ - `get` exists only inside the generator callback; it is not a public export.
275
+ - Return `success(...)`, `failure(...)`, or another `Failable`. An empty generator or bare `return` becomes `Success<void>`, but raw return values are rejected.
276
+ - Throwing inside the generator is not converted into `Failure`, and rejected promised sources are not converted into `Failure`; foreign exceptions and rejections escape unchanged.
277
+ - Rare cleanup edge cases: cleanup `yield* get(...)` steps unwind before a yielded `Failure` returns, cleanup `Failure`s preserve the original `Failure` while outer `finally` blocks keep unwinding, and promised source rejections still unwind managed cleanup before rejecting. Direct `throw`s inside `finally` are outside that managed cleanup and can replace the in-flight failure or rejection.
278
+
172
279
  ### Use guards for `unknown` values
173
280
 
174
- Use `isFailable(...)`, `isSuccess(...)`, and `isFailure(...)` when you are validating something that might already be a hydrated `Failable` instance:
281
+ Use `isFailable(...)`, `isSuccess(...)`, and `isFailure(...)` when you start from `unknown` and need to validate something that might already be a hydrated `Failable` instance. If you already have a local result from your own code, keep branching with `result.isSuccess` / `result.isError` instead of re-validating it with top-level guards:
175
282
 
176
283
  ```ts
177
284
  import { isFailable } from '@pvorona/failable';
@@ -190,14 +297,21 @@ Use `isSuccess(...)` / `isFailure(...)` when you only care about one branch. If
190
297
  ## Important Semantics
191
298
 
192
299
  - Hydrated `Failable` values are frozen plain objects with methods. Prefer `result.isSuccess` / `result.isError`, and do not use `instanceof`.
300
+ - `run(...)` supports both `function*` and `async function*` builders. In both forms, use `yield* get(...)`; async builders still do not use `await get(...)`.
301
+ - `run(...)` short-circuits on the first yielded failure, preserves that original `Failure` instance unchanged, and enters `finally` cleanup before returning. Cleanup keeps unwinding while cleanup `yield* get(...)` steps succeed. Cleanup `Failure`s preserve the original `Failure` and continue into outer `finally` blocks, while promised cleanup rejections still escape unchanged.
302
+ - In async builders, promised `get(...)` source rejections still escape unchanged after managed `yield* get(...)` cleanup unwinds. Managed cleanup `Failure`s and managed cleanup promise rejections do not replace that original rejection. Direct `throw`s inside `finally` are outside managed cleanup: they still escape unchanged, and they can replace an in-flight yielded `Failure` or main-path rejection.
303
+ - `run(...)` composes existing `Failable` results only. It does not capture thrown values or rejected promises into `Failure`.
193
304
  - `or(...)` and `getOr(...)` are eager. The fallback expression runs before the method call.
194
305
  - `orElse(...)` and `getOrElse(...)` are lazy. The callback runs only on failure.
195
306
  - `match(onSuccess, onFailure)` is useful when both branches should converge to the same output type.
307
+ - `throwIfError(result)` throws `result.error` unchanged on failures and narrows the same hydrated result to `Success<T>` on return.
308
+ - `throwIfError(result)` is deliberately minimal. It does not normalize or map errors; if you want `Error` values, normalize earlier with `createFailable(..., NormalizedErrors)` or a custom `normalizeError`.
196
309
  - `isFailable(...)`, `isSuccess(...)`, and `isFailure(...)` recognize only tagged hydrated instances, not public-shape lookalikes.
197
310
  - `isFailableLike(...)` remains the validator for transport shapes, and `createFailable(failableLike)` is the supported rehydration path before calling instance methods.
311
+ - `createFailable(...)` remains the boundary tool for capture. Use `createFailable(() => ...)` for synchronous throw capture and `await createFailable(promise)` for async rejection capture.
198
312
  - By default, `createFailable(...)` preserves raw thrown and rejected values. If something throws `'boom'`, `{ code: 'bad_request' }`, or `[error1, error2]`, that exact value becomes `.error`.
199
- - `getOrThrow()` throws `result.error` unchanged on failures. If you want `Error` values, opt into normalization.
200
- - `createFailable(async () => value)` is a footgun. The async function itself is treated as a sync return value, so the result is `Success<Promise<T>>`. If you want rejection capture, pass the promise directly: `await createFailable(somePromise)`.
313
+ - `getOrThrow()` returns the success value and throws `result.error` unchanged on failures. Use `throwIfError(result)` when you want control-flow narrowing instead of a returned value.
314
+ - `createFailable(() => ...)` is for genuinely synchronous callbacks. TypeScript rejects obviously promise-returning callbacks, but JS callers and `any`/`unknown`-typed callbacks still rely on the runtime guard. If you already have a promise, pass it directly: `await createFailable(promise)`. That guard error stays actionable even when a custom `normalizeError` is present.
201
315
 
202
316
  ## Normalizing Errors
203
317
 
@@ -219,7 +333,8 @@ if (result.isError) {
219
333
  }
220
334
  ```
221
335
 
222
- The same option also normalizes existing `failure(...)` values and rehydrated `FailableLike` failures.
336
+ The same preset also normalizes existing `failure(...)` values and rehydrated `FailableLike`
337
+ failures, while still passing through existing `Error` instances unchanged.
223
338
 
224
339
  Built-in normalization behaves like this:
225
340
 
@@ -228,6 +343,11 @@ Built-in normalization behaves like this:
228
343
  - other values become `Error`
229
344
  - the original raw value is preserved in `error.cause`
230
345
 
346
+ Custom normalization is different: `normalizeError` runs for failure values, including
347
+ existing `Error` instances, so you can wrap or replace them. The one exception is the
348
+ internal sync-only callback misuse guard error from `createFailable(() => promise)`,
349
+ which is preserved as-is so the actionable message survives.
350
+
231
351
  For custom normalization:
232
352
 
233
353
  ```ts
@@ -235,9 +355,7 @@ import { createFailable } from '@pvorona/failable';
235
355
 
236
356
  const result = createFailable(doThing, {
237
357
  normalizeError(error) {
238
- return error instanceof Error
239
- ? error
240
- : new Error('Operation failed', { cause: error });
358
+ return new Error('Operation failed', { cause: error });
241
359
  },
242
360
  });
243
361
  ```
@@ -263,6 +381,8 @@ const hydrated = createFailable(wire);
263
381
  - `type FailableLike<T, E>`: strict structured-clone-friendly wire shape
264
382
  - `const NormalizedErrors`: built-in token for `Error` normalization
265
383
  - `success(data)` / `failure(error)`: explicit constructors
384
+ - `throwIfError(result)`: throw the stored failure unchanged and narrow the same result on success
385
+ - `run(...)`: compose sync or async `Failable` steps with short-circuiting
266
386
  - `createFailable(...)`: wrap, preserve, rehydrate, or normalize results
267
387
  - `isFailable(...)`, `isSuccess(...)`, `isFailure(...)`: runtime validators for tagged hydrated values
268
388
  - `toFailableLike(...)`: convert a hydrated result into a plain transport shape
package/dist/index.js CHANGED
@@ -1,35 +1,35 @@
1
- import { isFunction as S, isObject as o, hasOwnPropertyValue as F, hasOwnKey as b } from "@pvorona/assert";
2
- import { notImplemented as u } from "@pvorona/not-implemented";
3
- const h = /* @__PURE__ */ Symbol("Failable"), g = /* @__PURE__ */ Symbol("Success"), O = /* @__PURE__ */ Symbol("Failure"), n = Object.freeze({
1
+ import { isFunction as d, isObject as l, hasOwnPropertyValue as b, hasOwnKey as F } from "@pvorona/assert";
2
+ import { notImplemented as i } from "@pvorona/not-implemented";
3
+ const g = /* @__PURE__ */ Symbol("Failable"), A = /* @__PURE__ */ Symbol("Success"), y = /* @__PURE__ */ Symbol("Failure"), u = Object.freeze({
4
4
  Success: "success",
5
5
  Failure: "failure"
6
- }), j = Object.freeze({
6
+ }), k = Object.freeze({
7
7
  mode: "normalized-errors"
8
8
  });
9
- function A(r) {
10
- return o(r) && Object.keys(r).length === 2 && F(r, "status", n.Success) && b(r, "data");
9
+ function P(r) {
10
+ return l(r) && Object.keys(r).length === 2 && b(r, "status", u.Success) && F(r, "data");
11
11
  }
12
- function w(r) {
13
- return o(r) && Object.keys(r).length === 2 && F(r, "status", n.Failure) && b(r, "error");
12
+ function G(r) {
13
+ return l(r) && Object.keys(r).length === 2 && b(r, "status", u.Failure) && F(r, "error");
14
14
  }
15
- function a(r) {
16
- return w(r) || A(r);
15
+ function w(r) {
16
+ return G(r) || P(r);
17
17
  }
18
18
  const m = {
19
- [h]: !0,
19
+ [g]: !0,
20
20
  isSuccess: !1,
21
21
  isError: !1,
22
22
  data: null,
23
23
  error: null,
24
- or: u,
25
- orElse: u,
26
- getOr: u,
27
- getOrElse: u,
28
- getOrThrow: u,
29
- match: u
30
- }, y = (() => {
24
+ or: i,
25
+ orElse: i,
26
+ getOr: i,
27
+ getOrElse: i,
28
+ getOrThrow: i,
29
+ match: i
30
+ }, T = (() => {
31
31
  const r = Object.create(m);
32
- return r[g] = !0, r.status = n.Success, r.isSuccess = !0, r.or = function() {
32
+ return r[A] = !0, r.status = u.Success, r.isSuccess = !0, r.or = function() {
33
33
  return this;
34
34
  }, r.orElse = function() {
35
35
  return this;
@@ -42,90 +42,253 @@ const m = {
42
42
  }, r.match = function(t) {
43
43
  return t(this.data);
44
44
  }, Object.freeze(r);
45
- })(), L = (() => {
45
+ })(), C = (() => {
46
46
  const r = Object.create(m);
47
- return r[O] = !0, r.status = n.Failure, r.isError = !0, r.or = function(t) {
48
- return c(t);
47
+ return r[y] = !0, r.status = u.Failure, r.isError = !0, r.or = function(t) {
48
+ return a(t);
49
49
  }, r.orElse = function(t) {
50
- return c(t());
50
+ return a(t());
51
51
  }, r.getOr = function(t) {
52
52
  return t;
53
53
  }, r.getOrElse = function(t) {
54
54
  return t();
55
55
  }, r.getOrThrow = function() {
56
56
  throw this.error;
57
- }, r.match = function(t, d) {
58
- return d(this.error);
57
+ }, r.match = function(t, n) {
58
+ return n(this.error);
59
59
  }, Object.freeze(r);
60
60
  })();
61
- function f(r, e) {
62
- return o(r) ? r[e] === !0 : !1;
61
+ function h(r, e) {
62
+ return l(r) ? r[e] === !0 : !1;
63
63
  }
64
- function l(r) {
65
- return f(r, h);
64
+ function c(r) {
65
+ return h(r, g);
66
66
  }
67
- function U(r) {
68
- return f(r, g);
67
+ function ur(r) {
68
+ return h(r, A);
69
69
  }
70
- function N(r) {
71
- return f(r, O);
70
+ function or(r) {
71
+ return h(r, y);
72
72
  }
73
- function c(r) {
74
- const e = Object.create(y);
73
+ function a(r) {
74
+ const e = Object.create(T);
75
75
  return e.data = r, Object.freeze(e);
76
76
  }
77
- function i(r) {
78
- const e = Object.create(L);
77
+ function E(r) {
78
+ const e = Object.create(C);
79
79
  return e.error = r, Object.freeze(e);
80
80
  }
81
- function G(r) {
82
- return r.status === n.Failure ? { status: n.Failure, error: r.error } : { status: n.Success, data: r.data };
81
+ function cr(r) {
82
+ if (r.status === u.Failure) throw r.error;
83
83
  }
84
- function R(r, e) {
85
- return l(r) ? s(r, e) : a(r) ? s(E(r), e) : S(r) ? T(r, e) : k(r, e);
84
+ function sr(r) {
85
+ return r.status === u.Failure ? { status: u.Failure, error: r.error } : { status: u.Success, data: r.data };
86
86
  }
87
- function E(r) {
88
- return r.status === n.Success ? c(r.data) : i(r.error);
87
+ const U = "`createFailable(() => ...)` only accepts synchronous callbacks. This callback returned a Promise. Pass the promise directly instead: `await createFailable(promise)`.", R = /* @__PURE__ */ Symbol(
88
+ "CreateFailablePromiseCallbackGuard"
89
+ ), N = /* @__PURE__ */ Symbol("RunGet");
90
+ class s {
91
+ [N] = !0;
92
+ source;
93
+ constructor(e) {
94
+ this.source = e;
95
+ }
96
+ static create(e) {
97
+ return new s(e);
98
+ }
99
+ }
100
+ const f = "`run()` generators must yield only values produced by `get(...)`. Use `yield* get(...)` in normal code.", B = "`run()` generators must return a `Failable` or finish without returning a value.";
101
+ function* x(r) {
102
+ return yield s.create(r);
103
+ }
104
+ async function* D(r) {
105
+ return yield s.create(r);
106
+ }
107
+ function O(r) {
108
+ return !l(r) && !d(r) ? !1 : d(r.then);
109
+ }
110
+ function M(r) {
111
+ return O(r) ? D(r) : x(r);
112
+ }
113
+ const z = Object.freeze({
114
+ get: M
115
+ });
116
+ function I(r) {
117
+ if (!(r instanceof s))
118
+ throw new Error(f);
119
+ const e = r.source;
120
+ if (!c(e))
121
+ throw new Error(f);
122
+ return e;
123
+ }
124
+ async function p(r) {
125
+ if (!(r instanceof s))
126
+ throw new Error(f);
127
+ const e = await r.source;
128
+ if (!c(e))
129
+ throw new Error(f);
130
+ return e;
131
+ }
132
+ async function j(r) {
133
+ if (!(r instanceof s))
134
+ throw new Error(f);
135
+ let e;
136
+ try {
137
+ e = await r.source;
138
+ } catch (t) {
139
+ return { kind: "rejection", rejection: t };
140
+ }
141
+ if (!c(e))
142
+ throw new Error(f);
143
+ return { kind: "source", source: e };
144
+ }
145
+ function v(r, e) {
146
+ let t = r.return(e);
147
+ for (; !t.done; ) {
148
+ const n = I(t.value);
149
+ if (n.status === u.Failure) {
150
+ t = r.return(e);
151
+ continue;
152
+ }
153
+ t = r.next(n.data);
154
+ }
155
+ }
156
+ async function K(r, e) {
157
+ let t = await r.return(e);
158
+ for (; !t.done; ) {
159
+ const n = await p(t.value);
160
+ if (n.status === u.Failure) {
161
+ t = await r.return(e);
162
+ continue;
163
+ }
164
+ t = await r.next(n.data);
165
+ }
166
+ }
167
+ async function V(r) {
168
+ let e = await r.return(void 0);
169
+ for (; !e.done; ) {
170
+ const t = await j(e.value);
171
+ if (t.kind === "rejection") {
172
+ e = await r.return(void 0);
173
+ continue;
174
+ }
175
+ const n = t.source;
176
+ if (n.status === u.Failure) {
177
+ e = await r.return(void 0);
178
+ continue;
179
+ }
180
+ e = await r.next(n.data);
181
+ }
182
+ }
183
+ function _(r) {
184
+ if (c(r))
185
+ return r;
186
+ if (r === void 0)
187
+ return a(void 0);
188
+ throw new Error(B);
189
+ }
190
+ function H(r) {
191
+ return Symbol.asyncIterator in r;
192
+ }
193
+ function W(r) {
194
+ let e = r.next();
195
+ for (; !e.done; ) {
196
+ const t = I(e.value);
197
+ if (t.status === u.Failure)
198
+ return v(r, t), t;
199
+ e = r.next(t.data);
200
+ }
201
+ return _(e.value);
89
202
  }
90
- function T(r, e) {
203
+ async function Y(r) {
204
+ let e = await r.next();
205
+ for (; !e.done; ) {
206
+ const t = await j(e.value);
207
+ if (t.kind === "rejection")
208
+ throw await V(r), t.rejection;
209
+ const n = t.source;
210
+ if (n.status === u.Failure)
211
+ return await K(r, n), n;
212
+ e = await r.next(n.data);
213
+ }
214
+ return _(e.value);
215
+ }
216
+ function ir(r) {
217
+ const e = r(z);
218
+ return H(e) ? Y(e) : W(e);
219
+ }
220
+ function ar(r, e) {
221
+ return c(r) ? o(r, e) : w(r) ? o(S(r), e) : d(r) ? X(r, e) : Z(r, e);
222
+ }
223
+ function S(r) {
224
+ return r.status === u.Success ? a(r.data) : E(r.error);
225
+ }
226
+ function q() {
227
+ const r = new Error(
228
+ U
229
+ );
230
+ return Object.defineProperty(r, R, {
231
+ value: !0,
232
+ enumerable: !1,
233
+ configurable: !1,
234
+ writable: !1
235
+ }), r;
236
+ }
237
+ function J(r) {
238
+ return r instanceof Error ? Object.getOwnPropertyDescriptor(
239
+ r,
240
+ R
241
+ )?.value === !0 : !1;
242
+ }
243
+ function Q(r) {
244
+ Promise.resolve(r).catch(() => {
245
+ });
246
+ }
247
+ function X(r, e) {
91
248
  try {
92
249
  const t = r();
93
- return l(t) ? s(t, e) : a(t) ? s(E(t), e) : c(t);
250
+ return O(t) ? (Q(t), o(
251
+ E(q()),
252
+ e
253
+ )) : c(t) ? o(t, e) : w(t) ? o(S(t), e) : a(t);
94
254
  } catch (t) {
95
- return s(i(t), e);
255
+ return o(E(t), e);
96
256
  }
97
257
  }
98
- function k(r, e) {
258
+ function Z(r, e) {
99
259
  return Promise.resolve(r).then(
100
- (t) => l(t) ? s(t, e) : a(t) ? s(E(t), e) : c(t),
101
- (t) => s(i(t), e)
260
+ (t) => c(t) ? o(t, e) : w(t) ? o(S(t), e) : a(t),
261
+ (t) => o(E(t), e)
102
262
  );
103
263
  }
104
- function s(r, e) {
105
- const t = _(e);
106
- return t === null || r.status === n.Success || r.error instanceof Error ? r : i(t(r.error));
264
+ function o(r, e) {
265
+ if (r.status === u.Success || J(r.error)) return r;
266
+ const t = $(e);
267
+ return t === null || r.error instanceof Error && e !== void 0 && L(e) ? r : E(t(r.error));
107
268
  }
108
- function _(r) {
109
- return r === void 0 ? null : z(r) ? B : I(r) ? r.normalizeError : null;
269
+ function $(r) {
270
+ return r === void 0 ? null : L(r) ? er : rr(r) ? r.normalizeError : null;
110
271
  }
111
- function z(r) {
112
- return !o(r) || Object.keys(r).length !== 1 ? !1 : Object.getOwnPropertyDescriptor(r, "mode")?.value === j.mode;
272
+ function L(r) {
273
+ return !l(r) || Object.keys(r).length !== 1 ? !1 : Object.getOwnPropertyDescriptor(r, "mode")?.value === k.mode;
113
274
  }
114
- function I(r) {
115
- return o(r) ? S(r.normalizeError) : !1;
275
+ function rr(r) {
276
+ return l(r) ? d(r.normalizeError) : !1;
116
277
  }
117
- function B(r) {
278
+ function er(r) {
118
279
  return r instanceof Error ? r : Array.isArray(r) ? new AggregateError(r, "Multiple errors", { cause: r }) : new Error(String(r), { cause: r });
119
280
  }
120
281
  export {
121
- n as FailableStatus,
122
- j as NormalizedErrors,
123
- R as createFailable,
124
- i as failure,
125
- l as isFailable,
126
- a as isFailableLike,
127
- N as isFailure,
128
- U as isSuccess,
129
- c as success,
130
- G as toFailableLike
282
+ u as FailableStatus,
283
+ k as NormalizedErrors,
284
+ ar as createFailable,
285
+ E as failure,
286
+ c as isFailable,
287
+ w as isFailableLike,
288
+ or as isFailure,
289
+ ur as isSuccess,
290
+ ir as run,
291
+ a as success,
292
+ cr as throwIfError,
293
+ sr as toFailableLike
131
294
  };
@@ -11,11 +11,11 @@ export type CreateFailableNormalizeErrorOptions = {
11
11
  };
12
12
  type CreateFailableNormalizeErrorInput = typeof NormalizedErrors | CreateFailableNormalizeErrorOptions;
13
13
  type Match<T, E> = <U>(onSuccess: (data: T) => U, onFailure: (error: E) => U) => U;
14
- export type Failable<T, E> = (Success<T> & {
14
+ export type Failable<T, E> = ((Success<T> & {
15
15
  readonly match: Match<T, E>;
16
16
  }) | (Failure<E> & {
17
17
  readonly match: Match<T, E>;
18
- });
18
+ }));
19
19
  /**
20
20
  * Structured-clone-friendly representation of {@link Failable}.
21
21
  *
@@ -78,12 +78,52 @@ export declare function isSuccess(value: unknown): value is Success<unknown>;
78
78
  export declare function isFailure(value: unknown): value is Failure<unknown>;
79
79
  export declare function success<T = void>(data: T): Success<T>;
80
80
  export declare function failure<E = void>(error: E): Failure<E>;
81
+ /**
82
+ * Throw `result.error` unchanged on failure, or narrow the same result to {@link Success} on return.
83
+ *
84
+ * Use this when you want control-flow narrowing without replacing the original variable.
85
+ * Use `result.getOrThrow()` when you need the success value itself in expression or return position.
86
+ * If you need `Error`-shaped failures, normalize earlier with `createFailable(...)`.
87
+ */
88
+ export declare function throwIfError<T, E>(result: Failable<T, E>): asserts result is Success<T>;
81
89
  export declare function toFailableLike<T>(value: Success<T>): FailableLikeSuccess<T>;
82
90
  export declare function toFailableLike<E>(value: Failure<E>): FailableLikeFailure<E>;
83
91
  export declare function toFailableLike<T, E>(value: Failable<T, E>): FailableLike<T, E>;
84
- type InferReturnTypeFromFunction<F extends () => R, E = unknown, R = ReturnType<F>> = [R] extends [never] ? Failure<E> : R extends Success<infer A> ? Success<A> : R extends Failure<infer A> ? Failure<A> : R extends FailableLikeSuccess<infer A> ? Success<A> : R extends FailableLikeFailure<infer A> ? Failure<A> : R extends Failable<infer A, infer B> ? Failable<A, B> : R extends FailableLike<infer A, infer B> ? Failable<A, B> : Failable<R, E>;
92
+ type InferCreateFailableFromValue<T, E = unknown> = [T] extends [never] ? Failure<E> : T extends Success<infer A> ? Success<A> : T extends Failure<infer A> ? Failure<A> : T extends FailableLikeSuccess<infer A> ? Success<A> : T extends FailableLikeFailure<infer A> ? Failure<A> : T extends Failable<infer A, infer B> ? Failable<A, B> : T extends FailableLike<infer A, infer B> ? Failable<A, B> : Failable<T, E>;
93
+ type IsAny<T> = 0 extends 1 & T ? true : false;
94
+ type HasKnownPromiseLikeReturn<T> = IsAny<T> extends true ? false : unknown extends T ? false : [Extract<T, PromiseLike<unknown>>] extends [never] ? false : true;
95
+ type CreateFailableSyncOnlyCallback<F extends () => unknown> = F & (HasKnownPromiseLikeReturn<ReturnType<F>> extends true ? {
96
+ readonly __createFailablePassPromiseDirectly: never;
97
+ } : unknown);
85
98
  type InferReturnTypeFromPromise<T, E = unknown, P extends PromiseLike<T> = PromiseLike<T>> = [Awaited<P>] extends [never] ? Promise<Failure<E>> : Awaited<P> extends Success<infer A> ? Promise<Success<A>> : Awaited<P> extends Failure<infer A> ? Promise<Failure<A>> : Awaited<P> extends Failable<unknown, unknown> ? Promise<Awaited<P>> : Awaited<P> extends FailableLikeSuccess<infer A> ? Promise<Success<A>> : Awaited<P> extends FailableLikeFailure<infer A> ? Promise<Failure<A>> : Awaited<P> extends FailableLike<infer A, infer B> ? Promise<Failable<A, B>> : Promise<Failable<Awaited<P>, E>>;
86
99
  type NormalizeCreateFailableResult<T> = [T] extends [never] ? Failure<Error> : T extends Success<infer A> ? Success<A> : T extends Failure<unknown> ? Failure<Error> : T extends FailableLikeSuccess<infer A> ? Success<A> : T extends FailableLikeFailure<unknown> ? Failure<Error> : T extends Failable<infer A, unknown> ? Failable<A, Error> : T extends FailableLike<infer A, unknown> ? Failable<A, Error> : Failable<T, Error>;
100
+ declare const RUN_GET_TAG: unique symbol;
101
+ declare class RunGet<T, E, TSource = Failable<T, E>> {
102
+ readonly [RUN_GET_TAG] = true;
103
+ readonly source: TSource;
104
+ private constructor();
105
+ static create<T, E, TSource extends Failable<T, E> | PromiseLike<Failable<T, E>>>(source: TSource): RunGet<T, E, TSource>;
106
+ }
107
+ type RunGetIterator<T, E> = Generator<RunGet<T, E>, T, unknown>;
108
+ type RunHelpers = {
109
+ readonly get: {
110
+ <T>(source: Success<T>): RunGetIterator<T, never>;
111
+ <E>(source: Failure<E>): RunGetIterator<never, E>;
112
+ <T, E>(source: Failable<T, E>): RunGetIterator<T, E>;
113
+ <T>(source: PromiseLike<Success<T>>): AsyncGenerator<RunGet<T, never, unknown>, T, unknown>;
114
+ <E>(source: PromiseLike<Failure<E>>): AsyncGenerator<RunGet<never, E, unknown>, never, unknown>;
115
+ <T, E>(source: PromiseLike<Failable<T, E>>): AsyncGenerator<RunGet<T, E, unknown>, T, unknown>;
116
+ };
117
+ };
118
+ type RunYield = RunGet<unknown, unknown>;
119
+ type RunReturn = void | Success<unknown> | Failure<unknown> | Failable<unknown, unknown>;
120
+ type InferRunYieldError<TYield> = TYield extends RunGet<unknown, infer TError, unknown> ? TError : never;
121
+ type InferRunReturnData<TResult> = TResult extends void ? void : TResult extends Success<infer TData> ? TData : TResult extends Failure<unknown> ? never : TResult extends Failable<infer TData, unknown> ? TData : never;
122
+ type InferRunReturnError<TResult> = TResult extends void ? never : TResult extends Success<unknown> ? never : TResult extends Failure<infer TError> ? TError : TResult extends Failable<unknown, infer TError> ? TError : never;
123
+ type InferRunError<TYield, TResult> = InferRunYieldError<TYield> | InferRunReturnError<TResult>;
124
+ type InferRunResult<TYield, TResult> = [TResult] extends [never] ? [InferRunYieldError<TYield>] extends [never] ? never : Failure<InferRunYieldError<TYield>> : [InferRunReturnData<TResult>] extends [never] ? Failure<InferRunError<TYield, TResult>> : [InferRunError<TYield, TResult>] extends [never] ? Success<InferRunReturnData<TResult>> : Failable<InferRunReturnData<TResult>, InferRunError<TYield, TResult>>;
125
+ export declare function run<TYield extends RunGet<unknown, unknown, unknown> = never, TResult extends RunReturn = RunReturn>(builder: (helpers: RunHelpers) => AsyncGenerator<TYield, TResult, unknown>): Promise<InferRunResult<TYield, TResult>>;
126
+ export declare function run<TYield extends RunYield = never, TResult extends RunReturn = RunReturn>(builder: (helpers: RunHelpers) => Generator<TYield, TResult, unknown>): InferRunResult<TYield, TResult>;
87
127
  export declare function createFailable<T>(value: Success<T>): Success<T>;
88
128
  export declare function createFailable<E>(value: Failure<E>): Failure<E>;
89
129
  export declare function createFailable<T, E>(value: Failable<T, E>): Failable<T, E>;
@@ -96,9 +136,21 @@ export declare function createFailable<T, E>(value: Failable<T, E>, normalizeOpt
96
136
  export declare function createFailable<T>(value: FailableLikeSuccess<T>, normalizeOption: CreateFailableNormalizeErrorInput): Success<T>;
97
137
  export declare function createFailable<E>(value: FailableLikeFailure<E>, normalizeOption: CreateFailableNormalizeErrorInput): Failure<Error>;
98
138
  export declare function createFailable<T, E>(value: FailableLike<T, E>, normalizeOption: CreateFailableNormalizeErrorInput): Failable<T, Error>;
99
- export declare function createFailable<F extends () => R, E = unknown, R = ReturnType<F>>(fun: F): InferReturnTypeFromFunction<F, E, R>;
100
- export declare function createFailable<F extends () => R, R = ReturnType<F>>(fun: F, normalizeOption: CreateFailableNormalizeErrorInput): NormalizeCreateFailableResult<R>;
101
- export declare function createFailable<T, E = unknown, P extends PromiseLike<T> = PromiseLike<T>>(promise: P): InferReturnTypeFromPromise<T, E, P>;
139
+ /**
140
+ * Capture the boundary you actually have:
141
+ * - `createFailable(() => value)` for synchronous callbacks that may throw
142
+ * - `await createFailable(promise)` for promise-based code that may reject
143
+ * - `run(...)` when the steps already return `Failable`
144
+ *
145
+ * In TypeScript, obviously promise-returning callbacks like `async () => ...` and
146
+ * `() => Promise.resolve(...)` are rejected. JS callers, plus `any`/`unknown`-typed
147
+ * callbacks, still rely on the runtime guard and receive a `Failure<Error>` telling
148
+ * them to pass the promise directly instead. That guard error is preserved even when
149
+ * a custom `normalizeError` callback is provided.
150
+ */
102
151
  export declare function createFailable<T, P extends PromiseLike<T> = PromiseLike<T>>(promise: P, normalizeOption: CreateFailableNormalizeErrorInput): Promise<NormalizeCreateFailableResult<Awaited<P>>>;
152
+ export declare function createFailable<T, E = unknown, P extends PromiseLike<T> = PromiseLike<T>>(promise: P): InferReturnTypeFromPromise<T, E, P>;
153
+ export declare function createFailable<F extends () => unknown>(fun: CreateFailableSyncOnlyCallback<F>, normalizeOption: CreateFailableNormalizeErrorInput): NormalizeCreateFailableResult<ReturnType<F>>;
154
+ export declare function createFailable<F extends () => unknown, E = unknown>(fun: CreateFailableSyncOnlyCallback<F>): InferCreateFailableFromValue<ReturnType<F>, E>;
103
155
  export {};
104
156
  //# sourceMappingURL=failable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"failable.d.ts","sourceRoot":"","sources":["../../src/lib/failable.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,cAAc;;;EAGhB,CAAC;AAEZ,MAAM,MAAM,cAAc,GACxB,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAEvD,eAAO,MAAM,gBAAgB;;EAElB,CAAC;AAEZ,MAAM,MAAM,mCAAmC,GAAG;IAChD,QAAQ,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,CAAC;CACpD,CAAC;AAEF,KAAK,iCAAiC,GAClC,OAAO,gBAAgB,GACvB,mCAAmC,CAAC;AAExC,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EACnB,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EACzB,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,KACvB,CAAC,CAAC;AAEP,MAAM,MAAM,QAAQ,CAAC,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AM,OAAO,EACpD,GAAG,EAAE,8BAA8B,CAAC,CAAC,CAAC,EACtC,eAAe,EAAE,iCAAiC,GACjD,6BAA6B,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAChD,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,CAAC,GAAG,OAAO,EACjE,GAAG,EAAE,8BAA8B,CAAC,CAAC,CAAC,GACrC,4BAA4B,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pvorona/failable",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Typed success/failure results for expected failures in TypeScript.",
5
5
  "keywords": [
6
6
  "failable",
@@ -30,14 +30,17 @@
30
30
  "!**/*.tsbuildinfo"
31
31
  ],
32
32
  "scripts": {
33
+ "test-public-api": "vitest run --config vitest.public-surface.config.mts",
34
+ "typecheck-public-api": "tsc --project tests/consumer/tsconfig.json --noEmit",
33
35
  "check-package-surface": "node ./scripts/check-package-surface.mjs",
34
- "prepublishOnly": "npm run check-package-surface"
36
+ "check-public-surface": "npm run test-public-api && npm run typecheck-public-api && npm run check-package-surface",
37
+ "prepublishOnly": "npm exec nx run @pvorona/failable:check-public-surface"
35
38
  },
36
39
  "publishConfig": {
37
40
  "access": "public"
38
41
  },
39
42
  "dependencies": {
40
- "@pvorona/assert": "~0.1.0",
43
+ "@pvorona/assert": "~1.0.0",
41
44
  "@pvorona/not-implemented": "~0.0.1",
42
45
  "@pvorona/types": "^0.0.0"
43
46
  }