Skip to content

Instantly share code, notes, and snippets.

@deleteman
Created March 28, 2019 04:08
Show Gist options
  • Select an option

  • Save deleteman/df8770c83050756539d83caf87bbe89a to your computer and use it in GitHub Desktop.

Select an option

Save deleteman/df8770c83050756539d83caf87bbe89a to your computer and use it in GitHub Desktop.
async-loop.js
function asyncLoop(list, callback) {
let results = []
list.forEach( fn => {
fn( (err, result) => {
if(err) return callback(err)
results.push(result)
if(results.length == list.length) {
callback(null, results)
}
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment