pipe
function pipe<T, R>(fn1, ...fns): (...args) => R;
Pipes the value of an expression into a pipeline of functions.
Type Parameters
| Type Parameter |
|---|
T extends unknown[] |
R |
Parameters
| Parameter | Type |
|---|---|
fn1 | Fn<T, R> |
...fns | Rns<R> |
Returns
(...args): R;
Parameters
| Parameter | Type |
|---|---|
...args | T |
Returns
R
Example
const len = (s: string): number => s.length;
const double = (n: number): number => n * 2;
// Without pipe
const doubleLen = (s: string) => double(len(s));
// With pipe
const doubleLen = pipe(len, double);