Skip to content

Instantly share code, notes, and snippets.

@mmckegg
Created October 13, 2013 01:57
Show Gist options
  • Save mmckegg/6957176 to your computer and use it in GitHub Desktop.
Save mmckegg/6957176 to your computer and use it in GitHub Desktop.
Async forEach
function forEach(array, fn, cb){
var i = -1
function next(err){
if (err) return cb&&cb(err)
i += 1
if (i<array.length){
fn(array[i], next, i)
} else {
cb&&cb(null)
}
}
next()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment