Skip to content

Instantly share code, notes, and snippets.

@jetspeed
Created April 8, 2018 03:30
Show Gist options
  • Save jetspeed/3a45db125c106730308386261f8d40ce to your computer and use it in GitHub Desktop.
Save jetspeed/3a45db125c106730308386261f8d40ce to your computer and use it in GitHub Desktop.
arrow func pipeline
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