Skip to content

Instantly share code, notes, and snippets.

@oskardahlberg
Created April 30, 2015 16:07
Show Gist options
  • Save oskardahlberg/802edb4e87c780a7c036 to your computer and use it in GitHub Desktop.
Save oskardahlberg/802edb4e87c780a7c036 to your computer and use it in GitHub Desktop.
async map example
function asyncMap (list, doStuff, done) {
var index = -1;
var results = [];
next();
function next (error, result) {
if (error) return done(error)
if (index == list.length) return done(results);
if (index >= 0) results[index] = result;
doStuff(list[++index], next);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment