Skip to content

Instantly share code, notes, and snippets.

@ashwinkumar2438
Last active September 9, 2020 19:07
Show Gist options
  • Save ashwinkumar2438/c23bb6cb68d2e7098edfba66088b2340 to your computer and use it in GitHub Desktop.
Save ashwinkumar2438/c23bb6cb68d2e7098edfba66088b2340 to your computer and use it in GitHub Desktop.
// Compose Function
var compose=(...args)=>(input)=>args.reduceRight((acc,fn)=>fn(acc),input);
var resulant=compose(h,g,f); //(input)=>h(g(f(input)));
// Pipe Function
var pipe=(...args)=>(input)=>args.reduce((acc,fn)=>fn(acc),input);
var resulant=pipe(f,g,h); //(input)=>h(g(f(input)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment