Projekt

Obecné

Profil

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

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

    
8
var _slice = require('./slice');
9

    
10
var _slice2 = _interopRequireDefault(_slice);
11

    
12
var _initialParams = require('./initialParams');
13

    
14
var _initialParams2 = _interopRequireDefault(_initialParams);
15

    
16
var _wrapAsync = require('./wrapAsync');
17

    
18
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
19

    
20
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21

    
22
function applyEach(eachfn) {
23
    return function (fns /*, ...args*/) {
24
        var args = (0, _slice2.default)(arguments, 1);
25
        var go = (0, _initialParams2.default)(function (args, callback) {
26
            var that = this;
27
            return eachfn(fns, function (fn, cb) {
28
                (0, _wrapAsync2.default)(fn).apply(that, args.concat(cb));
29
            }, callback);
30
        });
31
        if (args.length) {
32
            return go.apply(this, args);
33
        } else {
34
            return go;
35
        }
36
    };
37
}
38
module.exports = exports['default'];
(2-2/25)