Skip to content

Function: flow() ​

Call Signature ​

flow(): () => void

Defined in: index.ts:33

Creates function that applies given series of functions in order.

Returns ​

A new function that applies all provided functions in sequence

(): void

Returns ​

void

Examples ​

typescript
const transform = flow(
  (x: number) => x * 2,
  (x) => x + 1,
  (x) => x.toString()
); // (x: number) => string

const result = transform(5); // "11"
typescript
const asyncTransform = flow(
  (x: number) => x * 2,
  async (x) => Promise.resolve(x + 1),
  (x) => x.toString()
); // (x: number) => Promise<string>

const result = await asyncTransform(5); // "11"

Call Signature ​

flow<A, R1>(f1): (arg) => A extends Promise<unknown> ? Promise<Awaited<R1>> : R1 extends Promise<unknown> ? Promise<Awaited<R1>> : R1

Defined in: index.ts:34

Creates function that applies given series of functions in order.

Type Parameters ​

A ​

A

The input type of the first function

R1 ​

R1

Parameters ​

f1 ​

Fn<A, R1>

Returns ​

A new function that applies all provided functions in sequence

(arg): A extends Promise<unknown> ? Promise<Awaited<R1>> : R1 extends Promise<unknown> ? Promise<Awaited<R1>> : R1

Parameters ​

arg ​

A

Returns ​

A extends Promise<unknown> ? Promise<Awaited<R1>> : R1 extends Promise<unknown> ? Promise<Awaited<R1>> : R1

Examples ​

typescript
const transform = flow(
  (x: number) => x * 2,
  (x) => x + 1,
  (x) => x.toString()
); // (x: number) => string

const result = transform(5); // "11"
typescript
const asyncTransform = flow(
  (x: number) => x * 2,
  async (x) => Promise.resolve(x + 1),
  (x) => x.toString()
); // (x: number) => Promise<string>

const result = await asyncTransform(5); // "11"

Call Signature ​

flow<A, R1, R2>(f1, f2): (arg) => A extends Promise<unknown> ? Promise<Awaited<R2>> : R1 extends Promise<unknown> ? Promise<Awaited<R2>> : R2 extends Promise<unknown> ? Promise<Awaited<R2>> : R2

Defined in: index.ts:35

Creates function that applies given series of functions in order.

Type Parameters ​

A ​

A

The input type of the first function

R1 ​

R1

R2 ​

R2

Parameters ​

f1 ​

Fn<A, R1>

f2 ​

Fn<R1, R2>

Returns ​

A new function that applies all provided functions in sequence

(arg): A extends Promise<unknown> ? Promise<Awaited<R2>> : R1 extends Promise<unknown> ? Promise<Awaited<R2>> : R2 extends Promise<unknown> ? Promise<Awaited<R2>> : R2

Parameters ​

arg ​

A

Returns ​

A extends Promise<unknown> ? Promise<Awaited<R2>> : R1 extends Promise<unknown> ? Promise<Awaited<R2>> : R2 extends Promise<unknown> ? Promise<Awaited<R2>> : R2

Examples ​

typescript
const transform = flow(
  (x: number) => x * 2,
  (x) => x + 1,
  (x) => x.toString()
); // (x: number) => string

const result = transform(5); // "11"
typescript
const asyncTransform = flow(
  (x: number) => x * 2,
  async (x) => Promise.resolve(x + 1),
  (x) => x.toString()
); // (x: number) => Promise<string>

const result = await asyncTransform(5); // "11"

Call Signature ​

flow<A, R1, R2, R3>(f1, f2, f3): (arg) => A extends Promise<unknown> ? Promise<Awaited<R3>> : R1 extends Promise<unknown> ? Promise<Awaited<R3>> : R2 extends Promise<unknown> ? Promise<Awaited<R3>> : R3 extends Promise<unknown> ? Promise<Awaited<R3>> : R3

Defined in: index.ts:36

Creates function that applies given series of functions in order.

Type Parameters ​

A ​

A

The input type of the first function

R1 ​

R1

R2 ​

R2

R3 ​

R3

Parameters ​

f1 ​

Fn<A, R1>

f2 ​

Fn<R1, R2>

f3 ​

Fn<R2, R3>

Returns ​

A new function that applies all provided functions in sequence

(arg): A extends Promise<unknown> ? Promise<Awaited<R3>> : R1 extends Promise<unknown> ? Promise<Awaited<R3>> : R2 extends Promise<unknown> ? Promise<Awaited<R3>> : R3 extends Promise<unknown> ? Promise<Awaited<R3>> : R3

Parameters ​

arg ​

A

Returns ​

A extends Promise<unknown> ? Promise<Awaited<R3>> : R1 extends Promise<unknown> ? Promise<Awaited<R3>> : R2 extends Promise<unknown> ? Promise<Awaited<R3>> : R3 extends Promise<unknown> ? Promise<Awaited<R3>> : R3

Examples ​

typescript
const transform = flow(
  (x: number) => x * 2,
  (x) => x + 1,
  (x) => x.toString()
); // (x: number) => string

const result = transform(5); // "11"
typescript
const asyncTransform = flow(
  (x: number) => x * 2,
  async (x) => Promise.resolve(x + 1),
  (x) => x.toString()
); // (x: number) => Promise<string>

const result = await asyncTransform(5); // "11"

Call Signature ​

flow<A, R1, R2, R3, R4>(f1, f2, f3, f4): (arg) => A extends Promise<unknown> ? Promise<Awaited<R4>> : R1 extends Promise<unknown> ? Promise<Awaited<R4>> : R2 extends Promise<unknown> ? Promise<Awaited<R4>> : R3 extends Promise<unknown> ? Promise<Awaited<R4>> : R4 extends Promise<unknown> ? Promise<Awaited<R4>> : R4

Defined in: index.ts:41

Creates function that applies given series of functions in order.

Type Parameters ​

A ​

A

The input type of the first function

R1 ​

R1

R2 ​

R2

R3 ​

R3

R4 ​

R4

Parameters ​

f1 ​

Fn<A, R1>

f2 ​

Fn<R1, R2>

f3 ​

Fn<R2, R3>

f4 ​

Fn<R3, R4>

Returns ​

A new function that applies all provided functions in sequence

(arg): A extends Promise<unknown> ? Promise<Awaited<R4>> : R1 extends Promise<unknown> ? Promise<Awaited<R4>> : R2 extends Promise<unknown> ? Promise<Awaited<R4>> : R3 extends Promise<unknown> ? Promise<Awaited<R4>> : R4 extends Promise<unknown> ? Promise<Awaited<R4>> : R4

Parameters ​

arg ​

A

Returns ​

A extends Promise<unknown> ? Promise<Awaited<R4>> : R1 extends Promise<unknown> ? Promise<Awaited<R4>> : R2 extends Promise<unknown> ? Promise<Awaited<R4>> : R3 extends Promise<unknown> ? Promise<Awaited<R4>> : R4 extends Promise<unknown> ? Promise<Awaited<R4>> : R4

Examples ​

typescript
const transform = flow(
  (x: number) => x * 2,
  (x) => x + 1,
  (x) => x.toString()
); // (x: number) => string

const result = transform(5); // "11"
typescript
const asyncTransform = flow(
  (x: number) => x * 2,
  async (x) => Promise.resolve(x + 1),
  (x) => x.toString()
); // (x: number) => Promise<string>

const result = await asyncTransform(5); // "11"

Call Signature ​

flow<A, R1, R2, R3, R4, R5>(f1, f2, f3, f4, f5): (arg) => A extends Promise<unknown> ? Promise<Awaited<R5>> : R1 extends Promise<unknown> ? Promise<Awaited<R5>> : R2 extends Promise<unknown> ? Promise<Awaited<R5>> : R3 extends Promise<unknown> ? Promise<Awaited<R5>> : R4 extends Promise<unknown> ? Promise<Awaited<R5>> : R5 extends Promise<unknown> ? Promise<Awaited<R5>> : R5

Defined in: index.ts:47

Creates function that applies given series of functions in order.

Type Parameters ​

A ​

A

The input type of the first function

R1 ​

R1

R2 ​

R2

R3 ​

R3

R4 ​

R4

R5 ​

R5

Parameters ​

f1 ​

Fn<A, R1>

f2 ​

Fn<R1, R2>

f3 ​

Fn<R2, R3>

f4 ​

Fn<R3, R4>

f5 ​

Fn<R4, R5>

Returns ​

A new function that applies all provided functions in sequence

(arg): A extends Promise<unknown> ? Promise<Awaited<R5>> : R1 extends Promise<unknown> ? Promise<Awaited<R5>> : R2 extends Promise<unknown> ? Promise<Awaited<R5>> : R3 extends Promise<unknown> ? Promise<Awaited<R5>> : R4 extends Promise<unknown> ? Promise<Awaited<R5>> : R5 extends Promise<unknown> ? Promise<Awaited<R5>> : R5

Parameters ​

arg ​

A

Returns ​

A extends Promise<unknown> ? Promise<Awaited<R5>> : R1 extends Promise<unknown> ? Promise<Awaited<R5>> : R2 extends Promise<unknown> ? Promise<Awaited<R5>> : R3 extends Promise<unknown> ? Promise<Awaited<R5>> : R4 extends Promise<unknown> ? Promise<Awaited<R5>> : R5 extends Promise<unknown> ? Promise<Awaited<R5>> : R5

Examples ​

typescript
const transform = flow(
  (x: number) => x * 2,
  (x) => x + 1,
  (x) => x.toString()
); // (x: number) => string

const result = transform(5); // "11"
typescript
const asyncTransform = flow(
  (x: number) => x * 2,
  async (x) => Promise.resolve(x + 1),
  (x) => x.toString()
); // (x: number) => Promise<string>

const result = await asyncTransform(5); // "11"

Call Signature ​

flow<A, R1, R2, R3, R4, R5, R6>(f1, f2, f3, f4, f5, f6): (arg) => A extends Promise<unknown> ? Promise<Awaited<R6>> : R1 extends Promise<unknown> ? Promise<Awaited<R6>> : R2 extends Promise<unknown> ? Promise<Awaited<R6>> : R3 extends Promise<unknown> ? Promise<Awaited<R6>> : R4 extends Promise<unknown> ? Promise<Awaited<R6>> : R5 extends Promise<unknown> ? Promise<Awaited<R6>> : R6 extends Promise<unknown> ? Promise<Awaited<R6>> : R6

Defined in: index.ts:54

Creates function that applies given series of functions in order.

Type Parameters ​

A ​

A

The input type of the first function

R1 ​

R1

R2 ​

R2

R3 ​

R3

R4 ​

R4

R5 ​

R5

R6 ​

R6

Parameters ​

f1 ​

Fn<A, R1>

f2 ​

Fn<R1, R2>

f3 ​

Fn<R2, R3>

f4 ​

Fn<R3, R4>

f5 ​

Fn<R4, R5>

f6 ​

Fn<R5, R6>

Returns ​

A new function that applies all provided functions in sequence

(arg): A extends Promise<unknown> ? Promise<Awaited<R6>> : R1 extends Promise<unknown> ? Promise<Awaited<R6>> : R2 extends Promise<unknown> ? Promise<Awaited<R6>> : R3 extends Promise<unknown> ? Promise<Awaited<R6>> : R4 extends Promise<unknown> ? Promise<Awaited<R6>> : R5 extends Promise<unknown> ? Promise<Awaited<R6>> : R6 extends Promise<unknown> ? Promise<Awaited<R6>> : R6

Parameters ​

arg ​

A

Returns ​

A extends Promise<unknown> ? Promise<Awaited<R6>> : R1 extends Promise<unknown> ? Promise<Awaited<R6>> : R2 extends Promise<unknown> ? Promise<Awaited<R6>> : R3 extends Promise<unknown> ? Promise<Awaited<R6>> : R4 extends Promise<unknown> ? Promise<Awaited<R6>> : R5 extends Promise<unknown> ? Promise<Awaited<R6>> : R6 extends Promise<unknown> ? Promise<Awaited<R6>> : R6

Examples ​

typescript
const transform = flow(
  (x: number) => x * 2,
  (x) => x + 1,
  (x) => x.toString()
); // (x: number) => string

const result = transform(5); // "11"
typescript
const asyncTransform = flow(
  (x: number) => x * 2,
  async (x) => Promise.resolve(x + 1),
  (x) => x.toString()
); // (x: number) => Promise<string>

const result = await asyncTransform(5); // "11"

Call Signature ​

flow<A, R1, R2, R3, R4, R5, R6, R7>(f1, f2, f3, f4, f5, f6, f7): (arg) => A extends Promise<unknown> ? Promise<Awaited<R7>> : R1 extends Promise<unknown> ? Promise<Awaited<R7>> : R2 extends Promise<unknown> ? Promise<Awaited<R7>> : R3 extends Promise<unknown> ? Promise<Awaited<R7>> : R4 extends Promise<unknown> ? Promise<Awaited<R7>> : R5 extends Promise<unknown> ? Promise<Awaited<R7>> : R6 extends Promise<unknown> ? Promise<Awaited<R7>> : R7 extends Promise<unknown> ? Promise<Awaited<...>> : R7

Defined in: index.ts:62

Creates function that applies given series of functions in order.

Type Parameters ​

A ​

A

The input type of the first function

R1 ​

R1

R2 ​

R2

R3 ​

R3

R4 ​

R4

R5 ​

R5

R6 ​

R6

R7 ​

R7

Parameters ​

f1 ​

Fn<A, R1>

f2 ​

Fn<R1, R2>

f3 ​

Fn<R2, R3>

f4 ​

Fn<R3, R4>

f5 ​

Fn<R4, R5>

f6 ​

Fn<R5, R6>

f7 ​

Fn<R6, R7>

Returns ​

A new function that applies all provided functions in sequence

(arg): A extends Promise<unknown> ? Promise<Awaited<R7>> : R1 extends Promise<unknown> ? Promise<Awaited<R7>> : R2 extends Promise<unknown> ? Promise<Awaited<R7>> : R3 extends Promise<unknown> ? Promise<Awaited<R7>> : R4 extends Promise<unknown> ? Promise<Awaited<R7>> : R5 extends Promise<unknown> ? Promise<Awaited<R7>> : R6 extends Promise<unknown> ? Promise<Awaited<R7>> : R7 extends Promise<unknown> ? Promise<Awaited<...>> : R7

Parameters ​

arg ​

A

Returns ​

A extends Promise<unknown> ? Promise<Awaited<R7>> : R1 extends Promise<unknown> ? Promise<Awaited<R7>> : R2 extends Promise<unknown> ? Promise<Awaited<R7>> : R3 extends Promise<unknown> ? Promise<Awaited<R7>> : R4 extends Promise<unknown> ? Promise<Awaited<R7>> : R5 extends Promise<unknown> ? Promise<Awaited<R7>> : R6 extends Promise<unknown> ? Promise<Awaited<R7>> : R7 extends Promise<unknown> ? Promise<Awaited<...>> : R7

Examples ​

typescript
const transform = flow(
  (x: number) => x * 2,
  (x) => x + 1,
  (x) => x.toString()
); // (x: number) => string

const result = transform(5); // "11"
typescript
const asyncTransform = flow(
  (x: number) => x * 2,
  async (x) => Promise.resolve(x + 1),
  (x) => x.toString()
); // (x: number) => Promise<string>

const result = await asyncTransform(5); // "11"

Call Signature ​

flow<A, R1, R2, R3, R4, R5, R6, R7, R8>(f1, f2, f3, f4, f5, f6, f7, f8): (arg) => A extends Promise<unknown> ? Promise<Awaited<R8>> : R1 extends Promise<unknown> ? Promise<Awaited<R8>> : R2 extends Promise<unknown> ? Promise<Awaited<R8>> : R3 extends Promise<unknown> ? Promise<Awaited<R8>> : R4 extends Promise<unknown> ? Promise<Awaited<R8>> : R5 extends Promise<unknown> ? Promise<Awaited<R8>> : R6 extends Promise<unknown> ? Promise<Awaited<R8>> : R7 extends Promise<unknown> ? Promise<Awaited<...>> : R8 extends Promise<...> ? Promise<...> : R8

Defined in: index.ts:71

Creates function that applies given series of functions in order.

Type Parameters ​

A ​

A

The input type of the first function

R1 ​

R1

R2 ​

R2

R3 ​

R3

R4 ​

R4

R5 ​

R5

R6 ​

R6

R7 ​

R7

R8 ​

R8

Parameters ​

f1 ​

Fn<A, R1>

f2 ​

Fn<R1, R2>

f3 ​

Fn<R2, R3>

f4 ​

Fn<R3, R4>

f5 ​

Fn<R4, R5>

f6 ​

Fn<R5, R6>

f7 ​

Fn<R6, R7>

f8 ​

Fn<R7, R8>

Returns ​

A new function that applies all provided functions in sequence

(arg): A extends Promise<unknown> ? Promise<Awaited<R8>> : R1 extends Promise<unknown> ? Promise<Awaited<R8>> : R2 extends Promise<unknown> ? Promise<Awaited<R8>> : R3 extends Promise<unknown> ? Promise<Awaited<R8>> : R4 extends Promise<unknown> ? Promise<Awaited<R8>> : R5 extends Promise<unknown> ? Promise<Awaited<R8>> : R6 extends Promise<unknown> ? Promise<Awaited<R8>> : R7 extends Promise<unknown> ? Promise<Awaited<...>> : R8 extends Promise<...> ? Promise<...> : R8

Parameters ​

arg ​

A

Returns ​

A extends Promise<unknown> ? Promise<Awaited<R8>> : R1 extends Promise<unknown> ? Promise<Awaited<R8>> : R2 extends Promise<unknown> ? Promise<Awaited<R8>> : R3 extends Promise<unknown> ? Promise<Awaited<R8>> : R4 extends Promise<unknown> ? Promise<Awaited<R8>> : R5 extends Promise<unknown> ? Promise<Awaited<R8>> : R6 extends Promise<unknown> ? Promise<Awaited<R8>> : R7 extends Promise<unknown> ? Promise<Awaited<...>> : R8 extends Promise<...> ? Promise<...> : R8

Examples ​

typescript
const transform = flow(
  (x: number) => x * 2,
  (x) => x + 1,
  (x) => x.toString()
); // (x: number) => string

const result = transform(5); // "11"
typescript
const asyncTransform = flow(
  (x: number) => x * 2,
  async (x) => Promise.resolve(x + 1),
  (x) => x.toString()
); // (x: number) => Promise<string>

const result = await asyncTransform(5); // "11"

Call Signature ​

flow<A, R1, R2, R3, R4, R5, R6, R7, R8, R9>(f1, f2, f3, f4, f5, f6, f7, f8, f9): (arg) => A extends Promise<unknown> ? Promise<Awaited<R9>> : R1 extends Promise<unknown> ? Promise<Awaited<R9>> : R2 extends Promise<unknown> ? Promise<Awaited<R9>> : R3 extends Promise<unknown> ? Promise<Awaited<R9>> : R4 extends Promise<unknown> ? Promise<Awaited<R9>> : R5 extends Promise<unknown> ? Promise<Awaited<R9>> : R6 extends Promise<unknown> ? Promise<Awaited<R9>> : R7 extends Promise<unknown> ? Promise<Awaited<...>> : R8 extends Promise<...> ? Promise<...> : ... extends ... ? ... : ...

Defined in: index.ts:81

Creates function that applies given series of functions in order.

Type Parameters ​

A ​

A

The input type of the first function

R1 ​

R1

R2 ​

R2

R3 ​

R3

R4 ​

R4

R5 ​

R5

R6 ​

R6

R7 ​

R7

R8 ​

R8

R9 ​

R9

Parameters ​

f1 ​

Fn<A, R1>

f2 ​

Fn<R1, R2>

f3 ​

Fn<R2, R3>

f4 ​

Fn<R3, R4>

f5 ​

Fn<R4, R5>

f6 ​

Fn<R5, R6>

f7 ​

Fn<R6, R7>

f8 ​

Fn<R7, R8>

f9 ​

Fn<R8, R9>

Returns ​

A new function that applies all provided functions in sequence

(arg): A extends Promise<unknown> ? Promise<Awaited<R9>> : R1 extends Promise<unknown> ? Promise<Awaited<R9>> : R2 extends Promise<unknown> ? Promise<Awaited<R9>> : R3 extends Promise<unknown> ? Promise<Awaited<R9>> : R4 extends Promise<unknown> ? Promise<Awaited<R9>> : R5 extends Promise<unknown> ? Promise<Awaited<R9>> : R6 extends Promise<unknown> ? Promise<Awaited<R9>> : R7 extends Promise<unknown> ? Promise<Awaited<...>> : R8 extends Promise<...> ? Promise<...> : ... extends ... ? ... : ...

Parameters ​

arg ​

A

Returns ​

A extends Promise<unknown> ? Promise<Awaited<R9>> : R1 extends Promise<unknown> ? Promise<Awaited<R9>> : R2 extends Promise<unknown> ? Promise<Awaited<R9>> : R3 extends Promise<unknown> ? Promise<Awaited<R9>> : R4 extends Promise<unknown> ? Promise<Awaited<R9>> : R5 extends Promise<unknown> ? Promise<Awaited<R9>> : R6 extends Promise<unknown> ? Promise<Awaited<R9>> : R7 extends Promise<unknown> ? Promise<Awaited<...>> : R8 extends Promise<...> ? Promise<...> : ... extends ... ? ... : ...

Examples ​

typescript
const transform = flow(
  (x: number) => x * 2,
  (x) => x + 1,
  (x) => x.toString()
); // (x: number) => string

const result = transform(5); // "11"
typescript
const asyncTransform = flow(
  (x: number) => x * 2,
  async (x) => Promise.resolve(x + 1),
  (x) => x.toString()
); // (x: number) => Promise<string>

const result = await asyncTransform(5); // "11"

Call Signature ​

flow<A, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10>(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10): (arg) => A extends Promise<unknown> ? Promise<Awaited<R10>> : R1 extends Promise<unknown> ? Promise<Awaited<R10>> : R2 extends Promise<unknown> ? Promise<Awaited<R10>> : R3 extends Promise<unknown> ? Promise<Awaited<R10>> : R4 extends Promise<unknown> ? Promise<Awaited<R10>> : R5 extends Promise<unknown> ? Promise<Awaited<R10>> : R6 extends Promise<unknown> ? Promise<Awaited<R10>> : R7 extends Promise<unknown> ? Promise<Awaited<...>> : R8 extends Promise<...> ? Promise<...> : ... extends ... ? ... : ...

Defined in: index.ts:92

Creates function that applies given series of functions in order.

Type Parameters ​

A ​

A

The input type of the first function

R1 ​

R1

R2 ​

R2

R3 ​

R3

R4 ​

R4

R5 ​

R5

R6 ​

R6

R7 ​

R7

R8 ​

R8

R9 ​

R9

R10 ​

R10

Parameters ​

f1 ​

Fn<A, R1>

f2 ​

Fn<R1, R2>

f3 ​

Fn<R2, R3>

f4 ​

Fn<R3, R4>

f5 ​

Fn<R4, R5>

f6 ​

Fn<R5, R6>

f7 ​

Fn<R6, R7>

f8 ​

Fn<R7, R8>

f9 ​

Fn<R8, R9>

f10 ​

Fn<R9, R10>

Returns ​

A new function that applies all provided functions in sequence

(arg): A extends Promise<unknown> ? Promise<Awaited<R10>> : R1 extends Promise<unknown> ? Promise<Awaited<R10>> : R2 extends Promise<unknown> ? Promise<Awaited<R10>> : R3 extends Promise<unknown> ? Promise<Awaited<R10>> : R4 extends Promise<unknown> ? Promise<Awaited<R10>> : R5 extends Promise<unknown> ? Promise<Awaited<R10>> : R6 extends Promise<unknown> ? Promise<Awaited<R10>> : R7 extends Promise<unknown> ? Promise<Awaited<...>> : R8 extends Promise<...> ? Promise<...> : ... extends ... ? ... : ...

Parameters ​

arg ​

A

Returns ​

A extends Promise<unknown> ? Promise<Awaited<R10>> : R1 extends Promise<unknown> ? Promise<Awaited<R10>> : R2 extends Promise<unknown> ? Promise<Awaited<R10>> : R3 extends Promise<unknown> ? Promise<Awaited<R10>> : R4 extends Promise<unknown> ? Promise<Awaited<R10>> : R5 extends Promise<unknown> ? Promise<Awaited<R10>> : R6 extends Promise<unknown> ? Promise<Awaited<R10>> : R7 extends Promise<unknown> ? Promise<Awaited<...>> : R8 extends Promise<...> ? Promise<...> : ... extends ... ? ... : ...

Examples ​

typescript
const transform = flow(
  (x: number) => x * 2,
  (x) => x + 1,
  (x) => x.toString()
); // (x: number) => string

const result = transform(5); // "11"
typescript
const asyncTransform = flow(
  (x: number) => x * 2,
  async (x) => Promise.resolve(x + 1),
  (x) => x.toString()
); // (x: number) => Promise<string>

const result = await asyncTransform(5); // "11"

Call Signature ​

flow<A>(...fns): Fn<A, unknown>

Defined in: index.ts:104

Creates function that applies given series of functions in order.

Type Parameters ​

A ​

A

The input type of the first function

Parameters ​

fns ​

...Fn[]

A series of functions to compose, where each function's input type matches the previous function's output

Returns ​

Fn<A, unknown>

A new function that applies all provided functions in sequence

Examples ​

typescript
const transform = flow(
  (x: number) => x * 2,
  (x) => x + 1,
  (x) => x.toString()
); // (x: number) => string

const result = transform(5); // "11"
typescript
const asyncTransform = flow(
  (x: number) => x * 2,
  async (x) => Promise.resolve(x + 1),
  (x) => x.toString()
); // (x: number) => Promise<string>

const result = await asyncTransform(5); // "11"