Skip to main content
pipe and flow are utility functions for composing sequences of transformations. Both are fully typed: each function’s return type becomes the next function’s argument type, with no loss of type information.
Both support up to 10 functions in a single call. If you need more, break your pipeline into named intermediate steps.

pipe(value, ...fns)

Takes an initial value and passes it through a sequence of functions left-to-right. Returns the output of the final function.
Each function’s return type informs the next function’s parameter type:

flow(...fns)

Composes functions into a single reusable function without an initial value. Call the result later with your input. Think of it as a named, reusable pipeline.
flow is useful for defining transforms you want to pass as callbacks or store as constants:

Built-in .pipe() on Result and ResultAsync

Result and ResultAsync have their own .pipe() method. It behaves like pipe, but is Result-aware: if any step returns an Err, the chain short-circuits and subsequent functions are skipped.
This also works on ResultAsync:

Complete example

This example shows all three forms working together in a data transformation pipeline: