Skip to content

Instantly share code, notes, and snippets.

@karolisgrinkevicius
Created January 23, 2020 13:33
Show Gist options
  • Save karolisgrinkevicius/3dc0beb25b9c20751c8c1cb65304bef9 to your computer and use it in GitHub Desktop.
Save karolisgrinkevicius/3dc0beb25b9c20751c8c1cb65304bef9 to your computer and use it in GitHub Desktop.
pipe
type PipeFunctionArg = (...args: any[]) => object;
export const pipe = (...functions: PipeFunctionArg[]) => (...args: any[]) =>
functions.reduce((arg: any, fn: PipeFunctionArg) => (arg.length ? fn(...arg) : fn(arg)), args);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment