Skip to content

Instantly share code, notes, and snippets.

@ericelliott
Created August 28, 2016 03:25
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save ericelliott/d8d334cc6684039b3e714bc0a35a8c59 to your computer and use it in GitHub Desktop.
Save ericelliott/d8d334cc6684039b3e714bc0a35a8c59 to your computer and use it in GitHub Desktop.
Pipe
const pipe = (...fns) => x => fns.reduce((v, f) => f(v), x);
const fn1 = s => s.toLowerCase();
const fn2 = s => s.split('').reverse().join('');
const fn3 = s => s + '!'
const newFunc = pipe(fn1, fn2, fn3);
const result = newFunc('Time'); // emit!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment