Interface EitherAsync<L, R>

Type Parameters

  • L

  • R

Hierarchy

Properties

then: (<TResult1, TResult2>(onfulfilled?, onrejected?) => PromiseLike<TResult1 | TResult2>)

Type declaration

    • <TResult1, TResult2>(onfulfilled?, onrejected?): PromiseLike<TResult1 | TResult2>
    • WARNING: This is implemented only for Promise compatibility. Please use chain instead.

      Type Parameters

      Parameters

      • Optional onfulfilled: null | ((value) => TResult1 | PromiseLike<TResult1>)
      • Optional onrejected: null | ((reason) => TResult2 | PromiseLike<TResult2>)

      Returns PromiseLike<TResult1 | TResult2>

Methods

  • Returns the first Right between the future value of this and another EitherAsync or the Left in the argument if both this and the argument resolve to Left

    Parameters

    Returns functional.EitherAsync<L, R>

  • Applies a Right function wrapped in EitherAsync over a future Right value. Returns Left if either the this resolves to a Left or the function is Left

    Type Parameters

    • L2

    • R2

    Parameters

    Returns functional.EitherAsync<L | L2, Awaited<R2>>

  • Given two functions, maps the value that the Promise inside this resolves to using the first if it is Left or using the second one if it is Right

    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.EitherAsync<Awaited<L2>, Awaited<R2>>

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

    Type Parameters

    • T

    Parameters

    Returns Promise<T>

  • Transforms this with a function that returns a EitherAsync. Behaviour is the same as the regular Either#chain

    Type Parameters

    • L2

    • R2

    Parameters

    Returns functional.EitherAsync<L | L2, R2>

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

    Type Parameters

    • L2

    • R2

    Parameters

    Returns functional.EitherAsync<L2, R | R2>

  • Returns this if it resolves to 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.EitherAsync<L, Awaited<R2>>

  • 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.EitherAsync<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.EitherAsync<L, R>

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

    Parameters

    • defaultValue: L

    Returns Promise<L>

  • Transforms the Right value of this with a given function. If the EitherAsync that is being mapped resolves to a Left then the mapping function won't be called and run will resolve the whole thing to that Left, just like the regular Either#map

    Type Parameters

    • R2

    Parameters

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

          • value: R

          Returns R2

    Returns functional.EitherAsync<L, Awaited<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.EitherAsync<Awaited<L2>, R>

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

    Parameters

    • defaultValue: R

    Returns Promise<R>

  • It's important to remember how run will behave because in an async context there are other ways for a function to fail other than to return a Nothing, for example: If any of the computations inside EitherAsync resolved to a Left, run will return a Promise resolved to that Left. If any of the promises were to be rejected then run will return a Promise resolved to a Left with the rejection value inside If an exception is thrown then run will return a Promise resolved to a Left with the exception inside If none of the above happen then a promise resolved to the returned value wrapped in a Right will be returned

    Returns Promise<functional.Either<L, R>>

Generated using TypeDoc