CombinatorstryToEithertryToEither CallabletryToEither<T>(x: T): Either<Failure, Success<T>>Convert the Try to an Either, where Success is converted to Right, and Failure is converted to Left. ExampletryToEither("foobar")// => {right: "foobar"}tryToEither(new Error("foobar"))// => {left: Error("foobar")}Type parametersT: unknownThe value type.Parametersx: TThe Try to transform.Returns Either<Failure, Success<T>>
Convert the
Try
to anEither
, whereSuccess
is converted toRight
, andFailure
is converted toLeft
.Example