You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

21 lines
500 B

module.exports = function (arr, iterator, callback) {
callback = callback || function () {};
if (!Array.isArray(arr) || !arr.length) {
return callback();
}
var completed = 0;
var iterate = function () {
iterator(arr[completed], function (err) {
if (err) {
callback(err);
callback = function () {};
}
else {
++completed;
if (completed >= arr.length) { callback(); }
else { iterate(); }
}
});
};
iterate();
};