pipe (Functional Programming) es-toolkit
Performs left-to-right function composition, threading a value through a sequence of functions.
pipe is the composition entry point for es-toolkit/fp. Use it when you want to pass a value through transformations from left to right.
Usage
pipe is the entry point of es-toolkit/fp. It takes an initial value and applies each function to it in order, passing the result of one function as the input to the next. This reads top-to-bottom in the same order the transformation runs, which removes nesting and temporary variables.
Every es-toolkit/fp function returns a function that takes the data, so it slots directly into a pipe.
Any unary function works inside a pipe, not just es-toolkit functions.
Lazy evaluation
When consecutive lazy-capable functions (map, filter, take, …) appear together, pipe fuses them and processes the input element-by-element instead of building an intermediate array after every step. A trailing take can terminate the walk early, so the earlier functions never run on the rest of the input.
Parameters
The initial value fed into the pipeline.
The functions to apply, from left to right. Each receives the output of the previous one.
Returns
The result of applying every function to value in sequence. The public overloads infer the precise type from the chain.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.