Bones/node_modules/async-each-series/index.js
SOUTHERNCO\x2mjbyrn 7efe7605b8 Template Upload
2017-05-17 13:45:25 -04:00

22 lines
500 B
JavaScript

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();
};