Convert a Promise returning A
into a Promise returning a Result of either A
or the Error
type.
The new Promise always succeeds, reflecting an error condition in the Result
instead of the failure callback.
Turn a function that returns A
and potentially throws E
into a function that
catches E
if thrown and returns Result<A, E>
.
Beware that TypeScript's type inference isn't currently very good at
this, so you should explicitly provide the target function signature when
using this function, or you're likely to end up with a Result<unknown, unknown>
instead of the expected Result<A, E>
.
Static methods on the Result object.