38 lines
1000 B
JavaScript
38 lines
1000 B
JavaScript
|
'use strict';
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.default = _parallel;
|
||
|
|
||
|
var _noop = require('lodash/noop');
|
||
|
|
||
|
var _noop2 = _interopRequireDefault(_noop);
|
||
|
|
||
|
var _isArrayLike = require('lodash/isArrayLike');
|
||
|
|
||
|
var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
|
||
|
|
||
|
var _rest = require('lodash/rest');
|
||
|
|
||
|
var _rest2 = _interopRequireDefault(_rest);
|
||
|
|
||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
|
||
|
function _parallel(eachfn, tasks, callback) {
|
||
|
callback = callback || _noop2.default;
|
||
|
var results = (0, _isArrayLike2.default)(tasks) ? [] : {};
|
||
|
|
||
|
eachfn(tasks, function (task, key, callback) {
|
||
|
task((0, _rest2.default)(function (err, args) {
|
||
|
if (args.length <= 1) {
|
||
|
args = args[0];
|
||
|
}
|
||
|
results[key] = args;
|
||
|
callback(err);
|
||
|
}));
|
||
|
}, function (err) {
|
||
|
callback(err, results);
|
||
|
});
|
||
|
}
|
||
|
module.exports = exports['default'];
|