interface EitherAsyncTypeRef {
    all<L, R>(
        eas: readonly functional.EitherAsync<L, R>[],
    ): functional.EitherAsync<L, R[]>;
    fromPromise<L, R>(
        f: () => PromiseLike<functional.Either<L, R>>,
    ): functional.EitherAsync<L, R>;
    lefts<L, R>(list: readonly functional.EitherAsync<L, R>[]): Promise<L[]>;
    liftEither<L, R>(
        either: functional.Either<L, R>,
    ): functional.EitherAsync<L, R>;
    rights<L, R>(list: readonly functional.EitherAsync<L, R>[]): Promise<R[]>;
    sequence<L, R>(
        eas: readonly functional.EitherAsync<L, R>[],
    ): functional.EitherAsync<L, R[]>;
    <L, R>(
        runPromise: (helpers: EitherAsyncHelpers<L>) => PromiseLike<R>,
    ): functional.EitherAsync<L, R>;
}
  • Constructs an EitherAsync object from a function that takes an object full of helpers that let you lift things into the EitherAsync context and returns a Promise

    Type Parameters

    • L
    • R

    Parameters

    • runPromise: (helpers: EitherAsyncHelpers<L>) => PromiseLike<R>

    Returns functional.EitherAsync<L, R>

Methods

  • Takes a list of EitherAsyncs and returns a Promise that will resolve with all Left values. Internally it uses Promise.all to wait for all results

    Type Parameters

    • L
    • R

    Parameters

    Returns Promise<L[]>

  • Takes a list of EitherAsyncs and returns a Promise that will resolve with all Right values. Internally it uses Promise.all to wait for all results

    Type Parameters

    • L
    • R

    Parameters

    Returns Promise<R[]>

  • Turns a list of EitherAsyncs into an EitherAsync of list. The returned Promise will be rejected as soon as a single EitherAsync resolves to a Left, it will not wait for all Promises to resolve and since EitherAsync is lazy, unlike Promise, the remaining async operations will not be executed at all

    Type Parameters

    • L
    • R

    Parameters

    Returns functional.EitherAsync<L, R[]>