Static
errCreate an instance of Err
.
const anErr = Result.err('alas, failure');
Create an instance of Err
.
const anErr = Result.err('alas, failure');
The value to wrap in an Err
.
Static
okCreate an instance of Ok
.
Note that you may explicitly pass Unit
to the ok
constructor to create a Result<Unit, E>
. However, you may not call the
ok
constructor with null
or undefined
to get that result (the type
system won't allow you to construct it that way). Instead, for convenience,
you can simply call
, which will construct the
type correctly.Result.ok()
The value to wrap in an Ok
.
A
Result
represents success (Ok
) or failure (Err
).The behavior of this type is checked by TypeScript at compile time, and bears no runtime overhead other than the very small cost of the container object.