Skip to main content

tryToEither

Callable


  • Convert the Try to an Either, where Success is converted to Right, and Failure is converted to Left.

    Example

    tryToEither("foobar")
    // => {right: "foobar"}

    tryToEither(new Error("foobar"))
    // => {left: Error("foobar")}

    Type parameters

    • T: unknown

      The value type.

    Parameters

    • x: T

      The Try to transform.

    Returns Either<Failure, Success<T>>