Signature
tsSignature
export function pipe<const Steps extends readonly [AnyBehavior, ...AnyBehavior[]]>( ...steps: Steps & ValidPipe<Steps>): PipeResult<Steps>;Imports
tsImport
import { pipe } from "@/lib/flow/pipe";import { pipe } from "@/lib/flow";Type Parameters
StepsNon-empty tuple of compatible behaviors.
Parameters
stepsSteps & ValidPipe<Steps>
Behaviors to compose in execution order.
Returns
A behavior from the first input type to the last output type.
Return type
PipeResult<Steps>Details
Each step runs only when the previous step succeeds. The output type of each step must be
assignable to the input type of the next step.
Examples
tsExample
const workflow = pipe(loadUser, map(loadUserDetails, (details) => details.email));Related Symbols
AnyBehavior
Behavior shape accepted by keyed record helpers.
type
input
Creates an identity behavior for starting typed pipelines.
function
when
Branches between two behaviors using a predicate function.
function
Source
tsflow/pipe.ts:72-79
export function pipe<const Steps extends readonly [AnyBehavior, ...AnyBehavior[]]>( ...steps: Steps & ValidPipe<Steps>): PipeResult<Steps> { const [first, ...rest] = steps; const link = sequence as unknown as (first: AnyBehavior, second: AnyBehavior) => AnyBehavior;
return rest.reduce((current, next) => link(current, next), first) as unknown as PipeResult<Steps>;}