Created
November 10, 2020 22:05
-
-
Save helloncanella/90623a415c34b30a6070c6af5ca28792 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
export default function executeSequentialPromises(funcs) { | |
return funcs.reduce( | |
(promise, func) => | |
promise.then(result => | |
(func() || Promise.resolve(undefined)).then( | |
Array.prototype.concat.bind(result) | |
) | |
), | |
Promise.resolve([]) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment