Projekt

Obecné

Profil

Stáhnout (1.11 KB) Statistiky
| Větev: | Revize:
1
'use strict';
2

    
3
Object.defineProperty(exports, "__esModule", {
4
    value: true
5
});
6
exports.default = _parallel;
7

    
8
var _noop = require('lodash/noop');
9

    
10
var _noop2 = _interopRequireDefault(_noop);
11

    
12
var _isArrayLike = require('lodash/isArrayLike');
13

    
14
var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
15

    
16
var _slice = require('./slice');
17

    
18
var _slice2 = _interopRequireDefault(_slice);
19

    
20
var _wrapAsync = require('./wrapAsync');
21

    
22
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
23

    
24
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25

    
26
function _parallel(eachfn, tasks, callback) {
27
    callback = callback || _noop2.default;
28
    var results = (0, _isArrayLike2.default)(tasks) ? [] : {};
29

    
30
    eachfn(tasks, function (task, key, callback) {
31
        (0, _wrapAsync2.default)(task)(function (err, result) {
32
            if (arguments.length > 2) {
33
                result = (0, _slice2.default)(arguments, 1);
34
            }
35
            results[key] = result;
36
            callback(err);
37
        });
38
    }, function (err) {
39
        callback(err, results);
40
    });
41
}
42
module.exports = exports['default'];
(19-19/25)