Methods
(async) capture(promise) → {AsyncResult.<T, E>}
Capture the results of a promise as a AsyncResult.
Parameters:
Name | Type | Description |
---|---|---|
promise |
Promise.<T> | The promise to wrap. |
Returns:
The promise value or error as an AsyncResult.
- Type
- AsyncResult.<T, E>
captureFn(fn, …args) → {Result.<T, E>}
Capture the results of a function as a Result.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
fn |
function | The function to wrap. | |
args |
any |
<repeatable> |
Arguments to pass to the function. |
Returns:
The value or error as an Result.
- Type
- Result.<T, E>
err(error) → {Err.<T, E>}
Construct a new Err result value.
Parameters:
Name | Type | Description |
---|---|---|
error |
E | Err.<E, U> | A value or error result to use as the error. |
Returns:
An error result.
- Type
- Err.<T, E>
ok(value) → {Ok.<T, E>}
Construct a new Ok result value.
For void function results use: ok(undefined)
Parameters:
Name | Type | Description |
---|---|---|
value |
T | The value to use as the result. |
Returns:
An ok result.
- Type
- Ok.<T, E>