Files
30-seconds-of-code/snippets/pipe.md
2017-12-12 17:03:14 +01:00

212 B

Pipe

Use Array.reduce() to pass value through functions.

const pipe = (...funcs) => arg => funcs.reduce((acc, func) => func(acc), arg);
// pipe(btoa, x => x.toUpperCase())("Test") -> "VGVZDA=="