Skip to content

Instantly share code, notes, and snippets.

@leonguyen
Created April 19, 2014 03:42
Show Gist options
  • Select an option

  • Save leonguyen/11073356 to your computer and use it in GitHub Desktop.

Select an option

Save leonguyen/11073356 to your computer and use it in GitHub Desktop.
async.eachSeries Sample
async.eachSeries = function (arr, iterator, callback) {
callback = callback || function () {};
if (!arr.length) {
return callback();
}
var completed = 0;
var iterate = function () {
iterator(arr[completed], function (err) {
if (err) {
callback(err);
callback = function () {};
}
else {
completed += 1;
if (completed >= arr.length) {
callback(null);
}
else {
iterate();
}
}
});
};
iterate();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment