Created
April 8, 2018 03:30
-
-
Save jetspeed/3a45db125c106730308386261f8d40ce to your computer and use it in GitHub Desktop.
arrow func pipeline
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 pipeline = (...funcs) => | |
val => funcs.reduce((a, b) => b(a), val); | |
const plus1 = a => a + 1; | |
const mult2 = a => a * 2; | |
const addThenMult = pipeline(plus1, mult2); | |
const r = addThenMult(5); | |
const arr = [1,2,3]; | |
console.log(arr.reduce((a, b) => a + b, 1)); | |
console.log(r) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment