pipe()
pipe<
Fns
>(...fns
): (...args
) =>PipeReturn
<Fns
>
Allows you combine two or more functions to create a new function, which passes the results from one function to the next until all have be called. Has a left-to-right call order.
Type Parameters
Fns
Fns
extends PipeArray
The list of functions starting with one that can be n-ary, followed by unary functions.
Parameters
fns
...Pipeable
<Fns
>
The functions to pipe.
Returns
(...
args
):PipeReturn
<Fns
>
Parameters
args
...PipeParams
<Fns
>
Returns
PipeReturn
<Fns
>
Remarks
The implementation follows left-to-right pipe semantics:
- The leftmost function is applied first to the input arguments
- Each subsequent function (moving right) receives the result of the previous function
- The rightmost function's result becomes the final output
Example
const getActiveUsers = pipe(
filterActive,
sortUserNames,
displayPage,
);
const activeUsers = getActiveUsers(users, currentPage);