Skip to content

Instantly share code, notes, and snippets.

@helloncanella
Created November 10, 2020 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helloncanella/90623a415c34b30a6070c6af5ca28792 to your computer and use it in GitHub Desktop.
Save helloncanella/90623a415c34b30a6070c6af5ca28792 to your computer and use it in GitHub Desktop.
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