unthrown 4.0.0 → 4.2.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 +175 -54
- package/dist/index.d.cts +347 -69
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +347 -69
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +173 -55
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/constructors.ts","../src/core.ts","../src/do.ts","../src/defect.ts","../src/interop.ts","../src/facade.ts","../src/tagged.ts"],"mappings":";;AAQA;;;;;KAAY,QAAA,oBAA4B,CAAA,GAAI,CAAA,CAAE,CAAA;;;;;;;AAAC;AAU/C;KAAY,KAAA,2BAAgC,QAAA,CAAS,IAAA,CAAK,CAAA,EAAG,CAAA,qBAAsB,CAAA,GAAI,CAAA;;;;;;;;;;;;;;;;;KAkB3E,WAAA,OAAkB,CAAA,WAAY,WAAW;;AAlBmC;AAkBxF;;;;;;;;AAAqD;AAoBrD;;;;;KAAY,aAAA;EAYkB;;;;;;;;;;;EAA5B,GAAA,IAAO,CAAA,GAAI,KAAA,EAAO,CAAA,KAAM,CAAA,GAAI,WAAA,CAAY,CAAA,IAAK,QAAA,CAAO,CAAA,EAAG,CAAA;EAqBrC;;;;;;;;;;EAVlB,OAAA,QAAe,CAAA,GAAI,KAAA,EAAO,CAAA,KAAM,QAAA,CAAO,CAAA,EAAG,EAAA,IAAM,QAAA,CAAO,CAAA,EAAG,CAAA,GAAI,EAAA;EA2BD;;;;;;;;;EAjB7D,GAAA,IAAO,CAAA,GAAI,KAAA,EAAO,CAAA,KAAM,CAAA,GAAI,WAAA,CAAY,CAAA,IAAK,QAAA,CAAO,CAAA,EAAG,CAAA;EAwCjC;;;;;;;;;;;;;;;;EAvBtB,OAAA,KAAY,CAAA,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AAA;AAAA;;APTZ;AAU/C;;;;;;;;;;;;;;;;KOmBY,sBAAA;EAAA,eACK,KAAA,OACb,IAAA,QAAY,CAAA,wBAAyB,CAAA;IAAA,SAAe,IAAA;IAAA,SAAuB,OAAA;EAAA,IAC1E,mBAAA,CAAoB,GAAA,EAAK,CAAA;AAAA;APtB0D;AAkBxF;;;;;;;;AAAqD;AAoBrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAtCwF,iBO8ExE,WAAA,qBACd,GAAA,EAAK,GAAA,EACL,OAAA;EAAA,SAAqB,IAAA;AAAA,IACpB,sBAAA,CAAuB,GAAA;;;;;;;;;;;;KAkCd,WAAA;EAA2B,IAAA;AAAA;EACrC,EAAA,GAAK,KAAA,EAAO,CAAA,KAAM,CAAA;EAClB,MAAA,GAAS,KAAA,cAAmB,CAAA;AAAA,YAClB,CAAA,YAAa,KAAA,EAAO,OAAA,CAAQ,CAAA;EAAK,IAAA,EAAM,CAAA;AAAA,OAAS,CAAA;;;;;;;;KASvD,gBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2CW,SAAA;EAAyB,IAAA;AAAA,MACvC,MAAA,EAAQ,QAAA,CAAO,CAAA,EAAG,CAAA,GAClB,QAAA,EAAU,WAAA,CAAY,CAAA,EAAG,CAAA,EAAG,CAAA,MACxB,OAAA,CAAQ,CAAA,wDAAyD,gBAAA,IACpE,CAAA;AAAA,iBACa,SAAA;EAAyB,IAAA;AAAA,MACvC,MAAA,EAAQ,aAAA,CAAY,CAAA,EAAG,CAAA,GACvB,QAAA,EAAU,WAAA,CAAY,CAAA,EAAG,CAAA,EAAG,CAAA,MACxB,OAAA,CAAQ,CAAA,wDAAyD,gBAAA,IACpE,OAAA,CAAQ,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/constructors.ts","../src/core.ts","../src/do.ts","../src/defect.ts","../src/interop.ts","../src/facade.ts","../src/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;;;;;;;;;;;;;;;;;;KAgCD,OAAO,GAAG,KAAK,SAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4B5B;;;;;;;;;;;;;;;;;;;;;KAwBD,YAAY,GAAG,KAAK,cAAgB,GAAG;;;KC/H9C,QAAQ;;;;;;;;;;KAWD,oBAAoB,oBAAoB,UAAU,SAAS,QACrE,SAAS,KAAK;WAAqC,MAAM;;;;;;;;;;;;;;;;;;;;KAoB/C,uBAAuB;OAC5B,UAAU,YACb,YAAY,yBAAyB;aAAe;aAAuB;MAC1E,oBAAoB,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwDd,YAAY,oBAC1B,KAAK,KACL;WAAqB;IACpB,uBAAuB;;;;;;;;;;;;KAkCd,YAAY,GAAG;EAAY;GAAgB;EACrD,KAAK,OAAO,MAAM;EAClB,SAAS,mBAAmB;OACvB,KAAK,aAAa,OAAO,QAAQ;EAAK,MAAM;OAAS;;;;;;;;KASvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2CW,UAAU,GAAG;EAAY;GAAgB,GACvD,QAAQ,SAAO,GAAG,IAClB,UAAU,YAAY,GAAG,GAAG,OACxB,QAAQ,yDAAyD,oBACpE;iBACa,UAAU,GAAG;EAAY;GAAgB,GACvD,QAAQ,cAAY,GAAG,IACvB,UAAU,YAAY,GAAG,GAAG,OACxB,QAAQ,yDAAyD,oBACpE,QAAQ"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/core.ts
|
|
2
2
|
/**
|
|
3
|
-
* Thrown by a {@link Result}'s `
|
|
4
|
-
* wrong on a *modeled* result — `
|
|
3
|
+
* Thrown by a {@link Result}'s `get` / `getErr` when the assertion is
|
|
4
|
+
* wrong on a *modeled* result — `get()` on an `Err`, or `getErr()` on an
|
|
5
5
|
* `Ok`.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* A `Defect` is never wrapped in an `UnwrapError`: its original cause is
|
|
14
14
|
* re-thrown (with its original stack) instead.
|
|
15
15
|
*
|
|
16
|
-
* `
|
|
16
|
+
* `get()` and `getErr()` are type-gated (`this: Result<T, never>` /
|
|
17
17
|
* `Result<never, E>`), so the wrong-variant branch that throws this is
|
|
18
18
|
* unreachable through well-typed code — it remains only as a defensive guard
|
|
19
19
|
* against unsound runtime misuse (e.g. an `as` cast past the gate).
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
*/
|
|
25
25
|
var UnwrapError = class extends Error {
|
|
26
26
|
/**
|
|
27
|
-
* The offending value: the `Err` error for `
|
|
28
|
-
* `
|
|
27
|
+
* The offending value: the `Err` error for `get()`, or the `Ok` value for
|
|
28
|
+
* `getErr()`.
|
|
29
29
|
*/
|
|
30
30
|
error;
|
|
31
31
|
constructor(error) {
|
|
@@ -105,6 +105,10 @@ var Res = class {
|
|
|
105
105
|
if (this.tag !== "Ok") return passThrough(this);
|
|
106
106
|
return okRes(value);
|
|
107
107
|
}
|
|
108
|
+
discard() {
|
|
109
|
+
if (this.tag !== "Ok") return passThrough(this);
|
|
110
|
+
return okRes(void 0);
|
|
111
|
+
}
|
|
108
112
|
mapErr(f) {
|
|
109
113
|
if (this.tag !== "Err") return passThrough(this);
|
|
110
114
|
try {
|
|
@@ -113,7 +117,7 @@ var Res = class {
|
|
|
113
117
|
return defectRes(cause);
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
|
-
|
|
120
|
+
flatMapErr(f) {
|
|
117
121
|
if (this.tag !== "Err") return passThrough(this);
|
|
118
122
|
try {
|
|
119
123
|
return f(this.error);
|
|
@@ -121,7 +125,11 @@ var Res = class {
|
|
|
121
125
|
return defectRes(cause);
|
|
122
126
|
}
|
|
123
127
|
}
|
|
124
|
-
|
|
128
|
+
/** @deprecated Use {@link Res.flatMapErr}. */
|
|
129
|
+
orElse(f) {
|
|
130
|
+
return this.flatMapErr(f);
|
|
131
|
+
}
|
|
132
|
+
recoverErr(f) {
|
|
125
133
|
if (this.tag !== "Err") return passThrough(this);
|
|
126
134
|
try {
|
|
127
135
|
return okRes(f(this.error));
|
|
@@ -129,6 +137,10 @@ var Res = class {
|
|
|
129
137
|
return defectRes(cause);
|
|
130
138
|
}
|
|
131
139
|
}
|
|
140
|
+
/** @deprecated Use {@link Res.recoverErr}. */
|
|
141
|
+
recover(f) {
|
|
142
|
+
return this.recoverErr(f);
|
|
143
|
+
}
|
|
132
144
|
tapErr(f) {
|
|
133
145
|
if (this.tag !== "Err") return this;
|
|
134
146
|
try {
|
|
@@ -171,30 +183,46 @@ var Res = class {
|
|
|
171
183
|
case "Defect": return cases.defect(this.cause);
|
|
172
184
|
}
|
|
173
185
|
}
|
|
174
|
-
|
|
186
|
+
get() {
|
|
175
187
|
switch (this.tag) {
|
|
176
188
|
case "Ok": return this.value;
|
|
177
189
|
case "Err": throw new UnwrapError(this.error);
|
|
178
190
|
case "Defect": throw this.cause;
|
|
179
191
|
}
|
|
180
192
|
}
|
|
181
|
-
|
|
193
|
+
/** @deprecated Use {@link Res.get}. */
|
|
194
|
+
unwrap() {
|
|
195
|
+
return this.get();
|
|
196
|
+
}
|
|
197
|
+
getErr() {
|
|
182
198
|
switch (this.tag) {
|
|
183
199
|
case "Err": return this.error;
|
|
184
200
|
case "Ok": throw new UnwrapError(this.value);
|
|
185
201
|
case "Defect": throw this.cause;
|
|
186
202
|
}
|
|
187
203
|
}
|
|
188
|
-
|
|
204
|
+
/** @deprecated Use {@link Res.getErr}. */
|
|
205
|
+
unwrapErr() {
|
|
206
|
+
return this.getErr();
|
|
207
|
+
}
|
|
208
|
+
getOr(fallback) {
|
|
189
209
|
if (this.tag === "Ok") return this.value;
|
|
190
210
|
if (this.tag === "Defect") throw this.cause;
|
|
191
211
|
return fallback;
|
|
192
212
|
}
|
|
193
|
-
|
|
213
|
+
/** @deprecated Use {@link Res.getOr}. */
|
|
214
|
+
unwrapOr(fallback) {
|
|
215
|
+
return this.getOr(fallback);
|
|
216
|
+
}
|
|
217
|
+
getOrElse(f) {
|
|
194
218
|
if (this.tag === "Ok") return this.value;
|
|
195
219
|
if (this.tag === "Defect") throw this.cause;
|
|
196
220
|
return f(this.error);
|
|
197
221
|
}
|
|
222
|
+
/** @deprecated Use {@link Res.getOrElse}. */
|
|
223
|
+
unwrapOrElse(f) {
|
|
224
|
+
return this.getOrElse(f);
|
|
225
|
+
}
|
|
198
226
|
getOrNull() {
|
|
199
227
|
if (this.tag === "Ok") return this.value;
|
|
200
228
|
if (this.tag === "Defect") throw this.cause;
|
|
@@ -204,6 +232,11 @@ var Res = class {
|
|
|
204
232
|
if (this.tag === "Ok") return this.value;
|
|
205
233
|
if (this.tag === "Defect") throw this.cause;
|
|
206
234
|
}
|
|
235
|
+
getOrThrow() {
|
|
236
|
+
if (this.tag === "Ok") return this.value;
|
|
237
|
+
if (this.tag === "Defect") throw this.cause;
|
|
238
|
+
throw this.error;
|
|
239
|
+
}
|
|
207
240
|
isOk() {
|
|
208
241
|
return this.tag === "Ok";
|
|
209
242
|
}
|
|
@@ -415,6 +448,9 @@ var AsyncRes = class AsyncRes {
|
|
|
415
448
|
as(value) {
|
|
416
449
|
return new AsyncRes(this.promise.then((r) => r.tag === "Ok" ? okRes(value) : passThrough(r)));
|
|
417
450
|
}
|
|
451
|
+
discard() {
|
|
452
|
+
return new AsyncRes(this.promise.then((r) => r.tag === "Ok" ? okRes(void 0) : passThrough(r)));
|
|
453
|
+
}
|
|
418
454
|
mapErr(f) {
|
|
419
455
|
return new AsyncRes(this.promise.then((r) => {
|
|
420
456
|
if (r.tag !== "Err") return passThrough(r);
|
|
@@ -425,7 +461,7 @@ var AsyncRes = class AsyncRes {
|
|
|
425
461
|
}
|
|
426
462
|
}));
|
|
427
463
|
}
|
|
428
|
-
|
|
464
|
+
flatMapErr(f) {
|
|
429
465
|
return new AsyncRes(this.promise.then(async (r) => {
|
|
430
466
|
if (r.tag !== "Err") return passThrough(r);
|
|
431
467
|
try {
|
|
@@ -435,7 +471,11 @@ var AsyncRes = class AsyncRes {
|
|
|
435
471
|
}
|
|
436
472
|
}));
|
|
437
473
|
}
|
|
438
|
-
|
|
474
|
+
/** @deprecated Use {@link AsyncRes.flatMapErr}. */
|
|
475
|
+
orElse(f) {
|
|
476
|
+
return this.flatMapErr(f);
|
|
477
|
+
}
|
|
478
|
+
recoverErr(f) {
|
|
439
479
|
return new AsyncRes(this.promise.then((r) => {
|
|
440
480
|
if (r.tag !== "Err") return passThrough(r);
|
|
441
481
|
try {
|
|
@@ -445,6 +485,10 @@ var AsyncRes = class AsyncRes {
|
|
|
445
485
|
}
|
|
446
486
|
}));
|
|
447
487
|
}
|
|
488
|
+
/** @deprecated Use {@link AsyncRes.recoverErr}. */
|
|
489
|
+
recover(f) {
|
|
490
|
+
return this.recoverErr(f);
|
|
491
|
+
}
|
|
448
492
|
tapErr(f) {
|
|
449
493
|
return new AsyncRes(this.promise.then((r) => {
|
|
450
494
|
if (r.tag !== "Err") return r;
|
|
@@ -491,17 +535,33 @@ var AsyncRes = class AsyncRes {
|
|
|
491
535
|
match(cases) {
|
|
492
536
|
return this.promise.then((r) => r.match(cases));
|
|
493
537
|
}
|
|
538
|
+
get() {
|
|
539
|
+
return this.promise.then((r) => r.get());
|
|
540
|
+
}
|
|
541
|
+
/** @deprecated Use {@link AsyncRes.get}. */
|
|
494
542
|
unwrap() {
|
|
495
|
-
return this.
|
|
543
|
+
return this.get();
|
|
544
|
+
}
|
|
545
|
+
getErr() {
|
|
546
|
+
return this.promise.then((r) => r.getErr());
|
|
496
547
|
}
|
|
548
|
+
/** @deprecated Use {@link AsyncRes.getErr}. */
|
|
497
549
|
unwrapErr() {
|
|
498
|
-
return this.
|
|
550
|
+
return this.getErr();
|
|
551
|
+
}
|
|
552
|
+
getOr(fallback) {
|
|
553
|
+
return this.promise.then((r) => r.getOr(fallback));
|
|
499
554
|
}
|
|
555
|
+
/** @deprecated Use {@link AsyncRes.getOr}. */
|
|
500
556
|
unwrapOr(fallback) {
|
|
501
|
-
return this.
|
|
557
|
+
return this.getOr(fallback);
|
|
502
558
|
}
|
|
559
|
+
getOrElse(f) {
|
|
560
|
+
return this.promise.then((r) => r.getOrElse(f));
|
|
561
|
+
}
|
|
562
|
+
/** @deprecated Use {@link AsyncRes.getOrElse}. */
|
|
503
563
|
unwrapOrElse(f) {
|
|
504
|
-
return this.
|
|
564
|
+
return this.getOrElse(f);
|
|
505
565
|
}
|
|
506
566
|
getOrNull() {
|
|
507
567
|
return this.promise.then((r) => r.getOrNull());
|
|
@@ -509,46 +569,59 @@ var AsyncRes = class AsyncRes {
|
|
|
509
569
|
getOrUndefined() {
|
|
510
570
|
return this.promise.then((r) => r.getOrUndefined());
|
|
511
571
|
}
|
|
572
|
+
getOrThrow() {
|
|
573
|
+
return this.promise.then((r) => r.getOrThrow());
|
|
574
|
+
}
|
|
512
575
|
};
|
|
513
576
|
//#endregion
|
|
514
577
|
//#region src/constructors.ts
|
|
578
|
+
function Ok(value) {
|
|
579
|
+
return okRes(value);
|
|
580
|
+
}
|
|
515
581
|
/**
|
|
516
|
-
* Construct a
|
|
582
|
+
* Construct a failed {@link Result} carrying a **modeled** error.
|
|
517
583
|
*
|
|
518
|
-
* @typeParam
|
|
519
|
-
* @param
|
|
584
|
+
* @typeParam E - the modeled error type.
|
|
585
|
+
* @param error - the domain error to wrap.
|
|
520
586
|
*
|
|
521
587
|
* @example
|
|
522
588
|
* ```ts
|
|
523
|
-
* import {
|
|
589
|
+
* import { Err } from "unthrown";
|
|
524
590
|
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
591
|
+
* Err("not_found").map((n) => n + 1); // => Err("not_found") (map skipped)
|
|
592
|
+
* Err("not_found").getErr(); // => "not_found"
|
|
527
593
|
* ```
|
|
528
594
|
*
|
|
529
595
|
* @category Constructors
|
|
530
596
|
*/
|
|
531
|
-
function
|
|
532
|
-
return
|
|
597
|
+
function Err(error) {
|
|
598
|
+
return errRes(error);
|
|
599
|
+
}
|
|
600
|
+
function OkAsync(value) {
|
|
601
|
+
return Ok(value).toAsync();
|
|
533
602
|
}
|
|
534
603
|
/**
|
|
535
|
-
* Construct a failed {@link
|
|
604
|
+
* Construct a failed {@link AsyncResult} carrying a **modeled** error — the
|
|
605
|
+
* pre-lifted form of {@link Err}, sparing you `Err(error).toAsync()`.
|
|
606
|
+
*
|
|
607
|
+
* @remarks
|
|
608
|
+
* The error-channel mirror of {@link OkAsync}; see it for the naming and the
|
|
609
|
+
* `AsyncResult.Err` companion alias.
|
|
536
610
|
*
|
|
537
611
|
* @typeParam E - the modeled error type.
|
|
538
612
|
* @param error - the domain error to wrap.
|
|
539
613
|
*
|
|
540
614
|
* @example
|
|
541
615
|
* ```ts
|
|
542
|
-
* import {
|
|
616
|
+
* import { ErrAsync } from "unthrown";
|
|
543
617
|
*
|
|
544
|
-
*
|
|
545
|
-
* Err("not_found").unwrapErr(); // => "not_found"
|
|
618
|
+
* ErrAsync("not_found"); // AsyncResult<never, string>
|
|
546
619
|
* ```
|
|
547
620
|
*
|
|
548
621
|
* @category Constructors
|
|
549
622
|
*/
|
|
550
|
-
function
|
|
551
|
-
return
|
|
623
|
+
function ErrAsync(error) {
|
|
624
|
+
return Err(error).toAsync();
|
|
552
625
|
}
|
|
553
626
|
/**
|
|
554
627
|
* Type guard: narrow a {@link Result} to its `Ok` variant, exposing `.value`.
|
|
@@ -717,9 +790,9 @@ function isDefectMarker(x) {
|
|
|
717
790
|
* import { fromNullable } from "unthrown";
|
|
718
791
|
*
|
|
719
792
|
* const map = new Map([["a", 1]]);
|
|
720
|
-
* fromNullable(map.get("a"), () => "absent").
|
|
793
|
+
* fromNullable(map.get("a"), () => "absent").getOr(0); // => 1
|
|
721
794
|
* fromNullable(map.get("z"), () => "absent"); // => Err("absent")
|
|
722
|
-
* fromNullable(0, () => "absent").
|
|
795
|
+
* fromNullable(0, () => "absent").getOr(-1); // => 0 (falsy but present)
|
|
723
796
|
* ```
|
|
724
797
|
*/
|
|
725
798
|
function fromNullable(value, onAbsent) {
|
|
@@ -739,7 +812,7 @@ function fromNullable(value, onAbsent) {
|
|
|
739
812
|
* `qualify`'s return is **subtracted** from `E`, never inferred into it. So a
|
|
740
813
|
* `qualify` that returns *only* `defect(cause)` yields `E = never` (a Defect is
|
|
741
814
|
* out-of-band and must not pollute the error channel); reach for
|
|
742
|
-
* {@link
|
|
815
|
+
* {@link fromSafeThrowable} when every throw is a Defect.
|
|
743
816
|
*
|
|
744
817
|
* @typeParam A - the wrapped function's argument tuple.
|
|
745
818
|
* @typeParam T - the wrapped function's return type.
|
|
@@ -763,7 +836,7 @@ function fromNullable(value, onAbsent) {
|
|
|
763
836
|
* cause instanceof SyntaxError ? ("invalid_json" as const) : defect(cause),
|
|
764
837
|
* );
|
|
765
838
|
*
|
|
766
|
-
* parse('{"ok":true}').
|
|
839
|
+
* parse('{"ok":true}').getOr(null); // => { ok: true }
|
|
767
840
|
* parse("nope"); // => Err("invalid_json")
|
|
768
841
|
* ```
|
|
769
842
|
*/
|
|
@@ -778,6 +851,44 @@ function fromThrowable(fn, qualify) {
|
|
|
778
851
|
};
|
|
779
852
|
}
|
|
780
853
|
/**
|
|
854
|
+
* Wrap a throwing synchronous function asserted **not** to fail in any modeled
|
|
855
|
+
* way: any throw becomes a `Defect`.
|
|
856
|
+
*
|
|
857
|
+
* @remarks
|
|
858
|
+
* The synchronous counterpart of {@link fromSafePromise}. Use it only when a
|
|
859
|
+
* throw genuinely indicates a bug rather than an anticipated outcome — the
|
|
860
|
+
* error channel is `never`, so there is nothing to triage; there is no
|
|
861
|
+
* `qualify`. When some throws *are* anticipated, reach for
|
|
862
|
+
* {@link fromThrowable} and triage them.
|
|
863
|
+
*
|
|
864
|
+
* @typeParam A - the wrapped function's argument tuple.
|
|
865
|
+
* @typeParam T - the wrapped function's return type.
|
|
866
|
+
* @param fn - the throwing function to wrap.
|
|
867
|
+
* @returns a function with the same arguments returning `Result<T, never>`.
|
|
868
|
+
*
|
|
869
|
+
* @category Interop
|
|
870
|
+
*
|
|
871
|
+
* @example
|
|
872
|
+
* ```ts
|
|
873
|
+
* import { fromSafeThrowable } from "unthrown";
|
|
874
|
+
*
|
|
875
|
+
* // A decode failure here is a bug (the row came from our own schema), so
|
|
876
|
+
* // every throw is a defect — no throwaway `(cause, defect) => defect(cause)`.
|
|
877
|
+
* const decode = fromSafeThrowable((row: Row) => userSchema.parse(row));
|
|
878
|
+
*
|
|
879
|
+
* decode(row); // => Result<User, never> — a throw becomes a Defect
|
|
880
|
+
* ```
|
|
881
|
+
*/
|
|
882
|
+
function fromSafeThrowable(fn) {
|
|
883
|
+
return (...args) => {
|
|
884
|
+
try {
|
|
885
|
+
return Ok(fn(...args));
|
|
886
|
+
} catch (cause) {
|
|
887
|
+
return defectRes(cause);
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
781
892
|
* Wrap a `Promise` (or a thunk producing one) as an {@link AsyncResult}, forcing
|
|
782
893
|
* every rejection to be triaged.
|
|
783
894
|
*
|
|
@@ -825,7 +936,8 @@ function fromPromise(promise, qualify) {
|
|
|
825
936
|
* @remarks
|
|
826
937
|
* Use this only when a rejection genuinely indicates a bug rather than an
|
|
827
938
|
* anticipated outcome — the error channel is `never`, so there is nothing to
|
|
828
|
-
* triage. (`await`-ing still yields a `Result`; it never throws.)
|
|
939
|
+
* triage. (`await`-ing still yields a `Result`; it never throws.) The
|
|
940
|
+
* synchronous counterpart is {@link fromSafeThrowable}.
|
|
829
941
|
*
|
|
830
942
|
* @typeParam T - the resolved value type.
|
|
831
943
|
* @param promise - the promise, or a thunk returning one.
|
|
@@ -836,7 +948,7 @@ function fromPromise(promise, qualify) {
|
|
|
836
948
|
* ```ts
|
|
837
949
|
* import { fromSafePromise } from "unthrown";
|
|
838
950
|
*
|
|
839
|
-
* (await fromSafePromise(Promise.resolve(3))).
|
|
951
|
+
* (await fromSafePromise(Promise.resolve(3))).get(); // => 3
|
|
840
952
|
* // a rejection becomes a Defect (never a modeled Err):
|
|
841
953
|
* await fromSafePromise(Promise.reject(new Error("boom"))); // => Defect(Error("boom"))
|
|
842
954
|
* ```
|
|
@@ -910,7 +1022,7 @@ function foldRecord(results) {
|
|
|
910
1022
|
* ```ts
|
|
911
1023
|
* import { all, Ok, Err } from "unthrown";
|
|
912
1024
|
*
|
|
913
|
-
* all([Ok(1), Ok("a"), Ok(true)]).
|
|
1025
|
+
* all([Ok(1), Ok("a"), Ok(true)]).get(); // => [1, "a", true] (typed [number, string, boolean])
|
|
914
1026
|
* all([Ok(1), Err("e"), Ok(3)]); // => Err("e") (short-circuits on the first Err)
|
|
915
1027
|
* ```
|
|
916
1028
|
*/
|
|
@@ -933,7 +1045,7 @@ function all(results) {
|
|
|
933
1045
|
* ```ts
|
|
934
1046
|
* import { allFromDict, Ok, Err } from "unthrown";
|
|
935
1047
|
*
|
|
936
|
-
* allFromDict({ id: Ok(1), name: Ok("ada") }).
|
|
1048
|
+
* allFromDict({ id: Ok(1), name: Ok("ada") }).get(); // => { id: 1, name: "ada" }
|
|
937
1049
|
* allFromDict({ id: Ok(1), name: Err("missing") }); // => Err("missing")
|
|
938
1050
|
* ```
|
|
939
1051
|
*/
|
|
@@ -957,7 +1069,7 @@ function allFromDict(results) {
|
|
|
957
1069
|
* import { allAsync, fromSafePromise } from "unthrown";
|
|
958
1070
|
*
|
|
959
1071
|
* const both = allAsync([fromSafePromise(Promise.resolve(1)), fromSafePromise(Promise.resolve(2))]);
|
|
960
|
-
* (await both).
|
|
1072
|
+
* (await both).get(); // => [1, 2]
|
|
961
1073
|
* ```
|
|
962
1074
|
*/
|
|
963
1075
|
function allAsync(results) {
|
|
@@ -981,7 +1093,7 @@ function allAsync(results) {
|
|
|
981
1093
|
* a: fromSafePromise(Promise.resolve(1)),
|
|
982
1094
|
* b: fromSafePromise(Promise.resolve("x")),
|
|
983
1095
|
* });
|
|
984
|
-
* (await both).
|
|
1096
|
+
* (await both).get(); // => { a: 1, b: "x" }
|
|
985
1097
|
* ```
|
|
986
1098
|
*/
|
|
987
1099
|
function allFromDictAsync(results) {
|
|
@@ -1000,8 +1112,9 @@ function allFromDictAsync(results) {
|
|
|
1000
1112
|
* Companion object grouping the **`Result`-producing** entry points under a
|
|
1001
1113
|
* single, discoverable namespace: {@link Result.Ok}, {@link Result.Err},
|
|
1002
1114
|
* {@link Result.Do}, {@link Result.fromNullable}, {@link Result.fromThrowable},
|
|
1003
|
-
* {@link Result.
|
|
1004
|
-
* {@link Result.
|
|
1115
|
+
* {@link Result.fromSafeThrowable}, {@link Result.all},
|
|
1116
|
+
* {@link Result.allFromDict}, {@link Result.isOk}, {@link Result.isErr},
|
|
1117
|
+
* {@link Result.isDefect}, {@link Result.isResult}.
|
|
1005
1118
|
*
|
|
1006
1119
|
* @remarks
|
|
1007
1120
|
* Purely additive sugar — each member **is** the corresponding free function.
|
|
@@ -1018,7 +1131,7 @@ function allFromDictAsync(results) {
|
|
|
1018
1131
|
* @example
|
|
1019
1132
|
* ```ts
|
|
1020
1133
|
* import { Result } from "unthrown";
|
|
1021
|
-
* Result.Ok(1).flatMap((n) => Result.Ok(n + 1)).
|
|
1134
|
+
* Result.Ok(1).flatMap((n) => Result.Ok(n + 1)).get(); // => 2
|
|
1022
1135
|
* ```
|
|
1023
1136
|
*/
|
|
1024
1137
|
const Result = {
|
|
@@ -1027,6 +1140,7 @@ const Result = {
|
|
|
1027
1140
|
Do,
|
|
1028
1141
|
fromNullable,
|
|
1029
1142
|
fromThrowable,
|
|
1143
|
+
fromSafeThrowable,
|
|
1030
1144
|
all,
|
|
1031
1145
|
allFromDict,
|
|
1032
1146
|
isOk,
|
|
@@ -1036,18 +1150,20 @@ const Result = {
|
|
|
1036
1150
|
};
|
|
1037
1151
|
/**
|
|
1038
1152
|
* Companion object grouping the **`AsyncResult`-producing** entry points under
|
|
1039
|
-
* the matching namespace: {@link AsyncResult.
|
|
1040
|
-
* {@link AsyncResult.
|
|
1041
|
-
* {@link AsyncResult.allFromDict}.
|
|
1153
|
+
* the matching namespace: {@link AsyncResult.Ok}, {@link AsyncResult.Err},
|
|
1154
|
+
* {@link AsyncResult.fromPromise}, {@link AsyncResult.fromSafePromise},
|
|
1155
|
+
* {@link AsyncResult.all}, {@link AsyncResult.allFromDict}.
|
|
1042
1156
|
*
|
|
1043
1157
|
* @remarks
|
|
1044
1158
|
* The async sibling of {@link Result}. Statics are grouped by what they
|
|
1045
|
-
* **return**, so `fromPromise`/`fromSafePromise
|
|
1046
|
-
* here rather than on {@link Result}; the namespace
|
|
1047
|
-
* the
|
|
1048
|
-
*
|
|
1049
|
-
*
|
|
1050
|
-
*
|
|
1159
|
+
* **return**, so the pre-lifted constructors, `fromPromise`/`fromSafePromise`,
|
|
1160
|
+
* and the async aggregates sit here rather than on {@link Result}; the namespace
|
|
1161
|
+
* already conveys "async", so the members drop the `Async` suffix their free
|
|
1162
|
+
* functions carry (`AsyncResult.Ok` is `OkAsync`; `AsyncResult.Err` is
|
|
1163
|
+
* `ErrAsync`; `AsyncResult.all` is `allAsync`; `AsyncResult.allFromDict` is
|
|
1164
|
+
* `allFromDictAsync`). Like {@link Result}, the free functions remain the
|
|
1165
|
+
* primary, tree-shakeable API; the value `AsyncResult` and the type
|
|
1166
|
+
* {@link AsyncResult} share one name.
|
|
1051
1167
|
*
|
|
1052
1168
|
* @category Facade
|
|
1053
1169
|
*
|
|
@@ -1055,10 +1171,12 @@ const Result = {
|
|
|
1055
1171
|
* ```ts
|
|
1056
1172
|
* import { AsyncResult } from "unthrown";
|
|
1057
1173
|
* const user = await AsyncResult.fromPromise(fetchUser(id), (c, defect) => defect(c));
|
|
1058
|
-
* user.
|
|
1174
|
+
* user.get(); // => the fetched user (on success)
|
|
1059
1175
|
* ```
|
|
1060
1176
|
*/
|
|
1061
1177
|
const AsyncResult = {
|
|
1178
|
+
Ok: OkAsync,
|
|
1179
|
+
Err: ErrAsync,
|
|
1062
1180
|
fromPromise,
|
|
1063
1181
|
fromSafePromise,
|
|
1064
1182
|
all: allAsync,
|
|
@@ -1147,6 +1265,6 @@ function matchTags(result, handlers) {
|
|
|
1147
1265
|
});
|
|
1148
1266
|
}
|
|
1149
1267
|
//#endregion
|
|
1150
|
-
export { AsyncResult, Do, Err, Ok, Result, TaggedError, UnwrapError, all, allAsync, allFromDict, allFromDictAsync, fromNullable, fromPromise, fromSafePromise, fromThrowable, isDefect, isErr, isOk, isResult, matchTags };
|
|
1268
|
+
export { AsyncResult, Do, Err, ErrAsync, Ok, OkAsync, Result, TaggedError, UnwrapError, all, allAsync, allFromDict, allFromDictAsync, fromNullable, fromPromise, fromSafePromise, fromSafeThrowable, fromThrowable, isDefect, isErr, isOk, isResult, matchTags };
|
|
1151
1269
|
|
|
1152
1270
|
//# sourceMappingURL=index.mjs.map
|