async.during
Version:
async duringmethod as module.
26 lines (20 loc) • 531 B
JavaScript
;
var noop = require('async.util.noop');
var restParam = require('async.util.restparam');
module.exports = function during(test, iterator, cb) {
cb = cb || noop;
var next = restParam(function(err, args) {
if (err) {
cb(err);
} else {
args.push(check);
test.apply(this, args);
}
});
var check = function(err, truth) {
if (err) return cb(err);
if (!truth) return cb(null);
iterator(next);
};
test(check);
};