Interface Either<L, R>

Type Parameters

  • L

  • R

Hierarchy

  • Either

Methods

  • Returns the first Right between this and another Either or the Left in the argument if both this and the argument are Left

    Parameters

    Returns functional.Either<L, R>

  • Applies a Right function over a Right value. Returns Left if either this or the function are Left

    Type Parameters

    • L2

    • R2

    Parameters

    Returns functional.Either<L | L2, R2>

  • Given two functions, maps the value inside this using the first if this is Left or using the second one if this is Right. If both functions return the same type consider using Either#either instead

    Type Parameters

    • L2

    • R2

    Parameters

    • f: ((value) => L2)
        • (value): L2
        • Parameters

          • value: L

          Returns L2

    • g: ((value) => R2)
        • (value): R2
        • Parameters

          • value: R

          Returns R2

    Returns functional.Either<L2, R2>

  • Structural pattern matching for Either in the form of a function

    Type Parameters

    • T

    Parameters

    Returns T

  • The same as Either#chain but executes the transformation function only if the value is Left. Useful for recovering from errors

    Type Parameters

    • L2

    • R2

    Parameters

    Returns functional.Either<L2, R | R2>

  • Compares this to another Either, returns false if the constructors or the values inside are different, e.g. Right(5).equals(Left(5)) is false

    Parameters

    Returns boolean

  • Returns this if it's a Left, otherwise it returns the result of applying the function argument to this and wrapping it in a Right

    Type Parameters

    • R2

    Parameters

    Returns functional.Either<L, R2>

  • Extracts the value out of this

    Returns L | R

  • Type Parameters

    • L2

    • R2

    Parameters

    • f: ((value) => L2)
        • (value): L2
        • Parameters

          • value: L

          Returns L2

    • g: ((value) => R2)
        • (value): R2
        • Parameters

          • value: R

          Returns R2

    Returns functional.Either<L2, R2>

  • Parameters

    Returns boolean

  • Type Parameters

    • R2

    Parameters

    • f: ((value) => R2)
        • (value): R2
        • Parameters

          • value: R

          Returns R2

    Returns functional.Either<L, R2>

  • Type Parameters

    • T

    Parameters

    • reducer: ((accumulator, value) => T)
        • (accumulator, value): T
        • Parameters

          • accumulator: T
          • value: R

          Returns T

    • initialValue: T

    Returns T

  • Runs an effect if this is Left, returns this to make chaining other methods possible

    Parameters

    • effect: ((value) => any)
        • (value): any
        • Parameters

          • value: L

          Returns any

    Returns functional.Either<L, R>

  • Runs an effect if this is Right, returns this to make chaining other methods possible

    Parameters

    • effect: ((value) => any)
        • (value): any
        • Parameters

          • value: R

          Returns any

    Returns functional.Either<L, R>

  • Returns string

  • Returns true if this is Left, otherwise it returns false

    Returns this is functional.Either<L, never>

  • Returns true if this is Right, otherwise it returns false

    Returns this is functional.Either<never, R>

  • Returns the value inside this if it's Left or a default value if this is Right

    Parameters

    • defaultValue: L

    Returns L

  • Lazy version of leftOrDefault. Takes a function that returns the default value, that function will be called only if this is Right

    Parameters

    • getDefaultValue: (() => L)
        • (): L
        • Returns L

    Returns L

  • Constructs a Just with the value of this if it's Left or a Nothing if this is Right

    Returns functional.Maybe<L>

  • Maps the Right value of this, acts like an identity if this is Left

    Type Parameters

    • R2

    Parameters

    • f: ((value) => R2)
        • (value): R2
        • Parameters

          • value: R

          Returns R2

    Returns functional.Either<L, R2>

  • Maps the Left value of this, acts like an identity if this is Right

    Type Parameters

    • L2

    Parameters

    • f: ((value) => L2)
        • (value): L2
        • Parameters

          • value: L

          Returns L2

    Returns functional.Either<L2, R>

  • Returns the value inside this if it's Right or a default value if this is Left

    Parameters

    • defaultValue: R

    Returns R

  • Lazy version of orDefault. Takes a function that returns the default value, that function will be called only if this is Left

    Parameters

    • getDefaultValue: (() => R)
        • (): R
        • Returns R

    Returns R

  • Takes a reducer and an initial value and returns the initial value if this is Left or the result of applying the function to the initial value and the value inside this

    Type Parameters

    • T

    Parameters

    • reducer: ((accumulator, value) => T)
        • (accumulator, value): T
        • Parameters

          • accumulator: T
          • value: R

          Returns T

    • initialValue: T

    Returns T

  • Returns L | R

  • Constructs a Just with the value of this if it's Right or a Nothing if this is Left

    Returns functional.Maybe<R>

  • Returns string

  • Returns the value inside this if it's a Right or either throws the value or a generic exception depending on whether the value is an Error

    Returns R

Generated using TypeDoc