Skip to content

Instantly share code, notes, and snippets.

@me-shaon
Last active June 6, 2018 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save me-shaon/faad53060746433a7465da80ad6c330b to your computer and use it in GitHub Desktop.
Save me-shaon/faad53060746433a7465da80ad6c330b to your computer and use it in GitHub Desktop.
A simple PIPE method implementation using ES6
const addOne = x => (x+1);
const addTwo = x => (x+2);
const addThree = x => (x+3);
const pipe = (...arr) => x => arr.reduce((res, curr) => curr(res), x);
console.log(pipe(addOne, addTwo, addThree)(2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment