rightPipe
Chains synchronous transformations on an Either as long as it remains Right. The pipeline stops as soon as a Left is returned.
Interactive example
Syntax
typescript
function rightPipe<
GenericInput extends AnyValue, GenericOutputPipe1 extends AnyValue
>(
input: GenericInput,
pipe1: EitherRightPipeFunction<GenericInput, GenericOutputPipe1>
): EitherRightPipeResult<GenericInput | GenericOutputPipe1, GenericOutputPipe1>;
// ... overloads up to 15 stepsEitherRightPipeFunction receives either the unwrapped value of a Right or the value if it is not an Either, and can return an Either or a raw value.
Parameters
input: Initial value (may already be anEither).pipeX: Functions to run in sequence. Each function can return anEitheror a simple value.
Return value
- If all steps stay
Right, the last result is wrapped inEitherSuccess. - As soon as a
Leftis returned, the pipeline stops and thatLeftis propagated.
Best practices
- Use distinct info literals (
"step.1","step.2") to ease debugging. - Combine
rightPipewithE.hasInformationto branch your checks. - For async logic, prefer
rightAsyncPipe.
