Skip to content

Instantly share code, notes, and snippets.

@iceener
Last active June 24, 2020 04:59
Show Gist options
  • Save iceener/ba1f14a1493139b035ce44a5b026f3e6 to your computer and use it in GitHub Desktop.
Save iceener/ba1f14a1493139b035ce44a5b026f3e6 to your computer and use it in GitHub Desktop.
// Pipe function composition
const pipeAsyncFunctions = (...fns) => (input) => fns.reduce((chain, func) => chain.then(func), Promise.resolve(input));
// Usage
pipeAsyncFunctions(fn1, fn2)(input).then(result => console.log(result));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment