Skip to content

Instantly share code, notes, and snippets.

@jhurliman
Created May 5, 2017 17:30
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 jhurliman/96adc4482db51387954d68edf36e2477 to your computer and use it in GitHub Desktop.
Save jhurliman/96adc4482db51387954d68edf36e2477 to your computer and use it in GitHub Desktop.
Wrapper for Promise.all() that adds a progress callback
function allWithProgress(promises, callback) {
let completed = 0
callback(0, promises.length)
promises.forEach(p => {
p.then(() => callback(++completed, promises.length))
})
return Promise.all(promises)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment