fn
pipe
v0.0.10testedComposes functions left-to-right: `pipe(f, g)(x)` is `g(f(x))`
Example
ts
const calc = pipe((n: number) => n + 1, n => n * 2, n => `= ${n}`);
calc(3); // '= 8'Signatures
ts
export function pipe<A extends any[], B>(ab: (...a: A) => B): (...a: A) => B;ts
export function pipe<A extends any[], B, C>(ab: (...a: A) => B, bc: (b: B) => C): (...a: A) => C;ts
export function pipe<A extends any[], B, C, D>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D): (...a: A) => D;ts
export function pipe<A extends any[], B, C, D, E>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E): (...a: A) => E;ts
export function pipe<A extends any[], B, C, D, E, F>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F): (...a: A) => F;ts
export function pipe<A extends any[], B, C, D, E, F, G>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G): (...a: A) => G;ts
export function pipe<A extends any[], B, C, D, E, F, G, H>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H): (...a: A) => H;Parameters
| Parameter | Type | Description |
|---|---|---|
fns? | AnyFunction[] | The functions to pipe; the first may take any number of arguments |
Returns
AnyFunctionA function that runs the input through every function in order