Skip to content

Instantly share code, notes, and snippets.

@tuan
Created May 28, 2016 06:56
Show Gist options
  • Save tuan/9b2e20f293469ee3b215d4ef123cfd48 to your computer and use it in GitHub Desktop.
Save tuan/9b2e20f293469ee3b215d4ef123cfd48 to your computer and use it in GitHub Desktop.
let pipe = (value, ...funs) => {
return funs.reduce((accumulator, currentFun) => currentFun(accumulator), value);
}
let add1 = x => x + 1;
let multiply2 = x => x * 2;
pipe(10, add1, add1, multiply2, console.log);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment