Skip to main content

Compose & pipe

Compose​

const compose =
(...functions) =>
(input) =>
functions.reduceRight((acc, fn) => fn(acc), input);

Pipe​

const pipe =
(...functions) =>
(input) =>
functions.reduce((acc, fn) => fn(acc), input);