Skip to main content

Variable: compose()

const compose: {(): <Value>(value) => Value; <A, B>(fn): (value) => B; <A, B, C>(fn1, fn2): (value) => C; <A, B, C, D>(fn1, fn2, fn3): (value) => D; <A, B, C, D, E>(fn1, fn2, fn3, fn4): (value) => E; <A, B, C, D, E, F>(fn1, fn2, fn3, fn4, fn5): (value) => F; <A, B, C, D, E, F, G>(fn1, fn2, fn3, fn4, fn5, fn6): (value) => G; <A, B, C, D, E, F, G, H>(fn1, fn2, fn3, fn4, fn5, fn6, fn7): (value) => H; <A, B, C, D, E, F, G, H, I>(fn1, fn2, fn3, fn4, fn5, fn6, fn7, fn8): (value) => I; <A, B, C, D, E, F, G, H, I, J>(fn1, fn2, fn3, fn4, fn5, fn6, fn7, fn8, fn9): (value) => J; }

Defined in: core.d.ts:174

Returns a function that takes a single parameter and pipes it through the given functions.

Call Signature

(): <Value>(value) => Value

Returns

<Value>(value): Value

Type Parameters

Value

Value

Parameters

value

Value

Returns

Value

Call Signature

<A, B>(fn): (value) => B

Type Parameters

A

A

B

B

Parameters

fn

(a) => B

Returns

(value): B

Parameters

value

A

Returns

B

Call Signature

<A, B, C>(fn1, fn2): (value) => C

Type Parameters

A

A

B

B

C

C

Parameters

fn1

(a) => B

fn2

(b) => C

Returns

(value): C

Parameters

value

A

Returns

C

Call Signature

<A, B, C, D>(fn1, fn2, fn3): (value) => D

Type Parameters

A

A

B

B

C

C

D

D

Parameters

fn1

(a) => B

fn2

(b) => C

fn3

(c) => D

Returns

(value): D

Parameters

value

A

Returns

D

Call Signature

<A, B, C, D, E>(fn1, fn2, fn3, fn4): (value) => E

Type Parameters

A

A

B

B

C

C

D

D

E

E

Parameters

fn1

(a) => B

fn2

(b) => C

fn3

(c) => D

fn4

(d) => E

Returns

(value): E

Parameters

value

A

Returns

E

Call Signature

<A, B, C, D, E, F>(fn1, fn2, fn3, fn4, fn5): (value) => F

Type Parameters

A

A

B

B

C

C

D

D

E

E

F

F

Parameters

fn1

(a) => B

fn2

(b) => C

fn3

(c) => D

fn4

(d) => E

fn5

(e) => F

Returns

(value): F

Parameters

value

A

Returns

F

Call Signature

<A, B, C, D, E, F, G>(fn1, fn2, fn3, fn4, fn5, fn6): (value) => G

Type Parameters

A

A

B

B

C

C

D

D

E

E

F

F

G

G

Parameters

fn1

(a) => B

fn2

(b) => C

fn3

(c) => D

fn4

(d) => E

fn5

(e) => F

fn6

(f) => G

Returns

(value): G

Parameters

value

A

Returns

G

Call Signature

<A, B, C, D, E, F, G, H>(fn1, fn2, fn3, fn4, fn5, fn6, fn7): (value) => H

Type Parameters

A

A

B

B

C

C

D

D

E

E

F

F

G

G

H

H

Parameters

fn1

(a) => B

fn2

(b) => C

fn3

(c) => D

fn4

(d) => E

fn5

(e) => F

fn6

(f) => G

fn7

(g) => H

Returns

(value): H

Parameters

value

A

Returns

H

Call Signature

<A, B, C, D, E, F, G, H, I>(fn1, fn2, fn3, fn4, fn5, fn6, fn7, fn8): (value) => I

Type Parameters

A

A

B

B

C

C

D

D

E

E

F

F

G

G

H

H

I

I

Parameters

fn1

(a) => B

fn2

(b) => C

fn3

(c) => D

fn4

(d) => E

fn5

(e) => F

fn6

(f) => G

fn7

(g) => H

fn8

(h) => I

Returns

(value): I

Parameters

value

A

Returns

I

Call Signature

<A, B, C, D, E, F, G, H, I, J>(fn1, fn2, fn3, fn4, fn5, fn6, fn7, fn8, fn9): (value) => J

Type Parameters

A

A

B

B

C

C

D

D

E

E

F

F

G

G

H

H

I

I

J

J

Parameters

fn1

(a) => B

fn2

(b) => C

fn3

(c) => D

fn4

(d) => E

fn5

(e) => F

fn6

(f) => G

fn7

(g) => H

fn8

(h) => I

fn9

(i) => J

Returns

(value): J

Parameters

value

A

Returns

J

Example

import { compose, map, reduce, toArray } from 'lfi'

const screamify = compose(
map(word => word.toUpperCase()),
reduce(toArray()),
// Also works with non-`lfi` functions!
array => array.sort(),
)

console.log(screamify([`sloth`, `lazy`, `sleep`]))
//=> [ 'SLOTH', 'LAZY', 'SLEEP' ]
Playground

Since

v0.0.2