Skip to content

Instantly share code, notes, and snippets.

@nathan-lapinski
Last active January 3, 2019 04:35
Show Gist options
  • Save nathan-lapinski/0e0b2ecff5f2e00bdeabaaaa00d049a9 to your computer and use it in GitHub Desktop.
Save nathan-lapinski/0e0b2ecff5f2e00bdeabaaaa00d049a9 to your computer and use it in GitHub Desktop.
pipe example
const pipe = (...fns) => initialVal => fns.reduce((g,f) => f(g), initialVal);
const add1 = x => x + 1;
const mul2 = x => x * 2;
const res = pipe(add1,mul2)(0); // mul2(add1(0)) === 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment