Skip to content

Instantly share code, notes, and snippets.

@lilywang711
Created September 12, 2020 12:11
Show Gist options
  • Save lilywang711/912bbf29694e0d695b3384b411987257 to your computer and use it in GitHub Desktop.
Save lilywang711/912bbf29694e0d695b3384b411987257 to your computer and use it in GitHub Desktop.
const pipe = (...fns) => (input) => fns.reduce((acc, fn) => fn(acc), input);
const addOne = (x) => x + 1;
const square = (x) => x * x;
console.log(pipe(addOne, square)(2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment