智能照明系统APP-本地串口
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.
 
 
 
 
 
 
LightingSystemApp-serial/.svn/pristine/25/2564ec464bccd4ba1f588c97326...

29 lines
650 B

var noop = require('./noop');
var each = require('./each');
var nextTick = require('./nextTick');
exports = function(tasks, cb) {
cb = cb || noop;
var results = [];
var pending = tasks.length;
if (!pending) return done(null);
each(tasks, function(task, i) {
task(function(err, result) {
taskCb(i, err, result);
});
});
function taskCb(i, err, result) {
results[i] = result;
if (--pending === 0 || err) done(err);
}
function done(err) {
nextTick(function() {
cb(err, results);
cb = noop;
});
}
};
module.exports = exports;