rightAsyncPipe
Asynchronous version of rightPipe. Automatically handles promises and Either, and short-circuits on the first Left.
Interactive example
Syntax
typescript
function rightAsyncPipe<
const GenericInput extends unknown,
const GenericOutputPipe1 extends unknown
>(
input: GenericInput,
pipe1: RightAsyncPipeFunction<GenericInput, GenericOutputPipe1>
): Promise<
Extract<
RightAsyncPipeResult<GenericInput | GenericOutputPipe1, GenericOutputPipe1>,
any
>
>;
// ... overloads up to 15 stepsRightAsyncPipeFunction receives the unwrapped value of a Right (after await) and can return a raw value, an Either, or a promise of these values.
Parameters
input: Starting value,Either, or promise.pipeX: Async or sync functions executed sequentially. The pipeline stops on the firstLeft.
Return value
A Promise resolved with the last Right if everything succeeds, or the Left that interrupted the pipeline.
Best practices
- Prefix your information with a clear namespace (
"user.fetch","user.validate") to track progress. - Combine
rightAsyncPipeandrightPipedepending on whether your steps are sync/async. - Let
rightAsyncPipeawait each step instead of manually unwrapping intermediate promises.
See also
rightPipe.safeCallback– To convert thrown errors intoEithervalues.
