Skip to main content

pipe()

pipe<A>(a): A

pipe<A, B>(a, ab): B

pipe<A, B, C>(a, ab, bc): C

pipe<A, B, C, D>(a, ab, bc, cd): D

Show 16 more signatures

pipe<A, B, C, D, E>(a, ab, bc, cd, de): E

pipe<A, B, C, D, E, F>(a, ab, bc, cd, de, ef): F

pipe<A, B, C, D, E, F, G>(a, ab, bc, cd, de, ef, fg): G

pipe<A, B, C, D, E, F, G, H>(a, ab, bc, cd, de, ef, fg, gh): H

pipe<A, B, C, D, E, F, G, H, I>(a, ab, bc, cd, de, ef, fg, gh, hi): I

pipe<A, B, C, D, E, F, G, H, I, J>(a, ab, bc, cd, de, ef, fg, gh, hi, ij): J

pipe<A, B, C, D, E, F, G, H, I, J, K>(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk): K

pipe<A, B, C, D, E, F, G, H, I, J, K, L>(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl): L

pipe<A, B, C, D, E, F, G, H, I, J, K, L, M>(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm): M

pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn): N

pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn, no): O

pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn, no, op): P

pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q>(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn, no, op, pq): Q

pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R>(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn, no, op, pq, qr): R

pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S>(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn, no, op, pq, qr, rs): S

pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T>(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn, no, op, pq, qr, rs, st): T

Composes functions left-to-right, passing the result of each to the next.

note

Supports up to 20 functions with full type inference.


Type Parameters​

A: A​

The type of the initial value.

B: B​

C: C​

D: D​

E: E​

F: F​

G: G​

H: H​

I: I​

J: J​

K: K​

L: L​

M: M​

N: N​

O: O​

P: P​

Q: Q​

R: R​

S: S​

T: T​


Parameters​

Overload 1:

a: A​

The initial value to transform.

Overload 2:

a: A​

The initial value to transform.

ab: (a) => B​

Overload 3:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

Overload 4:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

Show 16 more overloads

Overload 5:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

Overload 6:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

ef: (e) => F​

Overload 7:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

ef: (e) => F​

fg: (f) => G​

Overload 8:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

ef: (e) => F​

fg: (f) => G​

gh: (g) => H​

Overload 9:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

ef: (e) => F​

fg: (f) => G​

gh: (g) => H​

hi: (h) => I​

Overload 10:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

ef: (e) => F​

fg: (f) => G​

gh: (g) => H​

hi: (h) => I​

ij: (i) => J​

Overload 11:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

ef: (e) => F​

fg: (f) => G​

gh: (g) => H​

hi: (h) => I​

ij: (i) => J​

jk: (j) => K​

Overload 12:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

ef: (e) => F​

fg: (f) => G​

gh: (g) => H​

hi: (h) => I​

ij: (i) => J​

jk: (j) => K​

kl: (k) => L​

Overload 13:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

ef: (e) => F​

fg: (f) => G​

gh: (g) => H​

hi: (h) => I​

ij: (i) => J​

jk: (j) => K​

kl: (k) => L​

lm: (l) => M​

Overload 14:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

ef: (e) => F​

fg: (f) => G​

gh: (g) => H​

hi: (h) => I​

ij: (i) => J​

jk: (j) => K​

kl: (k) => L​

lm: (l) => M​

mn: (m) => N​

Overload 15:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

ef: (e) => F​

fg: (f) => G​

gh: (g) => H​

hi: (h) => I​

ij: (i) => J​

jk: (j) => K​

kl: (k) => L​

lm: (l) => M​

mn: (m) => N​

no: (n) => O​

Overload 16:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

ef: (e) => F​

fg: (f) => G​

gh: (g) => H​

hi: (h) => I​

ij: (i) => J​

jk: (j) => K​

kl: (k) => L​

lm: (l) => M​

mn: (m) => N​

no: (n) => O​

op: (o) => P​

Overload 17:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

ef: (e) => F​

fg: (f) => G​

gh: (g) => H​

hi: (h) => I​

ij: (i) => J​

jk: (j) => K​

kl: (k) => L​

lm: (l) => M​

mn: (m) => N​

no: (n) => O​

op: (o) => P​

pq: (p) => Q​

Overload 18:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

ef: (e) => F​

fg: (f) => G​

gh: (g) => H​

hi: (h) => I​

ij: (i) => J​

jk: (j) => K​

kl: (k) => L​

lm: (l) => M​

mn: (m) => N​

no: (n) => O​

op: (o) => P​

pq: (p) => Q​

qr: (q) => R​

Overload 19:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

ef: (e) => F​

fg: (f) => G​

gh: (g) => H​

hi: (h) => I​

ij: (i) => J​

jk: (j) => K​

kl: (k) => L​

lm: (l) => M​

mn: (m) => N​

no: (n) => O​

op: (o) => P​

pq: (p) => Q​

qr: (q) => R​

rs: (r) => S​

Overload 20:

a: A​

The initial value to transform.

ab: (a) => B​

bc: (b) => C​

cd: (c) => D​

de: (d) => E​

ef: (e) => F​

fg: (f) => G​

gh: (g) => H​

hi: (h) => I​

ij: (i) => J​

jk: (j) => K​

kl: (k) => L​

lm: (l) => M​

mn: (m) => N​

no: (n) => O​

op: (o) => P​

pq: (p) => Q​

qr: (q) => R​

rs: (r) => S​

st: (s) => T​


Returns: A​

The result of applying all transformations.


Since​

2.0.0


Performance​

Inline execution for 0-5 functions (~2x faster), loop for 6+.


Also known as​

chain (Radashi) · flow (Lodash, es-toolkit) · pipe (Remeda, Ramda, Effect) · ❌ (Modern Dash, Antfu)


Example​

pipe(5, (x) => x * 2, (x) => x + 1);
// => 11

pipe(
'hello',
(s) => s.toUpperCase(),
(s) => s.split(''),
(arr) => arr.reverse(),
(arr) => arr.join('')
);
// => 'OLLEH'

How it works?​

Composes functions left-to-right, passing each result to the next function.

Step-by-Step​

String Transformation Example​

pipe vs flowRight​

pipeflowRight
DirectionLeft β†’ RightRight β†’ Left
First argInitial valueLast function
Mental modelData flows throughMath composition

Use Cases​

Function composition and chaining πŸ“Œβ€‹

Pass a value through multiple functions in a readable left-to-right manner. Essential for functional programming and clean data processing workflows.

const add = (n: number) => n + 1;
const double = (n: number) => n * 2;
const square = (n: number) => n * n;

const result = pipe(2, add, double, square);
// pipe(2, add, double, square) β†’ add(2)=3 β†’ double(3)=6 β†’ square(6)=36
// => 36

Data transformation pipelines​

Transform data through multiple steps with type-safe function chaining. Essential for complex data processing and ETL operations.

const slug = pipe(
" Hello World ",
(s) => s.trim(),
(s) => s.toLowerCase(),
(s) => s.replace(/\s+/g, "-"),
);
// => "hello-world"

Process API response through a full pipeline​

Chain parse, normalize, and filter steps into a single readable pipeline. The real-world pattern developers write daily when consuming API data.

const response = await fetch("/api/users");
const data = await response.json();

const activeUsers = pipe(
data.users as User[],
(users) => users.filter((u) => u.isActive),
(users) => users.map((u) => ({ id: u.id, name: u.name, email: u.email })),
);
// Raw array β†’ filtered active β†’ picked fields

Build an SEO slug from a title​

Chain deburr, lowercase, and cleanup into a single slug generator. Essential for CMS platforms and blog engines generating URL-friendly slugs.

const slug = pipe(
"CafΓ© RΓ©sumΓ© β€” Γ‰tΓ© 2025",
(s) => deburr(s),
(s) => s.toLowerCase(),
(s) => s.replace(/[^a-z0-9\s]/g, ""),
(s) => s.trim().replace(/\s+/g, "-"),
);
// => "cafe-resume-ete-2025"

Process form submission through validation and sanitization​

Chain sanitization and transformation steps for form data. Critical for secure form handling with clear, composable steps.

const clean = pipe(
{ name: " Alice ", email: " Alice@Mail.COM ", message: "<b>Hello</b>" },
(data) => ({
...data,
email: data.email.toLowerCase().trim(),
name: data.name.trim(),
}),
(data) => {
if (!data.email.includes("@")) throw new Error("Invalid email");
return data;
},
(data) => ({
...data,
message: escape(data.message),
}),
);
// => { name: "Alice", email: "alice@mail.com", message: "&lt;b&gt;Hello&lt;/b&gt;" }