tryFromEither
tryFromEither<
L
,R
>(x
):Try
<R
>
Convert the Either
to a Try
, where Right
is converted to Success
, and
Left
is converted to Failure
.
Example
tryFromEither({right: "foobar"})// => "foobar"
tryFromEither({left: new Error("foobar")})// => Error("foobar")
Type Parameters
• L
The Left
type.
• R extends unknown
The Right
type.
Parameters
x
Either
<L
, R
>
The Either
to transform.
Returns
Try
<R
>