unthrown 0.1.0 → 0.3.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/dist/index.cjs +176 -24
- package/dist/index.d.cts +167 -22
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +167 -22
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +174 -25
- package/dist/index.mjs.map +1 -1
- package/docs/index.md +299 -95
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -57,6 +57,15 @@ var Res = class {
|
|
|
57
57
|
return defectRes(cause);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
+
flatTap(f) {
|
|
61
|
+
if (this.tag !== "Ok") return this;
|
|
62
|
+
try {
|
|
63
|
+
const r = f(this.value);
|
|
64
|
+
return r.tag === "Ok" ? this : r;
|
|
65
|
+
} catch (cause) {
|
|
66
|
+
return defectRes(cause);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
60
69
|
as(value) {
|
|
61
70
|
if (this.tag !== "Ok") return this;
|
|
62
71
|
return okRes(value);
|
|
@@ -244,6 +253,17 @@ var AsyncRes = class AsyncRes {
|
|
|
244
253
|
}
|
|
245
254
|
}));
|
|
246
255
|
}
|
|
256
|
+
flatTap(f) {
|
|
257
|
+
return new AsyncRes(this.promise.then(async (r) => {
|
|
258
|
+
if (r.tag !== "Ok") return r;
|
|
259
|
+
try {
|
|
260
|
+
const inner = await f(r.value);
|
|
261
|
+
return inner.tag === "Ok" ? r : inner;
|
|
262
|
+
} catch (cause) {
|
|
263
|
+
return defectRes(cause);
|
|
264
|
+
}
|
|
265
|
+
}));
|
|
266
|
+
}
|
|
247
267
|
as(value) {
|
|
248
268
|
return new AsyncRes(this.promise.then((r) => r.tag === "Ok" ? okRes(value) : r));
|
|
249
269
|
}
|
|
@@ -466,9 +486,16 @@ function fromNullable(value, onAbsent) {
|
|
|
466
486
|
* {@link Defect} (via {@link defect}) — there is no path that leaves `unknown`
|
|
467
487
|
* in `E`. A throw inside `qualify` itself is treated as a `Defect`.
|
|
468
488
|
*
|
|
489
|
+
* The modeled error type is `Exclude<R, Defect>` — the `Defect` arm of
|
|
490
|
+
* `qualify`'s return is **subtracted** from `E`, never inferred into it. So a
|
|
491
|
+
* `qualify` that returns *only* `defect(cause)` yields `E = never` (a defect is
|
|
492
|
+
* out-of-band and must not pollute the error channel); reach for
|
|
493
|
+
* {@link fromSafePromise} when every failure is a defect.
|
|
494
|
+
*
|
|
469
495
|
* @typeParam A - the wrapped function's argument tuple.
|
|
470
496
|
* @typeParam T - the wrapped function's return type.
|
|
471
|
-
* @typeParam
|
|
497
|
+
* @typeParam R - `qualify`'s return type; the modeled error `E` is
|
|
498
|
+
* `Exclude<R, Defect>` (its `Defect` arm, if any, is subtracted).
|
|
472
499
|
* @param fn - the throwing function to wrap.
|
|
473
500
|
* @param qualify - triages a thrown cause into `E` or a `Defect`.
|
|
474
501
|
* @returns a function with the same arguments returning `Result<T, E>`.
|
|
@@ -481,11 +508,12 @@ function fromNullable(value, onAbsent) {
|
|
|
481
508
|
* ```
|
|
482
509
|
*/
|
|
483
510
|
function fromThrowable(fn, qualify) {
|
|
511
|
+
const triage = qualify;
|
|
484
512
|
return (...args) => {
|
|
485
513
|
try {
|
|
486
514
|
return ok(fn(...args));
|
|
487
515
|
} catch (cause) {
|
|
488
|
-
return qualifyToResult(cause,
|
|
516
|
+
return qualifyToResult(cause, triage);
|
|
489
517
|
}
|
|
490
518
|
};
|
|
491
519
|
}
|
|
@@ -499,8 +527,14 @@ function fromThrowable(fn, qualify) {
|
|
|
499
527
|
* `await`-ing it always yields a `Result`. A throw inside `qualify` is itself a
|
|
500
528
|
* `Defect`.
|
|
501
529
|
*
|
|
530
|
+
* The modeled error type is `Exclude<R, Defect>` — the `Defect` arm of
|
|
531
|
+
* `qualify`'s return is **subtracted** from `E`, never inferred into it. So a
|
|
532
|
+
* `qualify` that returns *only* `defect(cause)` yields `E = never`; when every
|
|
533
|
+
* rejection is a defect, prefer {@link fromSafePromise}.
|
|
534
|
+
*
|
|
502
535
|
* @typeParam T - the resolved value type.
|
|
503
|
-
* @typeParam
|
|
536
|
+
* @typeParam R - `qualify`'s return type; the modeled error `E` is
|
|
537
|
+
* `Exclude<R, Defect>` (its `Defect` arm, if any, is subtracted).
|
|
504
538
|
* @param promise - the promise, or a thunk returning one.
|
|
505
539
|
* @param qualify - triages a rejection cause into `E` or a `Defect`.
|
|
506
540
|
*
|
|
@@ -513,7 +547,8 @@ function fromThrowable(fn, qualify) {
|
|
|
513
547
|
* ```
|
|
514
548
|
*/
|
|
515
549
|
function fromPromise(promise, qualify) {
|
|
516
|
-
|
|
550
|
+
const triage = qualify;
|
|
551
|
+
return new AsyncRes((typeof promise === "function" ? Promise.resolve().then(promise) : promise).then((value) => okRes(value), (cause) => qualifyToResult(cause, triage)));
|
|
517
552
|
}
|
|
518
553
|
/**
|
|
519
554
|
* Wrap a `Promise` asserted **not** to fail in any modeled way: any rejection
|
|
@@ -539,34 +574,124 @@ function qualifyToResult(cause, qualify) {
|
|
|
539
574
|
}
|
|
540
575
|
}
|
|
541
576
|
/**
|
|
542
|
-
*
|
|
577
|
+
* Fold an array of settled `Result`s: first `Err` wins, any `Defect` dominates,
|
|
578
|
+
* else `Ok` of the values array.
|
|
579
|
+
*
|
|
580
|
+
* @internal
|
|
581
|
+
*/
|
|
582
|
+
function foldArray(results) {
|
|
583
|
+
let firstErr;
|
|
584
|
+
let firstDefect;
|
|
585
|
+
const values = [];
|
|
586
|
+
for (const r of results) if (r.tag === "Defect") firstDefect ??= r;
|
|
587
|
+
else if (r.tag === "Err") firstErr ??= r;
|
|
588
|
+
else values.push(r.value);
|
|
589
|
+
return firstDefect ?? firstErr ?? ok(values);
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Fold a record of settled `Result`s with the same rules, else `Ok` of the
|
|
593
|
+
* record of values. Keys are written with `Object.defineProperty` so a
|
|
594
|
+
* caller-supplied `"__proto__"` key cannot pollute the prototype.
|
|
595
|
+
*
|
|
596
|
+
* @internal
|
|
597
|
+
*/
|
|
598
|
+
function foldRecord(results) {
|
|
599
|
+
let firstErr;
|
|
600
|
+
let firstDefect;
|
|
601
|
+
const values = {};
|
|
602
|
+
for (const [key, r] of Object.entries(results)) if (r.tag === "Defect") firstDefect ??= r;
|
|
603
|
+
else if (r.tag === "Err") firstErr ??= r;
|
|
604
|
+
else Object.defineProperty(values, key, {
|
|
605
|
+
value: r.value,
|
|
606
|
+
enumerable: true,
|
|
607
|
+
writable: true,
|
|
608
|
+
configurable: true
|
|
609
|
+
});
|
|
610
|
+
return firstDefect ?? firstErr ?? ok(values);
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Collect a tuple/array of {@link Result}s into a single `Result` of all their
|
|
543
614
|
* success values.
|
|
544
615
|
*
|
|
545
616
|
* @remarks
|
|
546
617
|
* Short-circuits on the **first** `Err` (later entries are not inspected for
|
|
547
618
|
* their error); any `Defect` present **dominates**, winning even over an earlier
|
|
548
|
-
* `Err`.
|
|
549
|
-
* `Result<[number, string],
|
|
550
|
-
*
|
|
551
|
-
* @
|
|
552
|
-
* @param results - the results to combine.
|
|
619
|
+
* `Err`. A **fixed tuple** keeps its positional types — `all([ok(1), ok("a")])`
|
|
620
|
+
* is `Result<[number, string], …>` — while a **dynamic array** `Result<T, E>[]`
|
|
621
|
+
* collapses to `Result<T[], E>` with no cast. For a **record** keyed by name,
|
|
622
|
+
* use {@link allFromDict}.
|
|
553
623
|
*
|
|
554
624
|
* @example
|
|
555
625
|
* ```ts
|
|
556
626
|
* import { all, ok } from "unthrown";
|
|
557
|
-
* all([ok(1), ok("a"), ok(true)]).unwrap(); // [1, "a", true]
|
|
627
|
+
* all([ok(1), ok("a"), ok(true)]).unwrap(); // [1, "a", true] (typed [number, string, boolean])
|
|
628
|
+
* all([ok(1), ok(2)] as Result<number, never>[]).unwrap(); // number[]
|
|
558
629
|
* ```
|
|
559
630
|
*/
|
|
560
631
|
function all(results) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
632
|
+
return foldArray(results);
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Collect a **record** of {@link Result}s into a single `Result` of a record of
|
|
636
|
+
* their success values — `allFromDict({ a: Result<A, E>, b: Result<B, E> })` is
|
|
637
|
+
* `Result<{ a: A; b: B }, E>`. The named counterpart of {@link all}, for
|
|
638
|
+
* parallel work you'd rather not tuple.
|
|
639
|
+
*
|
|
640
|
+
* @remarks
|
|
641
|
+
* Same folding rules as {@link all}: first `Err` short-circuits, any `Defect`
|
|
642
|
+
* dominates. This is **not** error accumulation.
|
|
643
|
+
*
|
|
644
|
+
* @example
|
|
645
|
+
* ```ts
|
|
646
|
+
* import { allFromDict, ok } from "unthrown";
|
|
647
|
+
* allFromDict({ id: ok(1), name: ok("ada") }).unwrap(); // { id: 1, name: "ada" }
|
|
648
|
+
* ```
|
|
649
|
+
*/
|
|
650
|
+
function allFromDict(results) {
|
|
651
|
+
return foldRecord(results);
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* The asynchronous counterpart of {@link all}: combine a tuple/array of
|
|
655
|
+
* {@link AsyncResult}s into one `AsyncResult` of all their success values.
|
|
656
|
+
*
|
|
657
|
+
* @remarks
|
|
658
|
+
* The inputs are resolved **concurrently** (order preserved); the resolved
|
|
659
|
+
* `Result`s are then folded with the same rules as {@link all} — first `Err`
|
|
660
|
+
* short-circuits, any `Defect` dominates. As ever, the returned `AsyncResult`'s
|
|
661
|
+
* internal promise never rejects. For a **record**, use {@link allFromDictAsync}.
|
|
662
|
+
*
|
|
663
|
+
* @example
|
|
664
|
+
* ```ts
|
|
665
|
+
* import { allAsync, fromSafePromise } from "unthrown";
|
|
666
|
+
* await allAsync([fromSafePromise(a()), fromSafePromise(b())]);
|
|
667
|
+
* ```
|
|
668
|
+
*/
|
|
669
|
+
function allAsync(results) {
|
|
670
|
+
return new AsyncRes(Promise.all(results).then((resolved) => foldArray(resolved)));
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* The asynchronous counterpart of {@link allFromDict}: combine a record of
|
|
674
|
+
* {@link AsyncResult}s into one `AsyncResult` of a record of their values.
|
|
675
|
+
*
|
|
676
|
+
* @remarks
|
|
677
|
+
* Resolved concurrently (order preserved), folded with the {@link all} rules,
|
|
678
|
+
* and the internal promise never rejects.
|
|
679
|
+
*
|
|
680
|
+
* @example
|
|
681
|
+
* ```ts
|
|
682
|
+
* import { allFromDictAsync, fromSafePromise } from "unthrown";
|
|
683
|
+
* await allFromDictAsync({ a: fromSafePromise(a()), b: fromSafePromise(b()) });
|
|
684
|
+
* ```
|
|
685
|
+
*/
|
|
686
|
+
function allFromDictAsync(results) {
|
|
687
|
+
const entries = Object.entries(results);
|
|
688
|
+
return new AsyncRes(Promise.all(entries.map(([, ar]) => ar)).then((resolved) => {
|
|
689
|
+
const byKey = Object.create(null);
|
|
690
|
+
entries.forEach(([key], i) => {
|
|
691
|
+
byKey[key] = resolved[i];
|
|
692
|
+
});
|
|
693
|
+
return foldRecord(byKey);
|
|
694
|
+
}));
|
|
570
695
|
}
|
|
571
696
|
//#endregion
|
|
572
697
|
//#region src/facade.ts
|
|
@@ -575,7 +700,9 @@ function all(results) {
|
|
|
575
700
|
* discoverable namespace: {@link Result.ok}, {@link Result.err},
|
|
576
701
|
* {@link Result.defect}, {@link Result.fromNullable}, {@link Result.fromThrowable},
|
|
577
702
|
* {@link Result.fromPromise}, {@link Result.fromSafePromise}, {@link Result.all},
|
|
578
|
-
* {@link Result.
|
|
703
|
+
* {@link Result.allAsync}, {@link Result.allFromDict},
|
|
704
|
+
* {@link Result.allFromDictAsync}, {@link Result.isOk}, {@link Result.isErr},
|
|
705
|
+
* {@link Result.isDefect}.
|
|
579
706
|
*
|
|
580
707
|
* @remarks
|
|
581
708
|
* Purely additive sugar — each member **is** the corresponding free function.
|
|
@@ -598,6 +725,9 @@ const Result = {
|
|
|
598
725
|
fromPromise,
|
|
599
726
|
fromSafePromise,
|
|
600
727
|
all,
|
|
728
|
+
allAsync,
|
|
729
|
+
allFromDict,
|
|
730
|
+
allFromDictAsync,
|
|
601
731
|
isOk,
|
|
602
732
|
isErr,
|
|
603
733
|
isDefect
|
|
@@ -614,8 +744,26 @@ const Result = {
|
|
|
614
744
|
* field in the payload is forwarded to `Error`. The `_tag` always reflects
|
|
615
745
|
* `tag` and cannot be overridden by the payload.
|
|
616
746
|
*
|
|
747
|
+
* `_tag` is the discriminant used by {@link matchTags}; `Error.name` is the
|
|
748
|
+
* human-facing label in stack traces and logs. By default they coincide, but
|
|
749
|
+
* they can be **decoupled** with `options.name` — so a tag can be namespaced for
|
|
750
|
+
* collision-safety (`"@my-lib/RetryableError"`) without that slash-prefixed
|
|
751
|
+
* string leaking into `Error.name`:
|
|
752
|
+
*
|
|
753
|
+
* ```ts
|
|
754
|
+
* class RetryableError extends TaggedError("@my-lib/RetryableError", {
|
|
755
|
+
* name: "RetryableError",
|
|
756
|
+
* })<{ message: string }> {}
|
|
757
|
+
*
|
|
758
|
+
* const e = new RetryableError({ message: "boom" });
|
|
759
|
+
* e._tag; // "@my-lib/RetryableError" — namespaced discriminant
|
|
760
|
+
* e.name; // "RetryableError" — clean display name
|
|
761
|
+
* ```
|
|
762
|
+
*
|
|
617
763
|
* @typeParam Tag - the string literal discriminant.
|
|
618
|
-
* @param tag - the discriminant value
|
|
764
|
+
* @param tag - the discriminant value; also the default error `name`.
|
|
765
|
+
* @param options - optional overrides. `options.name` sets `Error.name`
|
|
766
|
+
* independently of `tag` (defaults to `tag`).
|
|
619
767
|
*
|
|
620
768
|
* @example
|
|
621
769
|
* ```ts
|
|
@@ -626,14 +774,15 @@ const Result = {
|
|
|
626
774
|
* new HttpError({ status: 500 }).status; // 500
|
|
627
775
|
* ```
|
|
628
776
|
*/
|
|
629
|
-
function TaggedError(tag) {
|
|
777
|
+
function TaggedError(tag, options) {
|
|
778
|
+
const displayName = options?.name ?? tag;
|
|
630
779
|
class TaggedErrorBase extends Error {
|
|
631
780
|
_tag;
|
|
632
781
|
constructor(props) {
|
|
633
782
|
super(typeof props?.["message"] === "string" ? props["message"] : void 0);
|
|
634
783
|
if (props) Object.assign(this, props);
|
|
635
784
|
this._tag = tag;
|
|
636
|
-
this.name =
|
|
785
|
+
this.name = displayName;
|
|
637
786
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
638
787
|
}
|
|
639
788
|
}
|
|
@@ -655,6 +804,9 @@ exports.Result = Result;
|
|
|
655
804
|
exports.TaggedError = TaggedError;
|
|
656
805
|
exports.UnwrapError = UnwrapError;
|
|
657
806
|
exports.all = all;
|
|
807
|
+
exports.allAsync = allAsync;
|
|
808
|
+
exports.allFromDict = allFromDict;
|
|
809
|
+
exports.allFromDictAsync = allFromDictAsync;
|
|
658
810
|
exports.defect = defect;
|
|
659
811
|
exports.err = err;
|
|
660
812
|
exports.fromNullable = fromNullable;
|
package/dist/index.d.cts
CHANGED
|
@@ -39,6 +39,23 @@ type ResultMethods<T, E> = {
|
|
|
39
39
|
* @param f - the side effect (its return value is ignored).
|
|
40
40
|
*/
|
|
41
41
|
tap(f: (value: T) => void): Result$1<T, E>;
|
|
42
|
+
/**
|
|
43
|
+
* Run a **failable** side effect on the success value, keeping the original
|
|
44
|
+
* value but threading the effect's error.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* This is to {@link ResultMethods.tap | tap} what
|
|
48
|
+
* {@link ResultMethods.flatMap | flatMap} is to {@link ResultMethods.map | map}:
|
|
49
|
+
* `f` returns a `Result`, but its **success value is discarded** — on success
|
|
50
|
+
* the original value flows through (`Result<T, E | E2>`), while an `Err` (or
|
|
51
|
+
* `Defect`) from `f` short-circuits. Runs only on `Ok`; `Err` and `Defect` pass
|
|
52
|
+
* through. If `f` throws, the throw becomes a `Defect`. Use it for a validation
|
|
53
|
+
* or write whose _result_ matters but whose _value_ you don't need.
|
|
54
|
+
*
|
|
55
|
+
* @typeParam E2 - the error type the effect may introduce.
|
|
56
|
+
* @param f - the failable side effect; its `Ok` value is ignored.
|
|
57
|
+
*/
|
|
58
|
+
flatTap<E2>(f: (value: T) => Result$1<unknown, E2>): Result$1<T, E | E2>;
|
|
42
59
|
/**
|
|
43
60
|
* Replace the success value with a constant `value`.
|
|
44
61
|
*
|
|
@@ -172,10 +189,10 @@ type ResultMethods<T, E> = {
|
|
|
172
189
|
*
|
|
173
190
|
* @throws Re-throws on a `Defect`.
|
|
174
191
|
*/
|
|
175
|
-
getOrUndefined(): T | undefined; /** Whether this result is `Ok`. */
|
|
176
|
-
isOk():
|
|
177
|
-
isErr():
|
|
178
|
-
isDefect():
|
|
192
|
+
getOrUndefined(): T | undefined; /** Whether this result is `Ok` — narrows `this` to its {@link OkView} on `true`. */
|
|
193
|
+
isOk(): this is OkView<T, E>; /** Whether this result is `Err` — narrows `this` to its {@link ErrView} on `true`. */
|
|
194
|
+
isErr(): this is ErrView<E, T>; /** Whether this result is a `Defect` — narrows `this` to its {@link DefectView} on `true`. */
|
|
195
|
+
isDefect(): this is DefectView<T, E>; /** Lift this synchronous `Result` into an {@link AsyncResult}. */
|
|
179
196
|
toAsync(): AsyncResult<T, E>;
|
|
180
197
|
};
|
|
181
198
|
/** The `Ok` variant of a {@link Result}: a success carrying a `value`. */
|
|
@@ -258,7 +275,8 @@ type Awaitable<T> = {
|
|
|
258
275
|
* {@link fromPromise} forces. To do further async work, re-enter through a
|
|
259
276
|
* qualified boundary and compose it: `ar.flatMap((v) => fromPromise(work(v),
|
|
260
277
|
* qualify))`. The eliminators (`unwrap`, …) return promises; the binds
|
|
261
|
-
* (`flatMap`, `orElse`, `recoverDefect`) additionally accept an
|
|
278
|
+
* (`flatMap`, `flatTap`, `orElse`, `recoverDefect`) additionally accept an
|
|
279
|
+
* `AsyncResult`.
|
|
262
280
|
*
|
|
263
281
|
* To pattern-match an `AsyncResult`, `await` it first: `match(await ar)`.
|
|
264
282
|
*
|
|
@@ -272,7 +290,13 @@ type AsyncResult<T, E> = Awaitable<Result$1<T, E>> & {
|
|
|
272
290
|
* (never a raw `Promise`); a throw becomes a `Defect`.
|
|
273
291
|
*/
|
|
274
292
|
flatMap<U, E2>(f: (value: T) => Result$1<U, E2> | AsyncResult<U, E2>): AsyncResult<U, E | E2>; /** Asynchronous `tap`. `f` is synchronous; a throw becomes a `Defect`. */
|
|
275
|
-
tap(f: (value: T) => void): AsyncResult<T, E>;
|
|
293
|
+
tap(f: (value: T) => void): AsyncResult<T, E>;
|
|
294
|
+
/**
|
|
295
|
+
* Asynchronous `flatTap` — a failable tap that keeps the original value. `f`
|
|
296
|
+
* may return a `Result` **or** an `AsyncResult`; its `Ok` value is discarded,
|
|
297
|
+
* an `Err`/`Defect` short-circuits, and a throw becomes a `Defect`.
|
|
298
|
+
*/
|
|
299
|
+
flatTap<E2>(f: (value: T) => Result$1<unknown, E2> | AsyncResult<unknown, E2>): AsyncResult<T, E | E2>; /** Asynchronous `as`. */
|
|
276
300
|
as<U>(value: U): AsyncResult<U, E>; /** Asynchronous `mapErr`. `f` is synchronous; a throw becomes a `Defect`. */
|
|
277
301
|
mapErr<E2>(f: (error: E) => E2): AsyncResult<T, E2>; /** Asynchronous `orElse`. `f` may return a `Result` or an `AsyncResult`. */
|
|
278
302
|
orElse<U, E2>(f: (error: E) => Result$1<U, E2> | AsyncResult<U, E2>): AsyncResult<T | U, E2>; /** Asynchronous `recover`. `f` is synchronous; a throw becomes a `Defect`. */
|
|
@@ -310,6 +334,18 @@ type ErrOf<R> = R extends {
|
|
|
310
334
|
readonly tag: "Err";
|
|
311
335
|
readonly error: infer E;
|
|
312
336
|
} ? E : never;
|
|
337
|
+
/**
|
|
338
|
+
* Extract the success type `T` from an {@link AsyncResult}.
|
|
339
|
+
*
|
|
340
|
+
* @typeParam R - the `AsyncResult` type to inspect.
|
|
341
|
+
*/
|
|
342
|
+
type AsyncOkOf<R> = R extends AsyncResult<infer T, unknown> ? T : never;
|
|
343
|
+
/**
|
|
344
|
+
* Extract the error type `E` from an {@link AsyncResult}.
|
|
345
|
+
*
|
|
346
|
+
* @typeParam R - the `AsyncResult` type to inspect.
|
|
347
|
+
*/
|
|
348
|
+
type AsyncErrOf<R> = R extends AsyncResult<unknown, infer E> ? E : never;
|
|
313
349
|
//#endregion
|
|
314
350
|
//#region src/constructors.d.ts
|
|
315
351
|
/**
|
|
@@ -449,9 +485,16 @@ declare function fromNullable<T, E>(value: T | null | undefined, onAbsent: () =>
|
|
|
449
485
|
* {@link Defect} (via {@link defect}) — there is no path that leaves `unknown`
|
|
450
486
|
* in `E`. A throw inside `qualify` itself is treated as a `Defect`.
|
|
451
487
|
*
|
|
488
|
+
* The modeled error type is `Exclude<R, Defect>` — the `Defect` arm of
|
|
489
|
+
* `qualify`'s return is **subtracted** from `E`, never inferred into it. So a
|
|
490
|
+
* `qualify` that returns *only* `defect(cause)` yields `E = never` (a defect is
|
|
491
|
+
* out-of-band and must not pollute the error channel); reach for
|
|
492
|
+
* {@link fromSafePromise} when every failure is a defect.
|
|
493
|
+
*
|
|
452
494
|
* @typeParam A - the wrapped function's argument tuple.
|
|
453
495
|
* @typeParam T - the wrapped function's return type.
|
|
454
|
-
* @typeParam
|
|
496
|
+
* @typeParam R - `qualify`'s return type; the modeled error `E` is
|
|
497
|
+
* `Exclude<R, Defect>` (its `Defect` arm, if any, is subtracted).
|
|
455
498
|
* @param fn - the throwing function to wrap.
|
|
456
499
|
* @param qualify - triages a thrown cause into `E` or a `Defect`.
|
|
457
500
|
* @returns a function with the same arguments returning `Result<T, E>`.
|
|
@@ -463,7 +506,7 @@ declare function fromNullable<T, E>(value: T | null | undefined, onAbsent: () =>
|
|
|
463
506
|
* parse("{}").unwrap();
|
|
464
507
|
* ```
|
|
465
508
|
*/
|
|
466
|
-
declare function fromThrowable<A extends unknown[], T,
|
|
509
|
+
declare function fromThrowable<A extends unknown[], T, R>(fn: (...args: A) => T, qualify: (cause: unknown) => R): (...args: A) => Result$1<T, Exclude<R, Defect>>;
|
|
467
510
|
/**
|
|
468
511
|
* Wrap a `Promise` (or a thunk producing one) as an {@link AsyncResult}, forcing
|
|
469
512
|
* every rejection to be triaged.
|
|
@@ -474,8 +517,14 @@ declare function fromThrowable<A extends unknown[], T, E>(fn: (...args: A) => T,
|
|
|
474
517
|
* `await`-ing it always yields a `Result`. A throw inside `qualify` is itself a
|
|
475
518
|
* `Defect`.
|
|
476
519
|
*
|
|
520
|
+
* The modeled error type is `Exclude<R, Defect>` — the `Defect` arm of
|
|
521
|
+
* `qualify`'s return is **subtracted** from `E`, never inferred into it. So a
|
|
522
|
+
* `qualify` that returns *only* `defect(cause)` yields `E = never`; when every
|
|
523
|
+
* rejection is a defect, prefer {@link fromSafePromise}.
|
|
524
|
+
*
|
|
477
525
|
* @typeParam T - the resolved value type.
|
|
478
|
-
* @typeParam
|
|
526
|
+
* @typeParam R - `qualify`'s return type; the modeled error `E` is
|
|
527
|
+
* `Exclude<R, Defect>` (its `Defect` arm, if any, is subtracted).
|
|
479
528
|
* @param promise - the promise, or a thunk returning one.
|
|
480
529
|
* @param qualify - triages a rejection cause into `E` or a `Defect`.
|
|
481
530
|
*
|
|
@@ -487,7 +536,7 @@ declare function fromThrowable<A extends unknown[], T, E>(fn: (...args: A) => T,
|
|
|
487
536
|
* );
|
|
488
537
|
* ```
|
|
489
538
|
*/
|
|
490
|
-
declare function fromPromise<T,
|
|
539
|
+
declare function fromPromise<T, R>(promise: Promise<T> | (() => Promise<T>), qualify: (cause: unknown) => R): AsyncResult<T, Exclude<R, Defect>>;
|
|
491
540
|
/**
|
|
492
541
|
* Wrap a `Promise` asserted **not** to fail in any modeled way: any rejection
|
|
493
542
|
* becomes a `Defect`.
|
|
@@ -502,25 +551,96 @@ declare function fromPromise<T, E>(promise: Promise<T> | (() => Promise<T>), qua
|
|
|
502
551
|
*/
|
|
503
552
|
declare function fromSafePromise<T>(promise: Promise<T> | (() => Promise<T>)): AsyncResult<T, never>;
|
|
504
553
|
/**
|
|
505
|
-
*
|
|
554
|
+
* The success channel of {@link all} / {@link allAsync}: a **positional tuple**
|
|
555
|
+
* for a fixed-length input (including the empty tuple), or a homogeneous
|
|
556
|
+
* **array** for a dynamic one.
|
|
557
|
+
*
|
|
558
|
+
* @remarks
|
|
559
|
+
* The split keys off the input's `length`: a fixed tuple has a literal length
|
|
560
|
+
* (`number extends Rs["length"]` is false → keep the positional `Ts`), while a
|
|
561
|
+
* general array has `length: number` (→ collapse to `Ts[number][]`). Checking
|
|
562
|
+
* length rather than `Rs extends [unknown, ...unknown[]]` keeps `all([])` typed
|
|
563
|
+
* as `Result<[], …>` instead of `Result<never[], …>`.
|
|
564
|
+
*
|
|
565
|
+
* @typeParam Rs - the tuple/array of input `Result` types.
|
|
566
|
+
* @typeParam Ts - per-element extracted success types (`OkOf` for `all`,
|
|
567
|
+
* `AsyncOkOf` for `allAsync`).
|
|
568
|
+
* @internal
|
|
569
|
+
*/
|
|
570
|
+
type AllOk<Rs extends readonly unknown[], Ts extends readonly unknown[]> = number extends Rs["length"] ? Ts[number][] : Ts;
|
|
571
|
+
/** A record of `Result`s — the input to {@link allFromDict}. */
|
|
572
|
+
type ResultRecord = Record<string, Result$1<unknown, unknown>>;
|
|
573
|
+
/** A record of `AsyncResult`s — the input to {@link allFromDictAsync}. */
|
|
574
|
+
type AsyncResultRecord = Record<string, AsyncResult<unknown, unknown>>;
|
|
575
|
+
/**
|
|
576
|
+
* Collect a tuple/array of {@link Result}s into a single `Result` of all their
|
|
506
577
|
* success values.
|
|
507
578
|
*
|
|
508
579
|
* @remarks
|
|
509
580
|
* Short-circuits on the **first** `Err` (later entries are not inspected for
|
|
510
581
|
* their error); any `Defect` present **dominates**, winning even over an earlier
|
|
511
|
-
* `Err`.
|
|
512
|
-
* `Result<[number, string],
|
|
513
|
-
*
|
|
514
|
-
* @
|
|
515
|
-
* @param results - the results to combine.
|
|
582
|
+
* `Err`. A **fixed tuple** keeps its positional types — `all([ok(1), ok("a")])`
|
|
583
|
+
* is `Result<[number, string], …>` — while a **dynamic array** `Result<T, E>[]`
|
|
584
|
+
* collapses to `Result<T[], E>` with no cast. For a **record** keyed by name,
|
|
585
|
+
* use {@link allFromDict}.
|
|
516
586
|
*
|
|
517
587
|
* @example
|
|
518
588
|
* ```ts
|
|
519
589
|
* import { all, ok } from "unthrown";
|
|
520
|
-
* all([ok(1), ok("a"), ok(true)]).unwrap(); // [1, "a", true]
|
|
590
|
+
* all([ok(1), ok("a"), ok(true)]).unwrap(); // [1, "a", true] (typed [number, string, boolean])
|
|
591
|
+
* all([ok(1), ok(2)] as Result<number, never>[]).unwrap(); // number[]
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
declare function all<Rs extends readonly Result$1<unknown, unknown>[]>(results: readonly [...Rs]): Result$1<AllOk<Rs, { [K in keyof Rs]: OkOf<Rs[K]> }>, ErrOf<Rs[number]>>;
|
|
595
|
+
/**
|
|
596
|
+
* Collect a **record** of {@link Result}s into a single `Result` of a record of
|
|
597
|
+
* their success values — `allFromDict({ a: Result<A, E>, b: Result<B, E> })` is
|
|
598
|
+
* `Result<{ a: A; b: B }, E>`. The named counterpart of {@link all}, for
|
|
599
|
+
* parallel work you'd rather not tuple.
|
|
600
|
+
*
|
|
601
|
+
* @remarks
|
|
602
|
+
* Same folding rules as {@link all}: first `Err` short-circuits, any `Defect`
|
|
603
|
+
* dominates. This is **not** error accumulation.
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* ```ts
|
|
607
|
+
* import { allFromDict, ok } from "unthrown";
|
|
608
|
+
* allFromDict({ id: ok(1), name: ok("ada") }).unwrap(); // { id: 1, name: "ada" }
|
|
609
|
+
* ```
|
|
610
|
+
*/
|
|
611
|
+
declare function allFromDict<R extends ResultRecord>(results: R): Result$1<{ [K in keyof R]: OkOf<R[K]> }, ErrOf<R[keyof R]>>;
|
|
612
|
+
/**
|
|
613
|
+
* The asynchronous counterpart of {@link all}: combine a tuple/array of
|
|
614
|
+
* {@link AsyncResult}s into one `AsyncResult` of all their success values.
|
|
615
|
+
*
|
|
616
|
+
* @remarks
|
|
617
|
+
* The inputs are resolved **concurrently** (order preserved); the resolved
|
|
618
|
+
* `Result`s are then folded with the same rules as {@link all} — first `Err`
|
|
619
|
+
* short-circuits, any `Defect` dominates. As ever, the returned `AsyncResult`'s
|
|
620
|
+
* internal promise never rejects. For a **record**, use {@link allFromDictAsync}.
|
|
621
|
+
*
|
|
622
|
+
* @example
|
|
623
|
+
* ```ts
|
|
624
|
+
* import { allAsync, fromSafePromise } from "unthrown";
|
|
625
|
+
* await allAsync([fromSafePromise(a()), fromSafePromise(b())]);
|
|
521
626
|
* ```
|
|
522
627
|
*/
|
|
523
|
-
declare function
|
|
628
|
+
declare function allAsync<Rs extends readonly AsyncResult<unknown, unknown>[]>(results: readonly [...Rs]): AsyncResult<AllOk<Rs, { [K in keyof Rs]: AsyncOkOf<Rs[K]> }>, AsyncErrOf<Rs[number]>>;
|
|
629
|
+
/**
|
|
630
|
+
* The asynchronous counterpart of {@link allFromDict}: combine a record of
|
|
631
|
+
* {@link AsyncResult}s into one `AsyncResult` of a record of their values.
|
|
632
|
+
*
|
|
633
|
+
* @remarks
|
|
634
|
+
* Resolved concurrently (order preserved), folded with the {@link all} rules,
|
|
635
|
+
* and the internal promise never rejects.
|
|
636
|
+
*
|
|
637
|
+
* @example
|
|
638
|
+
* ```ts
|
|
639
|
+
* import { allFromDictAsync, fromSafePromise } from "unthrown";
|
|
640
|
+
* await allFromDictAsync({ a: fromSafePromise(a()), b: fromSafePromise(b()) });
|
|
641
|
+
* ```
|
|
642
|
+
*/
|
|
643
|
+
declare function allFromDictAsync<R extends AsyncResultRecord>(results: R): AsyncResult<{ [K in keyof R]: AsyncOkOf<R[K]> }, AsyncErrOf<R[keyof R]>>;
|
|
524
644
|
//#endregion
|
|
525
645
|
//#region src/facade.d.ts
|
|
526
646
|
/**
|
|
@@ -528,7 +648,9 @@ declare function all<Rs extends readonly Result$1<unknown, unknown>[]>(results:
|
|
|
528
648
|
* discoverable namespace: {@link Result.ok}, {@link Result.err},
|
|
529
649
|
* {@link Result.defect}, {@link Result.fromNullable}, {@link Result.fromThrowable},
|
|
530
650
|
* {@link Result.fromPromise}, {@link Result.fromSafePromise}, {@link Result.all},
|
|
531
|
-
* {@link Result.
|
|
651
|
+
* {@link Result.allAsync}, {@link Result.allFromDict},
|
|
652
|
+
* {@link Result.allFromDictAsync}, {@link Result.isOk}, {@link Result.isErr},
|
|
653
|
+
* {@link Result.isDefect}.
|
|
532
654
|
*
|
|
533
655
|
* @remarks
|
|
534
656
|
* Purely additive sugar — each member **is** the corresponding free function.
|
|
@@ -551,6 +673,9 @@ declare const Result: {
|
|
|
551
673
|
readonly fromPromise: typeof fromPromise;
|
|
552
674
|
readonly fromSafePromise: typeof fromSafePromise;
|
|
553
675
|
readonly all: typeof all;
|
|
676
|
+
readonly allAsync: typeof allAsync;
|
|
677
|
+
readonly allFromDict: typeof allFromDict;
|
|
678
|
+
readonly allFromDictAsync: typeof allFromDictAsync;
|
|
554
679
|
readonly isOk: typeof isOk;
|
|
555
680
|
readonly isErr: typeof isErr;
|
|
556
681
|
readonly isDefect: typeof isDefect;
|
|
@@ -592,8 +717,26 @@ type TaggedErrorConstructor<Tag extends string> = {
|
|
|
592
717
|
* field in the payload is forwarded to `Error`. The `_tag` always reflects
|
|
593
718
|
* `tag` and cannot be overridden by the payload.
|
|
594
719
|
*
|
|
720
|
+
* `_tag` is the discriminant used by {@link matchTags}; `Error.name` is the
|
|
721
|
+
* human-facing label in stack traces and logs. By default they coincide, but
|
|
722
|
+
* they can be **decoupled** with `options.name` — so a tag can be namespaced for
|
|
723
|
+
* collision-safety (`"@my-lib/RetryableError"`) without that slash-prefixed
|
|
724
|
+
* string leaking into `Error.name`:
|
|
725
|
+
*
|
|
726
|
+
* ```ts
|
|
727
|
+
* class RetryableError extends TaggedError("@my-lib/RetryableError", {
|
|
728
|
+
* name: "RetryableError",
|
|
729
|
+
* })<{ message: string }> {}
|
|
730
|
+
*
|
|
731
|
+
* const e = new RetryableError({ message: "boom" });
|
|
732
|
+
* e._tag; // "@my-lib/RetryableError" — namespaced discriminant
|
|
733
|
+
* e.name; // "RetryableError" — clean display name
|
|
734
|
+
* ```
|
|
735
|
+
*
|
|
595
736
|
* @typeParam Tag - the string literal discriminant.
|
|
596
|
-
* @param tag - the discriminant value
|
|
737
|
+
* @param tag - the discriminant value; also the default error `name`.
|
|
738
|
+
* @param options - optional overrides. `options.name` sets `Error.name`
|
|
739
|
+
* independently of `tag` (defaults to `tag`).
|
|
597
740
|
*
|
|
598
741
|
* @example
|
|
599
742
|
* ```ts
|
|
@@ -604,7 +747,9 @@ type TaggedErrorConstructor<Tag extends string> = {
|
|
|
604
747
|
* new HttpError({ status: 500 }).status; // 500
|
|
605
748
|
* ```
|
|
606
749
|
*/
|
|
607
|
-
declare function TaggedError<Tag extends string>(tag: Tag
|
|
750
|
+
declare function TaggedError<Tag extends string>(tag: Tag, options?: {
|
|
751
|
+
readonly name?: string;
|
|
752
|
+
}): TaggedErrorConstructor<Tag>;
|
|
608
753
|
/**
|
|
609
754
|
* The handler object {@link matchTags} requires: a branch per error tag, plus
|
|
610
755
|
* `Ok` and `Defect`. Miss a tag and it will not compile — the exhaustiveness is
|
|
@@ -659,5 +804,5 @@ declare function matchTags<T, E extends {
|
|
|
659
804
|
_tag: string;
|
|
660
805
|
}, R>(result: AsyncResult<T, E>, handlers: TagHandlers<T, E, R>): Promise<R>;
|
|
661
806
|
//#endregion
|
|
662
|
-
export { type AsyncResult, type Awaitable, type Defect, type DefectView, type ErrOf, type ErrView, type OkOf, type OkView, Result, type TagHandlers, TaggedError, type TaggedErrorConstructor, type TaggedErrorInstance, UnwrapError, all, defect, err, fromNullable, fromPromise, fromSafePromise, fromThrowable, isDefect, isErr, isOk, matchTags, ok };
|
|
807
|
+
export { type AsyncErrOf, type AsyncOkOf, type AsyncResult, type Awaitable, type Defect, type DefectView, type ErrOf, type ErrView, type OkOf, type OkView, Result, type TagHandlers, TaggedError, type TaggedErrorConstructor, type TaggedErrorInstance, UnwrapError, all, allAsync, allFromDict, allFromDictAsync, defect, err, fromNullable, fromPromise, fromSafePromise, fromThrowable, isDefect, isErr, isOk, matchTags, ok };
|
|
663
808
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/constructors.ts","../src/core.ts","../src/defect.ts","../src/interop.ts","../src/facade.ts","../src/tagged.ts"],"mappings":";;AAWA;;;;;;;;KAAY,aAAA;EAqB6B;;;;;;;;;EAXvC,GAAA,IAAO,CAAA,GAAI,KAAA,EAAO,CAAA,KAAM,CAAA,GAAI,QAAA,CAAO,CAAA,EAAG,CAAA;EAoBV;;;;;;;;;;EAT5B,OAAA,QAAe,CAAA,GAAI,KAAA,EAAO,CAAA,KAAM,QAAA,CAAO,CAAA,EAAG,EAAA,IAAM,QAAA,CAAO,CAAA,EAAG,CAAA,GAAI,EAAA;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/constructors.ts","../src/core.ts","../src/defect.ts","../src/interop.ts","../src/facade.ts","../src/tagged.ts"],"mappings":";;AAWA;;;;;;;;KAAY,aAAA;EAqB6B;;;;;;;;;EAXvC,GAAA,IAAO,CAAA,GAAI,KAAA,EAAO,CAAA,KAAM,CAAA,GAAI,QAAA,CAAO,CAAA,EAAG,CAAA;EAoBV;;;;;;;;;;EAT5B,OAAA,QAAe,CAAA,GAAI,KAAA,EAAO,CAAA,KAAM,QAAA,CAAO,CAAA,EAAG,EAAA,IAAM,QAAA,CAAO,CAAA,EAAG,CAAA,GAAI,EAAA;EAkC7C;;;;;;;;EAzBjB,GAAA,CAAI,CAAA,GAAI,KAAA,EAAO,CAAA,YAAa,QAAA,CAAO,CAAA,EAAG,CAAA;EA+CP;;;;;;;;;;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