Skip to content

Instantly share code, notes, and snippets.

@tjjfvi
Last active October 11, 2018 22:58
Show Gist options
  • Save tjjfvi/67c6dbda48db41ae48650c3cb46da57d to your computer and use it in GitHub Desktop.
Save tjjfvi/67c6dbda48db41ae48650c3cb46da57d to your computer and use it in GitHub Desktop.
Promise.sequential(asyncFuncs): Sequentially executes the function and returns Array of results
Promise.sequential = funcs => funcs.reduce((p, fn) => p.then(rs => fn().then(r => [...rs, r])), Promise.resolve([]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment