Last active
June 24, 2020 04:59
-
-
Save iceener/ba1f14a1493139b035ce44a5b026f3e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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