Skip to content

Instantly share code, notes, and snippets.

@bunnyhawk
Created November 7, 2020 16:09
Show Gist options
  • Save bunnyhawk/64b466534f638a3602bdabc308949005 to your computer and use it in GitHub Desktop.
Save bunnyhawk/64b466534f638a3602bdabc308949005 to your computer and use it in GitHub Desktop.
const pipe = (...fns) => x => fns.reduce((y, fn) => fn(y), x);
const addOne = num => num + 1;
const subtractTwo = num => num - 2;
const square = num => num * num;
const quickMaths = pipe(addOne, subtractTwo, square);
quickMaths(20);
// Returns: 361
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment