unthrown 0.1.0 → 0.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/docs/index.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ### UnwrapError
10
10
 
11
- Defined in: [packages/core/src/core.ts:29](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/core.ts#L29)
11
+ Defined in: [packages/core/src/core.ts:29](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/core.ts#L29)
12
12
 
13
13
  Thrown by a [Result](#result)'s `unwrap` / `unwrapErr` when the assertion is
14
14
  wrong on a *modeled* result — `unwrap()` on an `Err`, or `unwrapErr()` on an
@@ -37,7 +37,7 @@ re-thrown (with its original stack) instead.
37
37
  new UnwrapError<E>(error): UnwrapError<E>;
38
38
  ```
39
39
 
40
- Defined in: [packages/core/src/core.ts:35](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/core.ts#L35)
40
+ Defined in: [packages/core/src/core.ts:35](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/core.ts#L35)
41
41
 
42
42
  ###### Parameters
43
43
 
@@ -60,7 +60,7 @@ Error.constructor
60
60
  | Property | Modifier | Type | Description | Inherited from | Defined in |
61
61
  | ------ | ------ | ------ | ------ | ------ | ------ |
62
62
  | <a id="cause"></a> `cause?` | `public` | `unknown` | - | `Error.cause` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 |
63
- | <a id="error"></a> `error` | `readonly` | `E` | The offending value: the `Err` error for `unwrap()`, or the `Ok` value for `unwrapErr()`. | - | [packages/core/src/core.ts:34](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/core.ts#L34) |
63
+ | <a id="error"></a> `error` | `readonly` | `E` | The offending value: the `Err` error for `unwrap()`, or the `Ok` value for `unwrapErr()`. | - | [packages/core/src/core.ts:34](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/core.ts#L34) |
64
64
  | <a id="message"></a> `message` | `public` | `string` | - | `Error.message` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 |
65
65
  | <a id="name"></a> `name` | `public` | `string` | - | `Error.name` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 |
66
66
  | <a id="stack"></a> `stack?` | `public` | `string` | - | `Error.stack` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
@@ -168,13 +168,49 @@ Error.prepareStackTrace
168
168
 
169
169
  ## Type Aliases
170
170
 
171
+ ### AsyncErrOf
172
+
173
+ ```ts
174
+ type AsyncErrOf<R> = R extends AsyncResult<unknown, infer E> ? E : never;
175
+ ```
176
+
177
+ Defined in: [packages/core/src/types.ts:350](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L350)
178
+
179
+ Extract the error type `E` from an [AsyncResult](#asyncresult).
180
+
181
+ #### Type Parameters
182
+
183
+ | Type Parameter | Description |
184
+ | ------ | ------ |
185
+ | `R` | the `AsyncResult` type to inspect. |
186
+
187
+ ***
188
+
189
+ ### AsyncOkOf
190
+
191
+ ```ts
192
+ type AsyncOkOf<R> = R extends AsyncResult<infer T, unknown> ? T : never;
193
+ ```
194
+
195
+ Defined in: [packages/core/src/types.ts:344](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L344)
196
+
197
+ Extract the success type `T` from an [AsyncResult](#asyncresult).
198
+
199
+ #### Type Parameters
200
+
201
+ | Type Parameter | Description |
202
+ | ------ | ------ |
203
+ | `R` | the `AsyncResult` type to inspect. |
204
+
205
+ ***
206
+
171
207
  ### AsyncResult
172
208
 
173
209
  ```ts
174
210
  type AsyncResult<T, E> = Awaitable<Result<T, E>> & object;
175
211
  ```
176
212
 
177
- Defined in: [packages/core/src/types.ts:278](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L278)
213
+ Defined in: [packages/core/src/types.ts:278](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L278)
178
214
 
179
215
  The asynchronous counterpart of [Result](#result): an awaitable wrapper with the
180
216
  same method surface, collapsing to a `Result<T, E>` when `await`-ed.
@@ -183,23 +219,23 @@ same method surface, collapsing to a `Result<T, E>` when `await`-ed.
183
219
 
184
220
  | Name | Type | Description | Defined in |
185
221
  | ------ | ------ | ------ | ------ |
186
- | `as()` | (`value`) => [`AsyncResult`](#asyncresult)&lt;`U`, `E`&gt; | Asynchronous `as`. | [packages/core/src/types.ts:289](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L289) |
187
- | `flatMap()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`U`, `E` \| `E2`&gt; | Asynchronous `flatMap`. `f` may return a `Result` **or** an `AsyncResult` (never a raw `Promise`); a throw becomes a `Defect`. | [packages/core/src/types.ts:285](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L285) |
188
- | `getOrNull()` | () => `Promise`&lt;`T` \| `null`&gt; | Asynchronous `getOrNull`. | [packages/core/src/types.ts:322](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L322) |
189
- | `getOrUndefined()` | () => `Promise`&lt;`T` \| `undefined`&gt; | Asynchronous `getOrUndefined`. | [packages/core/src/types.ts:324](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L324) |
190
- | `map()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`U`, `E`&gt; | Asynchronous `map`. `f` is synchronous; a throw becomes a `Defect`. | [packages/core/src/types.ts:280](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L280) |
191
- | `mapErr()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`T`, `E2`&gt; | Asynchronous `mapErr`. `f` is synchronous; a throw becomes a `Defect`. | [packages/core/src/types.ts:292](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L292) |
192
- | `match()` | (`cases`) => `Promise`&lt;`R`&gt; | Asynchronous `match`. Handlers are synchronous; resolves to `R`. | [packages/core/src/types.ts:308](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L308) |
193
- | `orElse()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`T` \| `U`, `E2`&gt; | Asynchronous `orElse`. `f` may return a `Result` or an `AsyncResult`. | [packages/core/src/types.ts:294](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L294) |
194
- | `recover()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`T` \| `U`, `never`&gt; | Asynchronous `recover`. `f` is synchronous; a throw becomes a `Defect`. | [packages/core/src/types.ts:296](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L296) |
195
- | `recoverDefect()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`T` \| `U`, `E` \| `E2`&gt; | Asynchronous `recoverDefect`. `f` may return a `Result` or an `AsyncResult`. | [packages/core/src/types.ts:301](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L301) |
196
- | `tap()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`T`, `E`&gt; | Asynchronous `tap`. `f` is synchronous; a throw becomes a `Defect`. | [packages/core/src/types.ts:287](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L287) |
197
- | `tapDefect()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`T`, `E`&gt; | Asynchronous `tapDefect`. | [packages/core/src/types.ts:305](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L305) |
198
- | `tapErr()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`T`, `E`&gt; | Asynchronous `tapErr`. `f` is synchronous; a throw becomes a `Defect`. | [packages/core/src/types.ts:298](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L298) |
199
- | `unwrap()` | () => `Promise`&lt;`T`&gt; | Asynchronous `unwrap`. The returned promise rejects on `Err`/`Defect`. | [packages/core/src/types.ts:314](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L314) |
200
- | `unwrapErr()` | () => `Promise`&lt;`E`&gt; | Asynchronous `unwrapErr`. | [packages/core/src/types.ts:316](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L316) |
201
- | `unwrapOr()` | (`fallback`) => `Promise`&lt;`T`&gt; | Asynchronous `unwrapOr`. | [packages/core/src/types.ts:318](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L318) |
202
- | `unwrapOrElse()` | (`f`) => `Promise`&lt;`T`&gt; | Asynchronous `unwrapOrElse`. | [packages/core/src/types.ts:320](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L320) |
222
+ | `as()` | (`value`) => [`AsyncResult`](#asyncresult)&lt;`U`, `E`&gt; | Asynchronous `as`. | [packages/core/src/types.ts:289](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L289) |
223
+ | `flatMap()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`U`, `E` \| `E2`&gt; | Asynchronous `flatMap`. `f` may return a `Result` **or** an `AsyncResult` (never a raw `Promise`); a throw becomes a `Defect`. | [packages/core/src/types.ts:285](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L285) |
224
+ | `getOrNull()` | () => `Promise`&lt;`T` \| `null`&gt; | Asynchronous `getOrNull`. | [packages/core/src/types.ts:322](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L322) |
225
+ | `getOrUndefined()` | () => `Promise`&lt;`T` \| `undefined`&gt; | Asynchronous `getOrUndefined`. | [packages/core/src/types.ts:324](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L324) |
226
+ | `map()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`U`, `E`&gt; | Asynchronous `map`. `f` is synchronous; a throw becomes a `Defect`. | [packages/core/src/types.ts:280](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L280) |
227
+ | `mapErr()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`T`, `E2`&gt; | Asynchronous `mapErr`. `f` is synchronous; a throw becomes a `Defect`. | [packages/core/src/types.ts:292](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L292) |
228
+ | `match()` | (`cases`) => `Promise`&lt;`R`&gt; | Asynchronous `match`. Handlers are synchronous; resolves to `R`. | [packages/core/src/types.ts:308](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L308) |
229
+ | `orElse()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`T` \| `U`, `E2`&gt; | Asynchronous `orElse`. `f` may return a `Result` or an `AsyncResult`. | [packages/core/src/types.ts:294](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L294) |
230
+ | `recover()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`T` \| `U`, `never`&gt; | Asynchronous `recover`. `f` is synchronous; a throw becomes a `Defect`. | [packages/core/src/types.ts:296](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L296) |
231
+ | `recoverDefect()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`T` \| `U`, `E` \| `E2`&gt; | Asynchronous `recoverDefect`. `f` may return a `Result` or an `AsyncResult`. | [packages/core/src/types.ts:301](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L301) |
232
+ | `tap()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`T`, `E`&gt; | Asynchronous `tap`. `f` is synchronous; a throw becomes a `Defect`. | [packages/core/src/types.ts:287](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L287) |
233
+ | `tapDefect()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`T`, `E`&gt; | Asynchronous `tapDefect`. | [packages/core/src/types.ts:305](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L305) |
234
+ | `tapErr()` | (`f`) => [`AsyncResult`](#asyncresult)&lt;`T`, `E`&gt; | Asynchronous `tapErr`. `f` is synchronous; a throw becomes a `Defect`. | [packages/core/src/types.ts:298](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L298) |
235
+ | `unwrap()` | () => `Promise`&lt;`T`&gt; | Asynchronous `unwrap`. The returned promise rejects on `Err`/`Defect`. | [packages/core/src/types.ts:314](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L314) |
236
+ | `unwrapErr()` | () => `Promise`&lt;`E`&gt; | Asynchronous `unwrapErr`. | [packages/core/src/types.ts:316](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L316) |
237
+ | `unwrapOr()` | (`fallback`) => `Promise`&lt;`T`&gt; | Asynchronous `unwrapOr`. | [packages/core/src/types.ts:318](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L318) |
238
+ | `unwrapOrElse()` | (`f`) => `Promise`&lt;`T`&gt; | Asynchronous `unwrapOrElse`. | [packages/core/src/types.ts:320](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L320) |
203
239
 
204
240
  #### Type Parameters
205
241
 
@@ -228,7 +264,7 @@ To pattern-match an `AsyncResult`, `await` it first: `match(await ar)`.
228
264
  type Awaitable<T> = object;
229
265
  ```
230
266
 
231
- Defined in: [packages/core/src/types.ts:256](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L256)
267
+ Defined in: [packages/core/src/types.ts:256](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L256)
232
268
 
233
269
  A success-only thenable: awaitable, but deliberately **not** a full
234
270
  `PromiseLike`.
@@ -255,7 +291,7 @@ being treated as a raw promise (e.g. dropped into `Promise.all`).
255
291
  then<R>(onfulfilled?): PromiseLike<R>;
256
292
  ```
257
293
 
258
- Defined in: [packages/core/src/types.ts:257](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L257)
294
+ Defined in: [packages/core/src/types.ts:257](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L257)
259
295
 
260
296
  ###### Type Parameters
261
297
 
@@ -281,7 +317,7 @@ Defined in: [packages/core/src/types.ts:257](https://github.com/btravstack/unthr
281
317
  type Defect = object;
282
318
  ```
283
319
 
284
- Defined in: [packages/core/src/defect.ts:15](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/defect.ts#L15)
320
+ Defined in: [packages/core/src/defect.ts:15](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/defect.ts#L15)
285
321
 
286
322
  The marker a `qualify` function returns to triage a cause as **unexpected**.
287
323
 
@@ -297,8 +333,8 @@ runtime state of a `Result`.
297
333
 
298
334
  | Property | Modifier | Type | Defined in |
299
335
  | ------ | ------ | ------ | ------ |
300
- | <a id="defect-1"></a> `[DEFECT]` | `readonly` | `true` | [packages/core/src/defect.ts:16](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/defect.ts#L16) |
301
- | <a id="cause-1"></a> `cause` | `readonly` | `unknown` | [packages/core/src/defect.ts:17](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/defect.ts#L17) |
336
+ | <a id="defect-1"></a> `[DEFECT]` | `readonly` | `true` | [packages/core/src/defect.ts:16](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/defect.ts#L16) |
337
+ | <a id="cause-1"></a> `cause` | `readonly` | `unknown` | [packages/core/src/defect.ts:17](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/defect.ts#L17) |
302
338
 
303
339
  ***
304
340
 
@@ -308,7 +344,7 @@ runtime state of a `Result`.
308
344
  type DefectView<T, E> = ResultMethods<T, E> & object;
309
345
  ```
310
346
 
311
- Defined in: [packages/core/src/types.ts:199](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L199)
347
+ Defined in: [packages/core/src/types.ts:199](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L199)
312
348
 
313
349
  The `Defect` variant of a [Result](#result): an unmodeled failure carrying a `cause`.
314
350
 
@@ -316,8 +352,8 @@ The `Defect` variant of a [Result](#result): an unmodeled failure carrying a `ca
316
352
 
317
353
  | Name | Type | Defined in |
318
354
  | ------ | ------ | ------ |
319
- | `cause` | `unknown` | [packages/core/src/types.ts:201](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L201) |
320
- | `tag` | `"Defect"` | [packages/core/src/types.ts:200](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L200) |
355
+ | `cause` | `unknown` | [packages/core/src/types.ts:201](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L201) |
356
+ | `tag` | `"Defect"` | [packages/core/src/types.ts:200](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L200) |
321
357
 
322
358
  #### Type Parameters
323
359
 
@@ -334,7 +370,7 @@ The `Defect` variant of a [Result](#result): an unmodeled failure carrying a `ca
334
370
  type ErrOf<R> = R extends object ? E : never;
335
371
  ```
336
372
 
337
- Defined in: [packages/core/src/types.ts:338](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L338)
373
+ Defined in: [packages/core/src/types.ts:338](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L338)
338
374
 
339
375
  Extract the error type `E` from a `Result`.
340
376
 
@@ -352,7 +388,7 @@ Extract the error type `E` from a `Result`.
352
388
  type ErrView<E, T> = ResultMethods<T, E> & object;
353
389
  ```
354
390
 
355
- Defined in: [packages/core/src/types.ts:194](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L194)
391
+ Defined in: [packages/core/src/types.ts:194](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L194)
356
392
 
357
393
  The `Err` variant of a [Result](#result): a modeled failure carrying an `error`.
358
394
 
@@ -360,8 +396,8 @@ The `Err` variant of a [Result](#result): a modeled failure carrying an `error`.
360
396
 
361
397
  | Name | Type | Defined in |
362
398
  | ------ | ------ | ------ |
363
- | `error` | `E` | [packages/core/src/types.ts:196](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L196) |
364
- | `tag` | `"Err"` | [packages/core/src/types.ts:195](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L195) |
399
+ | `error` | `E` | [packages/core/src/types.ts:196](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L196) |
400
+ | `tag` | `"Err"` | [packages/core/src/types.ts:195](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L195) |
365
401
 
366
402
  #### Type Parameters
367
403
 
@@ -378,7 +414,7 @@ The `Err` variant of a [Result](#result): a modeled failure carrying an `error`.
378
414
  type OkOf<R> = R extends object ? T : never;
379
415
  ```
380
416
 
381
- Defined in: [packages/core/src/types.ts:332](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L332)
417
+ Defined in: [packages/core/src/types.ts:332](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L332)
382
418
 
383
419
  Extract the success type `T` from a `Result`.
384
420
 
@@ -396,7 +432,7 @@ Extract the success type `T` from a `Result`.
396
432
  type OkView<T, E> = ResultMethods<T, E> & object;
397
433
  ```
398
434
 
399
- Defined in: [packages/core/src/types.ts:189](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L189)
435
+ Defined in: [packages/core/src/types.ts:189](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L189)
400
436
 
401
437
  The `Ok` variant of a [Result](#result): a success carrying a `value`.
402
438
 
@@ -404,8 +440,8 @@ The `Ok` variant of a [Result](#result): a success carrying a `value`.
404
440
 
405
441
  | Name | Type | Defined in |
406
442
  | ------ | ------ | ------ |
407
- | `tag` | `"Ok"` | [packages/core/src/types.ts:190](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L190) |
408
- | `value` | `T` | [packages/core/src/types.ts:191](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/types.ts#L191) |
443
+ | `tag` | `"Ok"` | [packages/core/src/types.ts:190](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L190) |
444
+ | `value` | `T` | [packages/core/src/types.ts:191](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/types.ts#L191) |
409
445
 
410
446
  #### Type Parameters
411
447
 
@@ -422,13 +458,14 @@ The `Ok` variant of a [Result](#result): a success carrying a `value`.
422
458
  type Result<T, E> = ResultType<T, E>;
423
459
  ```
424
460
 
425
- Defined in: [packages/core/src/facade.ts:31](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/facade.ts#L31)
461
+ Defined in: [packages/core/src/facade.ts:39](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/facade.ts#L39)
426
462
 
427
463
  Companion object grouping the standalone entry points under a single,
428
464
  discoverable namespace: [Result.ok](#property-ok), [Result.err](#property-err),
429
465
  [Result.defect](#property-defect), [Result.fromNullable](#property-fromnullable), [Result.fromThrowable](#property-fromthrowable),
430
466
  [Result.fromPromise](#property-frompromise), [Result.fromSafePromise](#property-fromsafepromise), [Result.all](#property-all),
431
- [Result.isOk](#property-isok), [Result.isErr](#property-iserr), [Result.isDefect](#property-isdefect).
467
+ [Result.allAsync](#property-allasync), [Result.isOk](#property-isok), [Result.isErr](#property-iserr),
468
+ [Result.isDefect](#property-isdefect).
432
469
 
433
470
  #### Type Parameters
434
471
 
@@ -459,7 +496,7 @@ Result.ok(1).flatMap((n) => Result.ok(n + 1)).unwrap(); // 2
459
496
  type TaggedErrorConstructor<Tag> = <A>(args) => TaggedErrorInstance<Tag, A>;
460
497
  ```
461
498
 
462
- Defined in: [packages/core/src/tagged.ts:28](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/tagged.ts#L28)
499
+ Defined in: [packages/core/src/tagged.ts:28](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/tagged.ts#L28)
463
500
 
464
501
  The class constructor returned by [TaggedError](#taggederror). Generic in its payload:
465
502
  apply it with an instantiation expression at the `extends` site.
@@ -493,7 +530,7 @@ When the payload is empty, the constructor takes **no** arguments (the
493
530
  type TaggedErrorInstance<Tag, A> = Error & Readonly<A> & object;
494
531
  ```
495
532
 
496
- Defined in: [packages/core/src/tagged.ts:15](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/tagged.ts#L15)
533
+ Defined in: [packages/core/src/tagged.ts:15](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/tagged.ts#L15)
497
534
 
498
535
  The instance shape produced by a [TaggedError](#taggederror) class: an `Error` plus a
499
536
  `_tag` discriminant and the (readonly) payload fields.
@@ -502,7 +539,7 @@ The instance shape produced by a [TaggedError](#taggederror) class: an `Error` p
502
539
 
503
540
  | Name | Type | Defined in |
504
541
  | ------ | ------ | ------ |
505
- | `_tag` | `Tag` | [packages/core/src/tagged.ts:16](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/tagged.ts#L16) |
542
+ | `_tag` | `Tag` | [packages/core/src/tagged.ts:16](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/tagged.ts#L16) |
506
543
 
507
544
  #### Type Parameters
508
545
 
@@ -519,7 +556,7 @@ The instance shape produced by a [TaggedError](#taggederror) class: an `Error` p
519
556
  type TagHandlers<T, E, R> = object & { [K in E["_tag"]]: (error: Extract<E, { _tag: K }>) => R };
520
557
  ```
521
558
 
522
- Defined in: [packages/core/src/tagged.ts:81](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/tagged.ts#L81)
559
+ Defined in: [packages/core/src/tagged.ts:103](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/tagged.ts#L103)
523
560
 
524
561
  The handler object [matchTags](#matchtags) requires: a branch per error tag, plus
525
562
  `Ok` and `Defect`. Miss a tag and it will not compile — the exhaustiveness is
@@ -529,8 +566,8 @@ enforced by the type, with no `.exhaustive()` to forget.
529
566
 
530
567
  | Name | Type | Defined in |
531
568
  | ------ | ------ | ------ |
532
- | `Defect()` | (`cause`) => `R` | [packages/core/src/tagged.ts:83](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/tagged.ts#L83) |
533
- | `Ok()` | (`value`) => `R` | [packages/core/src/tagged.ts:82](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/tagged.ts#L82) |
569
+ | `Defect()` | (`cause`) => `R` | [packages/core/src/tagged.ts:105](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/tagged.ts#L105) |
570
+ | `Ok()` | (`value`) => `R` | [packages/core/src/tagged.ts:104](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/tagged.ts#L104) |
534
571
 
535
572
  #### Type Parameters
536
573
 
@@ -548,29 +585,31 @@ enforced by the type, with no `.exhaustive()` to forget.
548
585
  const Result: object;
549
586
  ```
550
587
 
551
- Defined in: [packages/core/src/facade.ts:31](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/facade.ts#L31)
588
+ Defined in: [packages/core/src/facade.ts:39](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/facade.ts#L39)
552
589
 
553
590
  Companion object grouping the standalone entry points under a single,
554
591
  discoverable namespace: [Result.ok](#property-ok), [Result.err](#property-err),
555
592
  [Result.defect](#property-defect), [Result.fromNullable](#property-fromnullable), [Result.fromThrowable](#property-fromthrowable),
556
593
  [Result.fromPromise](#property-frompromise), [Result.fromSafePromise](#property-fromsafepromise), [Result.all](#property-all),
557
- [Result.isOk](#property-isok), [Result.isErr](#property-iserr), [Result.isDefect](#property-isdefect).
594
+ [Result.allAsync](#property-allasync), [Result.isOk](#property-isok), [Result.isErr](#property-iserr),
595
+ [Result.isDefect](#property-isdefect).
558
596
 
559
597
  #### Type Declaration
560
598
 
561
599
  | Name | Type | Defined in |
562
600
  | ------ | ------ | ------ |
563
- | <a id="property-all"></a> `all()` | &lt;`Rs`&gt;(`results`) => `Result`&lt;\{ \[K in string \| number \| symbol\]: OkOf\<Rs\[K\]\> \}, [`ErrOf`](#errof)&lt;`Rs`\[`number`\]&gt;&gt; | [packages/core/src/facade.ts:39](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/facade.ts#L39) |
564
- | <a id="property-defect"></a> `defect()` | (`cause`) => [`Defect`](#defect) | [packages/core/src/facade.ts:34](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/facade.ts#L34) |
565
- | <a id="property-err"></a> `err()` | &lt;`E`&gt;(`error`) => `Result`&lt;`never`, `E`&gt; | [packages/core/src/facade.ts:33](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/facade.ts#L33) |
566
- | <a id="property-fromnullable"></a> `fromNullable()` | &lt;`T`, `E`&gt;(`value`, `onAbsent`) => `Result`&lt;`NonNullable`&lt;`T`&gt;, `E`&gt; | [packages/core/src/facade.ts:35](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/facade.ts#L35) |
567
- | <a id="property-frompromise"></a> `fromPromise()` | &lt;`T`, `E`&gt;(`promise`, `qualify`) => [`AsyncResult`](#asyncresult)&lt;`T`, `E`&gt; | [packages/core/src/facade.ts:37](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/facade.ts#L37) |
568
- | <a id="property-fromsafepromise"></a> `fromSafePromise()` | &lt;`T`&gt;(`promise`) => [`AsyncResult`](#asyncresult)&lt;`T`, `never`&gt; | [packages/core/src/facade.ts:38](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/facade.ts#L38) |
569
- | <a id="property-fromthrowable"></a> `fromThrowable()` | &lt;`A`, `T`, `E`&gt;(`fn`, `qualify`) => (...`args`) => `Result`&lt;`T`, `E`&gt; | [packages/core/src/facade.ts:36](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/facade.ts#L36) |
570
- | <a id="property-isdefect"></a> `isDefect()` | &lt;`T`, `E`&gt;(`r`) => `r is DefectView<T, E>` | [packages/core/src/facade.ts:42](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/facade.ts#L42) |
571
- | <a id="property-iserr"></a> `isErr()` | &lt;`T`, `E`&gt;(`r`) => `r is ErrView<E, T>` | [packages/core/src/facade.ts:41](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/facade.ts#L41) |
572
- | <a id="property-isok"></a> `isOk()` | &lt;`T`, `E`&gt;(`r`) => `r is OkView<T, E>` | [packages/core/src/facade.ts:40](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/facade.ts#L40) |
573
- | <a id="property-ok"></a> `ok()` | &lt;`T`&gt;(`value`) => `Result`&lt;`T`, `never`&gt; | [packages/core/src/facade.ts:32](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/facade.ts#L32) |
601
+ | <a id="property-all"></a> `all()` | &lt;`Rs`&gt;(`results`) => `Result`&lt;`AllOk`&lt;`Rs`, \{ \[K in string \| number \| symbol\]: OkOf\<Rs\[K\]\> \}&gt;, [`ErrOf`](#errof)&lt;`Rs`\[`number`\]&gt;&gt; | [packages/core/src/facade.ts:47](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/facade.ts#L47) |
602
+ | <a id="property-allasync"></a> `allAsync()` | &lt;`Rs`&gt;(`results`) => [`AsyncResult`](#asyncresult)&lt;`AllOk`&lt;`Rs`, \{ \[K in string \| number \| symbol\]: AsyncOkOf\<Rs\[K\]\> \}&gt;, [`AsyncErrOf`](#asyncerrof)&lt;`Rs`\[`number`\]&gt;&gt; | [packages/core/src/facade.ts:48](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/facade.ts#L48) |
603
+ | <a id="property-defect"></a> `defect()` | (`cause`) => [`Defect`](#defect) | [packages/core/src/facade.ts:42](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/facade.ts#L42) |
604
+ | <a id="property-err"></a> `err()` | &lt;`E`&gt;(`error`) => `Result`&lt;`never`, `E`&gt; | [packages/core/src/facade.ts:41](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/facade.ts#L41) |
605
+ | <a id="property-fromnullable"></a> `fromNullable()` | &lt;`T`, `E`&gt;(`value`, `onAbsent`) => `Result`&lt;`NonNullable`&lt;`T`&gt;, `E`&gt; | [packages/core/src/facade.ts:43](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/facade.ts#L43) |
606
+ | <a id="property-frompromise"></a> `fromPromise()` | &lt;`T`, `R`&gt;(`promise`, `qualify`) => [`AsyncResult`](#asyncresult)&lt;`T`, `Exclude`&lt;`R`, [`Defect`](#defect)&gt;&gt; | [packages/core/src/facade.ts:45](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/facade.ts#L45) |
607
+ | <a id="property-fromsafepromise"></a> `fromSafePromise()` | &lt;`T`&gt;(`promise`) => [`AsyncResult`](#asyncresult)&lt;`T`, `never`&gt; | [packages/core/src/facade.ts:46](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/facade.ts#L46) |
608
+ | <a id="property-fromthrowable"></a> `fromThrowable()` | &lt;`A`, `T`, `R`&gt;(`fn`, `qualify`) => (...`args`) => `Result`&lt;`T`, `Exclude`&lt;`R`, [`Defect`](#defect)&gt;&gt; | [packages/core/src/facade.ts:44](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/facade.ts#L44) |
609
+ | <a id="property-isdefect"></a> `isDefect()` | &lt;`T`, `E`&gt;(`r`) => `r is DefectView<T, E>` | [packages/core/src/facade.ts:51](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/facade.ts#L51) |
610
+ | <a id="property-iserr"></a> `isErr()` | &lt;`T`, `E`&gt;(`r`) => `r is ErrView<E, T>` | [packages/core/src/facade.ts:50](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/facade.ts#L50) |
611
+ | <a id="property-isok"></a> `isOk()` | &lt;`T`, `E`&gt;(`r`) => `r is OkView<T, E>` | [packages/core/src/facade.ts:49](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/facade.ts#L49) |
612
+ | <a id="property-ok"></a> `ok()` | &lt;`T`&gt;(`value`) => `Result`&lt;`T`, `never`&gt; | [packages/core/src/facade.ts:40](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/facade.ts#L40) |
574
613
 
575
614
  #### Remarks
576
615
 
@@ -591,19 +630,18 @@ Result.ok(1).flatMap((n) => Result.ok(n + 1)).unwrap(); // 2
591
630
  ### all()
592
631
 
593
632
  ```ts
594
- function all<Rs>(results): Result<{ [K in string | number | symbol]: OkOf<Rs[K]> }, ErrOf<Rs[number]>>;
633
+ function all<Rs>(results): Result<AllOk<Rs, { [K in string | number | symbol]: OkOf<Rs[K]> }>, ErrOf<Rs[number]>>;
595
634
  ```
596
635
 
597
- Defined in: [packages/core/src/interop.ts:162](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/interop.ts#L162)
636
+ Defined in: [packages/core/src/interop.ts:202](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/interop.ts#L202)
598
637
 
599
- Collect a tuple of [Result](#result)s into a single `Result` of the tuple of
600
- success values.
638
+ Collect [Result](#result)s into a single `Result` of all their success values.
601
639
 
602
640
  #### Type Parameters
603
641
 
604
642
  | Type Parameter | Description |
605
643
  | ------ | ------ |
606
- | `Rs` *extends* readonly `Result`&lt;`unknown`, `unknown`&gt;[] | the tuple of input `Result` types. |
644
+ | `Rs` *extends* readonly `Result`&lt;`unknown`, `unknown`&gt;[] | the tuple/array of input `Result` types. |
607
645
 
608
646
  #### Parameters
609
647
 
@@ -613,20 +651,67 @@ success values.
613
651
 
614
652
  #### Returns
615
653
 
616
- `Result`&lt;\{ \[K in string \| number \| symbol\]: OkOf\<Rs\[K\]\> \}, [`ErrOf`](#errof)&lt;`Rs`\[`number`\]&gt;&gt;
654
+ `Result`&lt;`AllOk`&lt;`Rs`, \{ \[K in string \| number \| symbol\]: OkOf\<Rs\[K\]\> \}&gt;, [`ErrOf`](#errof)&lt;`Rs`\[`number`\]&gt;&gt;
617
655
 
618
656
  #### Remarks
619
657
 
620
658
  Short-circuits on the **first** `Err` (later entries are not inspected for
621
659
  their error); any `Defect` present **dominates**, winning even over an earlier
622
- `Err`. Positional types are preserved, so `all([ok(1), ok("a")])` is
623
- `Result<[number, string], …>`.
660
+ `Err`. A **fixed tuple** keeps its positional types — `all([ok(1), ok("a")])`
661
+ is `Result<[number, string], …>` — while a **dynamic array** `Result<T, E>[]`
662
+ collapses to `Result<T[], E>` with no cast.
624
663
 
625
664
  #### Example
626
665
 
627
666
  ```ts
628
667
  import { all, ok } from "unthrown";
629
- all([ok(1), ok("a"), ok(true)]).unwrap(); // [1, "a", true]
668
+ all([ok(1), ok("a"), ok(true)]).unwrap(); // [1, "a", true] (typed [number, string, boolean])
669
+ all([ok(1), ok(2)] as Result<number, never>[]).unwrap(); // number[]
670
+ ```
671
+
672
+ ***
673
+
674
+ ### allAsync()
675
+
676
+ ```ts
677
+ function allAsync<Rs>(results): AsyncResult<AllOk<Rs, { [K in string | number | symbol]: AsyncOkOf<Rs[K]> }>, AsyncErrOf<Rs[number]>>;
678
+ ```
679
+
680
+ Defined in: [packages/core/src/interop.ts:242](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/interop.ts#L242)
681
+
682
+ The asynchronous counterpart of [all](#all): combine [AsyncResult](#asyncresult)s into
683
+ one `AsyncResult` of all their success values.
684
+
685
+ #### Type Parameters
686
+
687
+ | Type Parameter | Description |
688
+ | ------ | ------ |
689
+ | `Rs` *extends* readonly [`AsyncResult`](#asyncresult)&lt;`unknown`, `unknown`&gt;[] | the tuple/array of input `AsyncResult` types. |
690
+
691
+ #### Parameters
692
+
693
+ | Parameter | Type | Description |
694
+ | ------ | ------ | ------ |
695
+ | `results` | readonly \[`Rs`\] | the async results to combine. |
696
+
697
+ #### Returns
698
+
699
+ [`AsyncResult`](#asyncresult)&lt;`AllOk`&lt;`Rs`, \{ \[K in string \| number \| symbol\]: AsyncOkOf\<Rs\[K\]\> \}&gt;, [`AsyncErrOf`](#asyncerrof)&lt;`Rs`\[`number`\]&gt;&gt;
700
+
701
+ #### Remarks
702
+
703
+ The inputs are resolved **concurrently** (their order is preserved); the
704
+ resolved `Result`s are then folded with the same rules as [all](#all) —
705
+ first `Err` short-circuits, any `Defect` dominates. As ever, the returned
706
+ `AsyncResult`'s internal promise never rejects. A **fixed tuple** keeps its
707
+ positional types; a **dynamic array** `AsyncResult<T, E>[]` collapses to
708
+ `AsyncResult<T[], E>`.
709
+
710
+ #### Example
711
+
712
+ ```ts
713
+ import { allAsync, fromSafePromise } from "unthrown";
714
+ const both = await allAsync([fromSafePromise(a()), fromSafePromise(b())]);
630
715
  ```
631
716
 
632
717
  ***
@@ -637,7 +722,7 @@ all([ok(1), ok("a"), ok(true)]).unwrap(); // [1, "a", true]
637
722
  function defect(cause): Defect;
638
723
  ```
639
724
 
640
- Defined in: [packages/core/src/defect.ts:36](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/defect.ts#L36)
725
+ Defined in: [packages/core/src/defect.ts:36](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/defect.ts#L36)
641
726
 
642
727
  Wrap a cause as a [Defect](#defect) — the value you return from a `qualify`
643
728
  function when a failure is **not** a modeled domain error.
@@ -672,7 +757,7 @@ const user = fromPromise(fetchUser(id), (cause) =>
672
757
  function err<E>(error): Result<never, E>;
673
758
  ```
674
759
 
675
- Defined in: [packages/core/src/constructors.ts:34](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/constructors.ts#L34)
760
+ Defined in: [packages/core/src/constructors.ts:34](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/constructors.ts#L34)
676
761
 
677
762
  Construct a failed [Result](#result) carrying a **modeled** error.
678
763
 
@@ -707,7 +792,7 @@ err("not_found").unwrapErr(); // "not_found"
707
792
  function fromNullable<T, E>(value, onAbsent): Result<NonNullable<T>, E>;
708
793
  ```
709
794
 
710
- Defined in: [packages/core/src/interop.ts:29](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/interop.ts#L29)
795
+ Defined in: [packages/core/src/interop.ts:29](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/interop.ts#L29)
711
796
 
712
797
  Bridge a nullable value into a [Result](#result): absence becomes a **modeled**
713
798
  `Err`. The sanctioned alternative to an `Option` type.
@@ -747,10 +832,10 @@ fromNullable(map.get(key), () => "missing").unwrap();
747
832
  ### fromPromise()
748
833
 
749
834
  ```ts
750
- function fromPromise<T, E>(promise, qualify): AsyncResult<T, E>;
835
+ function fromPromise<T, R>(promise, qualify): AsyncResult<T, Exclude<R, Defect>>;
751
836
  ```
752
837
 
753
- Defined in: [packages/core/src/interop.ts:95](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/interop.ts#L95)
838
+ Defined in: [packages/core/src/interop.ts:110](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/interop.ts#L110)
754
839
 
755
840
  Wrap a `Promise` (or a thunk producing one) as an [AsyncResult](#asyncresult), forcing
756
841
  every rejection to be triaged.
@@ -760,18 +845,18 @@ every rejection to be triaged.
760
845
  | Type Parameter | Description |
761
846
  | ------ | ------ |
762
847
  | `T` | the resolved value type. |
763
- | `E` | the modeled error type. |
848
+ | `R` | `qualify`'s return type; the modeled error `E` is `Exclude<R, Defect>` (its `Defect` arm, if any, is subtracted). |
764
849
 
765
850
  #### Parameters
766
851
 
767
852
  | Parameter | Type | Description |
768
853
  | ------ | ------ | ------ |
769
854
  | `promise` | `Promise`&lt;`T`&gt; \| (() => `Promise`&lt;`T`&gt;) | the promise, or a thunk returning one. |
770
- | `qualify` | (`cause`) => [`Defect`](#defect) \| `E` | triages a rejection cause into `E` or a `Defect`. |
855
+ | `qualify` | (`cause`) => `R` | triages a rejection cause into `E` or a `Defect`. |
771
856
 
772
857
  #### Returns
773
858
 
774
- [`AsyncResult`](#asyncresult)&lt;`T`, `E`&gt;
859
+ [`AsyncResult`](#asyncresult)&lt;`T`, `Exclude`&lt;`R`, [`Defect`](#defect)&gt;&gt;
775
860
 
776
861
  #### Remarks
777
862
 
@@ -780,6 +865,11 @@ every rejection to be triaged.
780
865
  `await`-ing it always yields a `Result`. A throw inside `qualify` is itself a
781
866
  `Defect`.
782
867
 
868
+ The modeled error type is `Exclude<R, Defect>` — the `Defect` arm of
869
+ `qualify`'s return is **subtracted** from `E`, never inferred into it. So a
870
+ `qualify` that returns *only* `defect(cause)` yields `E = never`; when every
871
+ rejection is a defect, prefer [fromSafePromise](#fromsafepromise).
872
+
783
873
  #### Example
784
874
 
785
875
  ```ts
@@ -797,7 +887,7 @@ const user = await fromPromise(fetchUser(id), (cause) =>
797
887
  function fromSafePromise<T>(promise): AsyncResult<T, never>;
798
888
  ```
799
889
 
800
- Defined in: [packages/core/src/interop.ts:119](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/interop.ts#L119)
890
+ Defined in: [packages/core/src/interop.ts:136](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/interop.ts#L136)
801
891
 
802
892
  Wrap a `Promise` asserted **not** to fail in any modeled way: any rejection
803
893
  becomes a `Defect`.
@@ -829,10 +919,10 @@ triage. (`await`-ing still yields a `Result`; it never throws.)
829
919
  ### fromThrowable()
830
920
 
831
921
  ```ts
832
- function fromThrowable<A, T, E>(fn, qualify): (...args) => Result<T, E>;
922
+ function fromThrowable<A, T, R>(fn, qualify): (...args) => Result<T, Exclude<R, Defect>>;
833
923
  ```
834
924
 
835
- Defined in: [packages/core/src/interop.ts:59](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/interop.ts#L59)
925
+ Defined in: [packages/core/src/interop.ts:66](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/interop.ts#L66)
836
926
 
837
927
  Wrap a throwing synchronous function so it returns a [Result](#result) instead of
838
928
  throwing.
@@ -843,20 +933,20 @@ throwing.
843
933
  | ------ | ------ |
844
934
  | `A` *extends* `unknown`[] | the wrapped function's argument tuple. |
845
935
  | `T` | the wrapped function's return type. |
846
- | `E` | the modeled error type. |
936
+ | `R` | `qualify`'s return type; the modeled error `E` is `Exclude<R, Defect>` (its `Defect` arm, if any, is subtracted). |
847
937
 
848
938
  #### Parameters
849
939
 
850
940
  | Parameter | Type | Description |
851
941
  | ------ | ------ | ------ |
852
942
  | `fn` | (...`args`) => `T` | the throwing function to wrap. |
853
- | `qualify` | (`cause`) => [`Defect`](#defect) \| `E` | triages a thrown cause into `E` or a `Defect`. |
943
+ | `qualify` | (`cause`) => `R` | triages a thrown cause into `E` or a `Defect`. |
854
944
 
855
945
  #### Returns
856
946
 
857
947
  a function with the same arguments returning `Result<T, E>`.
858
948
 
859
- (...`args`) => `Result`&lt;`T`, `E`&gt;
949
+ (...`args`) => `Result`&lt;`T`, `Exclude`&lt;`R`, [`Defect`](#defect)&gt;&gt;
860
950
 
861
951
  #### Remarks
862
952
 
@@ -864,6 +954,12 @@ a function with the same arguments returning `Result<T, E>`.
864
954
  [Defect](#defect) (via [defect](#defect-2)) — there is no path that leaves `unknown`
865
955
  in `E`. A throw inside `qualify` itself is treated as a `Defect`.
866
956
 
957
+ The modeled error type is `Exclude<R, Defect>` — the `Defect` arm of
958
+ `qualify`'s return is **subtracted** from `E`, never inferred into it. So a
959
+ `qualify` that returns *only* `defect(cause)` yields `E = never` (a defect is
960
+ out-of-band and must not pollute the error channel); reach for
961
+ [fromSafePromise](#fromsafepromise) when every failure is a defect.
962
+
867
963
  #### Example
868
964
 
869
965
  ```ts
@@ -880,7 +976,7 @@ parse("{}").unwrap();
880
976
  function isDefect<T, E>(r): r is DefectView<T, E>;
881
977
  ```
882
978
 
883
- Defined in: [packages/core/src/constructors.ts:66](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/constructors.ts#L66)
979
+ Defined in: [packages/core/src/constructors.ts:66](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/constructors.ts#L66)
884
980
 
885
981
  Type guard: narrow a [Result](#result) to its `Defect` variant, exposing `.cause`.
886
982
 
@@ -911,7 +1007,7 @@ Type guard: narrow a [Result](#result) to its `Defect` variant, exposing `.cause
911
1007
  function isErr<T, E>(r): r is ErrView<E, T>;
912
1008
  ```
913
1009
 
914
- Defined in: [packages/core/src/constructors.ts:58](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/constructors.ts#L58)
1010
+ Defined in: [packages/core/src/constructors.ts:58](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/constructors.ts#L58)
915
1011
 
916
1012
  Type guard: narrow a [Result](#result) to its `Err` variant, exposing `.error`.
917
1013
 
@@ -942,7 +1038,7 @@ Type guard: narrow a [Result](#result) to its `Err` variant, exposing `.error`.
942
1038
  function isOk<T, E>(r): r is OkView<T, E>;
943
1039
  ```
944
1040
 
945
- Defined in: [packages/core/src/constructors.ts:50](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/constructors.ts#L50)
1041
+ Defined in: [packages/core/src/constructors.ts:50](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/constructors.ts#L50)
946
1042
 
947
1043
  Type guard: narrow a [Result](#result) to its `Ok` variant, exposing `.value`.
948
1044
 
@@ -983,7 +1079,7 @@ if (isOk(r)) r.value; // number, narrowed
983
1079
  function matchTags<T, E, R>(result, handlers): R;
984
1080
  ```
985
1081
 
986
- Defined in: [packages/core/src/tagged.ts:116](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/tagged.ts#L116)
1082
+ Defined in: [packages/core/src/tagged.ts:138](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/tagged.ts#L138)
987
1083
 
988
1084
  Exhaustively fold a [Result](#result) (or [AsyncResult](#asyncresult)) whose error type is
989
1085
  a tagged union, dispatching each error to the handler matching its `_tag`.
@@ -1035,7 +1131,7 @@ matchTags(r, {
1035
1131
  function matchTags<T, E, R>(result, handlers): Promise<R>;
1036
1132
  ```
1037
1133
 
1038
- Defined in: [packages/core/src/tagged.ts:120](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/tagged.ts#L120)
1134
+ Defined in: [packages/core/src/tagged.ts:142](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/tagged.ts#L142)
1039
1135
 
1040
1136
  Exhaustively fold a [Result](#result) (or [AsyncResult](#asyncresult)) whose error type is
1041
1137
  a tagged union, dispatching each error to the handler matching its `_tag`.
@@ -1089,7 +1185,7 @@ matchTags(r, {
1089
1185
  function ok<T>(value): Result<T, never>;
1090
1186
  ```
1091
1187
 
1092
- Defined in: [packages/core/src/constructors.ts:18](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/constructors.ts#L18)
1188
+ Defined in: [packages/core/src/constructors.ts:18](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/constructors.ts#L18)
1093
1189
 
1094
1190
  Construct a successful [Result](#result).
1095
1191
 
@@ -1121,10 +1217,10 @@ ok(42).unwrap(); // 42
1121
1217
  ### TaggedError()
1122
1218
 
1123
1219
  ```ts
1124
- function TaggedError<Tag>(tag): TaggedErrorConstructor<Tag>;
1220
+ function TaggedError<Tag>(tag, options?): TaggedErrorConstructor<Tag>;
1125
1221
  ```
1126
1222
 
1127
- Defined in: [packages/core/src/tagged.ts:54](https://github.com/btravstack/unthrown/blob/4553631adb8280ef7c869dfae5bdb13be762095c/packages/core/src/tagged.ts#L54)
1223
+ Defined in: [packages/core/src/tagged.ts:72](https://github.com/btravstack/unthrown/blob/400cfa972078ebe2522248d056e2f198b8101e81/packages/core/src/tagged.ts#L72)
1128
1224
 
1129
1225
  Build a base class for a tagged error — a class extending `Error` with a
1130
1226
  `_tag` string discriminant, in the style of Effect's `Data.TaggedError`.
@@ -1139,7 +1235,9 @@ Build a base class for a tagged error — a class extending `Error` with a
1139
1235
 
1140
1236
  | Parameter | Type | Description |
1141
1237
  | ------ | ------ | ------ |
1142
- | `tag` | `Tag` | the discriminant value, also used as the error `name`. |
1238
+ | `tag` | `Tag` | the discriminant value; also the default error `name`. |
1239
+ | `options?` | \{ `name?`: `string`; \} | optional overrides. `options.name` sets `Error.name` independently of `tag` (defaults to `tag`). |
1240
+ | `options.name?` | `string` | - |
1143
1241
 
1144
1242
  #### Returns
1145
1243
 
@@ -1152,6 +1250,22 @@ an instantiation expression; omit it for a payload-less error. A `message`
1152
1250
  field in the payload is forwarded to `Error`. The `_tag` always reflects
1153
1251
  `tag` and cannot be overridden by the payload.
1154
1252
 
1253
+ `_tag` is the discriminant used by [matchTags](#matchtags); `Error.name` is the
1254
+ human-facing label in stack traces and logs. By default they coincide, but
1255
+ they can be **decoupled** with `options.name` — so a tag can be namespaced for
1256
+ collision-safety (`"@my-lib/RetryableError"`) without that slash-prefixed
1257
+ string leaking into `Error.name`:
1258
+
1259
+ ```ts
1260
+ class RetryableError extends TaggedError("@my-lib/RetryableError", {
1261
+ name: "RetryableError",
1262
+ })<{ message: string }> {}
1263
+
1264
+ const e = new RetryableError({ message: "boom" });
1265
+ e._tag; // "@my-lib/RetryableError" — namespaced discriminant
1266
+ e.name; // "RetryableError" — clean display name
1267
+ ```
1268
+
1155
1269
  #### Example
1156
1270
 
1157
1271
  ```ts