This commit is contained in:
27
node_modules/licia/waterfall.js
generated
vendored
Normal file
27
node_modules/licia/waterfall.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
var noop = require('./noop');
|
||||
var nextTick = require('./nextTick');
|
||||
var restArgs = require('./restArgs');
|
||||
exports = function(tasks, cb) {
|
||||
cb = cb || noop;
|
||||
var current = 0;
|
||||
var taskCb = restArgs(function(err, args) {
|
||||
if (++current >= tasks.length || err) {
|
||||
args.unshift(err);
|
||||
nextTick(function() {
|
||||
cb.apply(null, args);
|
||||
});
|
||||
} else {
|
||||
args.push(taskCb);
|
||||
tasks[current].apply(null, args);
|
||||
}
|
||||
});
|
||||
if (tasks.length) {
|
||||
tasks[0](taskCb);
|
||||
} else {
|
||||
nextTick(function() {
|
||||
cb();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = exports;
|
||||
Reference in New Issue
Block a user