Last active
June 6, 2018 09:01
-
-
Save me-shaon/faad53060746433a7465da80ad6c330b to your computer and use it in GitHub Desktop.
A simple PIPE method implementation using ES6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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