@unthrown/boxed 0.3.0 → 1.1.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 +2 -2
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +6 -6
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +9 -9
- package/dist/index.mjs.map +1 -1
- package/docs/index.md +10 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,11 +16,11 @@ Boxed's `Result` has two channels (`Ok`/`Error`) and no defect channel. Coming
|
|
|
16
16
|
with `onDefect` — no defect is ever silently folded into your domain error type.
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
|
-
import {
|
|
19
|
+
import { Ok } from "unthrown";
|
|
20
20
|
import { toBoxed, fromBoxed } from "@unthrown/boxed";
|
|
21
21
|
import { Result } from "@bloodyowl/boxed";
|
|
22
22
|
|
|
23
|
-
toBoxed(
|
|
23
|
+
toBoxed(Ok(1), (cause) => ({ _tag: "Bug", cause })); // Result.Ok(1)
|
|
24
24
|
fromBoxed(Result.Ok(1)); // Result<number, never>
|
|
25
25
|
```
|
|
26
26
|
|
package/dist/index.cjs
CHANGED
|
@@ -3,17 +3,17 @@ let _bloodyowl_boxed = require("@bloodyowl/boxed");
|
|
|
3
3
|
let unthrown = require("unthrown");
|
|
4
4
|
//#region src/index.ts
|
|
5
5
|
/**
|
|
6
|
-
* Convert a `Result` into a Boxed `Result`, triaging any
|
|
6
|
+
* Convert a `Result` into a Boxed `Result`, triaging any Defect.
|
|
7
7
|
*
|
|
8
8
|
* @remarks
|
|
9
|
-
* Boxed's `Result` has no
|
|
9
|
+
* Boxed's `Result` has no Defect channel, so `onDefect` **must** fold a
|
|
10
10
|
* `Defect`'s cause into a modeled error `E` (an `Error`). `Ok → Result.Ok`,
|
|
11
11
|
* `Err → Result.Error`, `Defect → Result.Error(onDefect(cause))`.
|
|
12
12
|
*
|
|
13
13
|
* @typeParam T - the success value type.
|
|
14
14
|
* @typeParam E - the modeled error type.
|
|
15
15
|
* @param result - the result to convert.
|
|
16
|
-
* @param onDefect - folds a
|
|
16
|
+
* @param onDefect - folds a Defect's unknown cause into a modeled `E`.
|
|
17
17
|
*/
|
|
18
18
|
function toBoxed(result, onDefect) {
|
|
19
19
|
return result.match({
|
|
@@ -26,7 +26,7 @@ function toBoxed(result, onDefect) {
|
|
|
26
26
|
* Convert a Boxed `Result` into a `Result`.
|
|
27
27
|
*
|
|
28
28
|
* @remarks
|
|
29
|
-
* `Result.Ok → Ok`, `Result.Error → Err`. Boxed's `Result` carries no
|
|
29
|
+
* `Result.Ok → Ok`, `Result.Error → Err`. Boxed's `Result` carries no Defect, so
|
|
30
30
|
* the result is never a `Defect`.
|
|
31
31
|
*
|
|
32
32
|
* @typeParam T - the success value type.
|
|
@@ -35,13 +35,13 @@ function toBoxed(result, onDefect) {
|
|
|
35
35
|
*/
|
|
36
36
|
function fromBoxed(result) {
|
|
37
37
|
return result.match({
|
|
38
|
-
Ok: (value) => (0, unthrown.
|
|
39
|
-
Error: (error) => (0, unthrown.
|
|
38
|
+
Ok: (value) => (0, unthrown.Ok)(value),
|
|
39
|
+
Error: (error) => (0, unthrown.Err)(error)
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Convert an `AsyncResult` into a Boxed `Future<Result>`, triaging any
|
|
44
|
-
*
|
|
44
|
+
* Defect.
|
|
45
45
|
*
|
|
46
46
|
* @remarks
|
|
47
47
|
* The async counterpart of {@link toBoxed}: `onDefect` is required for the same
|
|
@@ -51,7 +51,7 @@ function fromBoxed(result) {
|
|
|
51
51
|
* @typeParam T - the success value type.
|
|
52
52
|
* @typeParam E - the modeled error type.
|
|
53
53
|
* @param asyncResult - the async result to convert.
|
|
54
|
-
* @param onDefect - folds a
|
|
54
|
+
* @param onDefect - folds a Defect's unknown cause into a modeled `E`.
|
|
55
55
|
*/
|
|
56
56
|
function toBoxedFuture(asyncResult, onDefect) {
|
|
57
57
|
return _bloodyowl_boxed.Future.make((resolve) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -3,24 +3,24 @@ import { AsyncResult, Result as Result$1 } from "unthrown";
|
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
5
|
/**
|
|
6
|
-
* Convert a `Result` into a Boxed `Result`, triaging any
|
|
6
|
+
* Convert a `Result` into a Boxed `Result`, triaging any Defect.
|
|
7
7
|
*
|
|
8
8
|
* @remarks
|
|
9
|
-
* Boxed's `Result` has no
|
|
9
|
+
* Boxed's `Result` has no Defect channel, so `onDefect` **must** fold a
|
|
10
10
|
* `Defect`'s cause into a modeled error `E` (an `Error`). `Ok → Result.Ok`,
|
|
11
11
|
* `Err → Result.Error`, `Defect → Result.Error(onDefect(cause))`.
|
|
12
12
|
*
|
|
13
13
|
* @typeParam T - the success value type.
|
|
14
14
|
* @typeParam E - the modeled error type.
|
|
15
15
|
* @param result - the result to convert.
|
|
16
|
-
* @param onDefect - folds a
|
|
16
|
+
* @param onDefect - folds a Defect's unknown cause into a modeled `E`.
|
|
17
17
|
*/
|
|
18
18
|
declare function toBoxed<T, E>(result: Result$1<T, E>, onDefect: (cause: unknown) => E): Result<T, E>;
|
|
19
19
|
/**
|
|
20
20
|
* Convert a Boxed `Result` into a `Result`.
|
|
21
21
|
*
|
|
22
22
|
* @remarks
|
|
23
|
-
* `Result.Ok → Ok`, `Result.Error → Err`. Boxed's `Result` carries no
|
|
23
|
+
* `Result.Ok → Ok`, `Result.Error → Err`. Boxed's `Result` carries no Defect, so
|
|
24
24
|
* the result is never a `Defect`.
|
|
25
25
|
*
|
|
26
26
|
* @typeParam T - the success value type.
|
|
@@ -30,7 +30,7 @@ declare function toBoxed<T, E>(result: Result$1<T, E>, onDefect: (cause: unknown
|
|
|
30
30
|
declare function fromBoxed<T, E>(result: Result<T, E>): Result$1<T, E>;
|
|
31
31
|
/**
|
|
32
32
|
* Convert an `AsyncResult` into a Boxed `Future<Result>`, triaging any
|
|
33
|
-
*
|
|
33
|
+
* Defect.
|
|
34
34
|
*
|
|
35
35
|
* @remarks
|
|
36
36
|
* The async counterpart of {@link toBoxed}: `onDefect` is required for the same
|
|
@@ -40,7 +40,7 @@ declare function fromBoxed<T, E>(result: Result<T, E>): Result$1<T, E>;
|
|
|
40
40
|
* @typeParam T - the success value type.
|
|
41
41
|
* @typeParam E - the modeled error type.
|
|
42
42
|
* @param asyncResult - the async result to convert.
|
|
43
|
-
* @param onDefect - folds a
|
|
43
|
+
* @param onDefect - folds a Defect's unknown cause into a modeled `E`.
|
|
44
44
|
*/
|
|
45
45
|
declare function toBoxedFuture<T, E>(asyncResult: AsyncResult<T, E>, onDefect: (cause: unknown) => E): Future<Result<T, E>>;
|
|
46
46
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -3,24 +3,24 @@ import { AsyncResult, Result as Result$1 } from "unthrown";
|
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
5
|
/**
|
|
6
|
-
* Convert a `Result` into a Boxed `Result`, triaging any
|
|
6
|
+
* Convert a `Result` into a Boxed `Result`, triaging any Defect.
|
|
7
7
|
*
|
|
8
8
|
* @remarks
|
|
9
|
-
* Boxed's `Result` has no
|
|
9
|
+
* Boxed's `Result` has no Defect channel, so `onDefect` **must** fold a
|
|
10
10
|
* `Defect`'s cause into a modeled error `E` (an `Error`). `Ok → Result.Ok`,
|
|
11
11
|
* `Err → Result.Error`, `Defect → Result.Error(onDefect(cause))`.
|
|
12
12
|
*
|
|
13
13
|
* @typeParam T - the success value type.
|
|
14
14
|
* @typeParam E - the modeled error type.
|
|
15
15
|
* @param result - the result to convert.
|
|
16
|
-
* @param onDefect - folds a
|
|
16
|
+
* @param onDefect - folds a Defect's unknown cause into a modeled `E`.
|
|
17
17
|
*/
|
|
18
18
|
declare function toBoxed<T, E>(result: Result$1<T, E>, onDefect: (cause: unknown) => E): Result<T, E>;
|
|
19
19
|
/**
|
|
20
20
|
* Convert a Boxed `Result` into a `Result`.
|
|
21
21
|
*
|
|
22
22
|
* @remarks
|
|
23
|
-
* `Result.Ok → Ok`, `Result.Error → Err`. Boxed's `Result` carries no
|
|
23
|
+
* `Result.Ok → Ok`, `Result.Error → Err`. Boxed's `Result` carries no Defect, so
|
|
24
24
|
* the result is never a `Defect`.
|
|
25
25
|
*
|
|
26
26
|
* @typeParam T - the success value type.
|
|
@@ -30,7 +30,7 @@ declare function toBoxed<T, E>(result: Result$1<T, E>, onDefect: (cause: unknown
|
|
|
30
30
|
declare function fromBoxed<T, E>(result: Result<T, E>): Result$1<T, E>;
|
|
31
31
|
/**
|
|
32
32
|
* Convert an `AsyncResult` into a Boxed `Future<Result>`, triaging any
|
|
33
|
-
*
|
|
33
|
+
* Defect.
|
|
34
34
|
*
|
|
35
35
|
* @remarks
|
|
36
36
|
* The async counterpart of {@link toBoxed}: `onDefect` is required for the same
|
|
@@ -40,7 +40,7 @@ declare function fromBoxed<T, E>(result: Result<T, E>): Result$1<T, E>;
|
|
|
40
40
|
* @typeParam T - the success value type.
|
|
41
41
|
* @typeParam E - the modeled error type.
|
|
42
42
|
* @param asyncResult - the async result to convert.
|
|
43
|
-
* @param onDefect - folds a
|
|
43
|
+
* @param onDefect - folds a Defect's unknown cause into a modeled `E`.
|
|
44
44
|
*/
|
|
45
45
|
declare function toBoxedFuture<T, E>(asyncResult: AsyncResult<T, E>, onDefect: (cause: unknown) => E): Future<Result<T, E>>;
|
|
46
46
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Future, Result } from "@bloodyowl/boxed";
|
|
2
|
-
import {
|
|
2
|
+
import { Err, Ok, fromSafePromise } from "unthrown";
|
|
3
3
|
//#region src/index.ts
|
|
4
4
|
/**
|
|
5
|
-
* Convert a `Result` into a Boxed `Result`, triaging any
|
|
5
|
+
* Convert a `Result` into a Boxed `Result`, triaging any Defect.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
* Boxed's `Result` has no
|
|
8
|
+
* Boxed's `Result` has no Defect channel, so `onDefect` **must** fold a
|
|
9
9
|
* `Defect`'s cause into a modeled error `E` (an `Error`). `Ok → Result.Ok`,
|
|
10
10
|
* `Err → Result.Error`, `Defect → Result.Error(onDefect(cause))`.
|
|
11
11
|
*
|
|
12
12
|
* @typeParam T - the success value type.
|
|
13
13
|
* @typeParam E - the modeled error type.
|
|
14
14
|
* @param result - the result to convert.
|
|
15
|
-
* @param onDefect - folds a
|
|
15
|
+
* @param onDefect - folds a Defect's unknown cause into a modeled `E`.
|
|
16
16
|
*/
|
|
17
17
|
function toBoxed(result, onDefect) {
|
|
18
18
|
return result.match({
|
|
@@ -25,7 +25,7 @@ function toBoxed(result, onDefect) {
|
|
|
25
25
|
* Convert a Boxed `Result` into a `Result`.
|
|
26
26
|
*
|
|
27
27
|
* @remarks
|
|
28
|
-
* `Result.Ok → Ok`, `Result.Error → Err`. Boxed's `Result` carries no
|
|
28
|
+
* `Result.Ok → Ok`, `Result.Error → Err`. Boxed's `Result` carries no Defect, so
|
|
29
29
|
* the result is never a `Defect`.
|
|
30
30
|
*
|
|
31
31
|
* @typeParam T - the success value type.
|
|
@@ -34,13 +34,13 @@ function toBoxed(result, onDefect) {
|
|
|
34
34
|
*/
|
|
35
35
|
function fromBoxed(result) {
|
|
36
36
|
return result.match({
|
|
37
|
-
Ok: (value) =>
|
|
38
|
-
Error: (error) =>
|
|
37
|
+
Ok: (value) => Ok(value),
|
|
38
|
+
Error: (error) => Err(error)
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Convert an `AsyncResult` into a Boxed `Future<Result>`, triaging any
|
|
43
|
-
*
|
|
43
|
+
* Defect.
|
|
44
44
|
*
|
|
45
45
|
* @remarks
|
|
46
46
|
* The async counterpart of {@link toBoxed}: `onDefect` is required for the same
|
|
@@ -50,7 +50,7 @@ function fromBoxed(result) {
|
|
|
50
50
|
* @typeParam T - the success value type.
|
|
51
51
|
* @typeParam E - the modeled error type.
|
|
52
52
|
* @param asyncResult - the async result to convert.
|
|
53
|
-
* @param onDefect - folds a
|
|
53
|
+
* @param onDefect - folds a Defect's unknown cause into a modeled `E`.
|
|
54
54
|
*/
|
|
55
55
|
function toBoxedFuture(asyncResult, onDefect) {
|
|
56
56
|
return Future.make((resolve) => {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["BoxedResult"],"sources":["../src/index.ts"],"sourcesContent":["// @unthrown/boxed — interop between unthrown's `Result`/`AsyncResult` and\n// Boxed's `Result`/`Future<Result>`.\n//\n// Boxed's `Result` has two channels (`Ok`/`Error`) and no
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["BoxedResult"],"sources":["../src/index.ts"],"sourcesContent":["// @unthrown/boxed — interop between unthrown's `Result`/`AsyncResult` and\n// Boxed's `Result`/`Future<Result>`.\n//\n// Boxed's `Result` has two channels (`Ok`/`Error`) and no Defect channel.\n// Coming *in*, every Boxed result is an `Ok` or `Error` — never a `Defect`.\n// Going *out*, a `Defect` has nowhere to live, so `toBoxed` forces you to triage\n// it with `onDefect` (Thesis #3): no Defect is ever silently folded into your\n// domain error type.\n//\n// import { Ok } from \"unthrown\";\n// import { toBoxed, fromBoxed } from \"@unthrown/boxed\";\n//\n// toBoxed(Ok(1), (cause) => ({ _tag: \"Bug\", cause })); // Result.Ok(1)\n// fromBoxed(Result.Ok(1)); // Result<number, never>\n\nimport { Future, Result as BoxedResult } from \"@bloodyowl/boxed\";\nimport { Err, fromSafePromise, Ok } from \"unthrown\";\nimport type { AsyncResult, Result } from \"unthrown\";\n\n/**\n * Convert a `Result` into a Boxed `Result`, triaging any Defect.\n *\n * @remarks\n * Boxed's `Result` has no Defect channel, so `onDefect` **must** fold a\n * `Defect`'s cause into a modeled error `E` (an `Error`). `Ok → Result.Ok`,\n * `Err → Result.Error`, `Defect → Result.Error(onDefect(cause))`.\n *\n * @typeParam T - the success value type.\n * @typeParam E - the modeled error type.\n * @param result - the result to convert.\n * @param onDefect - folds a Defect's unknown cause into a modeled `E`.\n */\nexport function toBoxed<T, E>(\n result: Result<T, E>,\n onDefect: (cause: unknown) => E,\n): BoxedResult<T, E> {\n return result.match<BoxedResult<T, E>>({\n ok: (value) => BoxedResult.Ok(value),\n err: (error) => BoxedResult.Error(error),\n defect: (cause) => BoxedResult.Error(onDefect(cause)),\n });\n}\n\n/**\n * Convert a Boxed `Result` into a `Result`.\n *\n * @remarks\n * `Result.Ok → Ok`, `Result.Error → Err`. Boxed's `Result` carries no Defect, so\n * the result is never a `Defect`.\n *\n * @typeParam T - the success value type.\n * @typeParam E - the modeled error type.\n * @param result - the Boxed result to convert.\n */\nexport function fromBoxed<T, E>(result: BoxedResult<T, E>): Result<T, E> {\n return result.match({\n Ok: (value) => Ok(value),\n Error: (error) => Err(error),\n });\n}\n\n/**\n * Convert an `AsyncResult` into a Boxed `Future<Result>`, triaging any\n * Defect.\n *\n * @remarks\n * The async counterpart of {@link toBoxed}: `onDefect` is required for the same\n * reason. The `AsyncResult` is awaited (it never rejects) and its settled\n * `Result` is converted, then resolved into the `Future`.\n *\n * @typeParam T - the success value type.\n * @typeParam E - the modeled error type.\n * @param asyncResult - the async result to convert.\n * @param onDefect - folds a Defect's unknown cause into a modeled `E`.\n */\nexport function toBoxedFuture<T, E>(\n asyncResult: AsyncResult<T, E>,\n onDefect: (cause: unknown) => E,\n): Future<BoxedResult<T, E>> {\n return Future.make<BoxedResult<T, E>>((resolve) => {\n void settle(asyncResult).then((result) => {\n resolve(toBoxed(result, onDefect));\n });\n });\n}\n\n/**\n * Convert a Boxed `Future<Result>` into an `AsyncResult`.\n *\n * @remarks\n * The async counterpart of {@link fromBoxed}. A `Result.Error` stays an `Err`;\n * an *unexpected* rejection of the underlying promise becomes a `Defect`. The\n * returned `AsyncResult` never throws when awaited.\n *\n * @typeParam T - the success value type.\n * @typeParam E - the modeled error type.\n * @param future - the Boxed future to convert.\n */\nexport function fromBoxedFuture<T, E>(future: Future<BoxedResult<T, E>>): AsyncResult<T, E> {\n return fromSafePromise(future.toPromise()).flatMap((result) => fromBoxed(result));\n}\n\nfunction settle<T, E>(asyncResult: AsyncResult<T, E>): Promise<Result<T, E>> {\n return (async () => await asyncResult)();\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,SAAgB,QACd,QACA,UACmB;CACnB,OAAO,OAAO,MAAyB;EACrC,KAAK,UAAUA,OAAY,GAAG,KAAK;EACnC,MAAM,UAAUA,OAAY,MAAM,KAAK;EACvC,SAAS,UAAUA,OAAY,MAAM,SAAS,KAAK,CAAC;CACtD,CAAC;AACH;;;;;;;;;;;;AAaA,SAAgB,UAAgB,QAAyC;CACvE,OAAO,OAAO,MAAM;EAClB,KAAK,UAAU,GAAG,KAAK;EACvB,QAAQ,UAAU,IAAI,KAAK;CAC7B,CAAC;AACH;;;;;;;;;;;;;;;AAgBA,SAAgB,cACd,aACA,UAC2B;CAC3B,OAAO,OAAO,MAAyB,YAAY;EACjD,OAAY,WAAW,CAAC,CAAC,MAAM,WAAW;GACxC,QAAQ,QAAQ,QAAQ,QAAQ,CAAC;EACnC,CAAC;CACH,CAAC;AACH;;;;;;;;;;;;;AAcA,SAAgB,gBAAsB,QAAsD;CAC1F,OAAO,gBAAgB,OAAO,UAAU,CAAC,CAAC,CAAC,SAAS,WAAW,UAAU,MAAM,CAAC;AAClF;AAEA,SAAS,OAAa,aAAuD;CAC3E,QAAQ,YAAY,MAAM,YAAA,CAAa;AACzC"}
|
package/docs/index.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
function fromBoxed<T, E>(result): Result<T, E>;
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Defined in: [index.ts:55](https://github.com/btravstack/unthrown/blob/
|
|
15
|
+
Defined in: [index.ts:55](https://github.com/btravstack/unthrown/blob/8424c0f1e5d5b49a3cb6853d52fb8d5085bd4701/packages/boxed/src/index.ts#L55)
|
|
16
16
|
|
|
17
17
|
Convert a Boxed `Result` into a `Result`.
|
|
18
18
|
|
|
@@ -35,7 +35,7 @@ Convert a Boxed `Result` into a `Result`.
|
|
|
35
35
|
|
|
36
36
|
#### Remarks
|
|
37
37
|
|
|
38
|
-
`Result.Ok → Ok`, `Result.Error → Err`. Boxed's `Result` carries no
|
|
38
|
+
`Result.Ok → Ok`, `Result.Error → Err`. Boxed's `Result` carries no Defect, so
|
|
39
39
|
the result is never a `Defect`.
|
|
40
40
|
|
|
41
41
|
***
|
|
@@ -46,7 +46,7 @@ the result is never a `Defect`.
|
|
|
46
46
|
function fromBoxedFuture<T, E>(future): AsyncResult<T, E>;
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
Defined in: [index.ts:99](https://github.com/btravstack/unthrown/blob/
|
|
49
|
+
Defined in: [index.ts:99](https://github.com/btravstack/unthrown/blob/8424c0f1e5d5b49a3cb6853d52fb8d5085bd4701/packages/boxed/src/index.ts#L99)
|
|
50
50
|
|
|
51
51
|
Convert a Boxed `Future<Result>` into an `AsyncResult`.
|
|
52
52
|
|
|
@@ -81,9 +81,9 @@ returned `AsyncResult` never throws when awaited.
|
|
|
81
81
|
function toBoxed<T, E>(result, onDefect): Result<T, E>;
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
Defined in: [index.ts:33](https://github.com/btravstack/unthrown/blob/
|
|
84
|
+
Defined in: [index.ts:33](https://github.com/btravstack/unthrown/blob/8424c0f1e5d5b49a3cb6853d52fb8d5085bd4701/packages/boxed/src/index.ts#L33)
|
|
85
85
|
|
|
86
|
-
Convert a `Result` into a Boxed `Result`, triaging any
|
|
86
|
+
Convert a `Result` into a Boxed `Result`, triaging any Defect.
|
|
87
87
|
|
|
88
88
|
#### Type Parameters
|
|
89
89
|
|
|
@@ -97,7 +97,7 @@ Convert a `Result` into a Boxed `Result`, triaging any defect.
|
|
|
97
97
|
| Parameter | Type | Description |
|
|
98
98
|
| ------ | ------ | ------ |
|
|
99
99
|
| `result` | `Result`<`T`, `E`> | the result to convert. |
|
|
100
|
-
| `onDefect` | (`cause`) => `E` | folds a
|
|
100
|
+
| `onDefect` | (`cause`) => `E` | folds a Defect's unknown cause into a modeled `E`. |
|
|
101
101
|
|
|
102
102
|
#### Returns
|
|
103
103
|
|
|
@@ -105,7 +105,7 @@ Convert a `Result` into a Boxed `Result`, triaging any defect.
|
|
|
105
105
|
|
|
106
106
|
#### Remarks
|
|
107
107
|
|
|
108
|
-
Boxed's `Result` has no
|
|
108
|
+
Boxed's `Result` has no Defect channel, so `onDefect` **must** fold a
|
|
109
109
|
`Defect`'s cause into a modeled error `E` (an `Error`). `Ok → Result.Ok`,
|
|
110
110
|
`Err → Result.Error`, `Defect → Result.Error(onDefect(cause))`.
|
|
111
111
|
|
|
@@ -117,10 +117,10 @@ Boxed's `Result` has no defect channel, so `onDefect` **must** fold a
|
|
|
117
117
|
function toBoxedFuture<T, E>(asyncResult, onDefect): Future<Result<T, E>>;
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
-
Defined in: [index.ts:76](https://github.com/btravstack/unthrown/blob/
|
|
120
|
+
Defined in: [index.ts:76](https://github.com/btravstack/unthrown/blob/8424c0f1e5d5b49a3cb6853d52fb8d5085bd4701/packages/boxed/src/index.ts#L76)
|
|
121
121
|
|
|
122
122
|
Convert an `AsyncResult` into a Boxed `Future<Result>`, triaging any
|
|
123
|
-
|
|
123
|
+
Defect.
|
|
124
124
|
|
|
125
125
|
#### Type Parameters
|
|
126
126
|
|
|
@@ -134,7 +134,7 @@ defect.
|
|
|
134
134
|
| Parameter | Type | Description |
|
|
135
135
|
| ------ | ------ | ------ |
|
|
136
136
|
| `asyncResult` | `AsyncResult`<`T`, `E`> | the async result to convert. |
|
|
137
|
-
| `onDefect` | (`cause`) => `E` | folds a
|
|
137
|
+
| `onDefect` | (`cause`) => `E` | folds a Defect's unknown cause into a modeled `E`. |
|
|
138
138
|
|
|
139
139
|
#### Returns
|
|
140
140
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unthrown/boxed",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Boxed interop for unthrown",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"boxed",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"./package.json": "./package.json"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"unthrown": "
|
|
47
|
+
"unthrown": "1.1.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@bloodyowl/boxed": "3.4.0",
|