1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | exports.default = function (coll, limit, iteratee, callback) {
|
8 | callback = callback || _noop2.default;
|
9 | var _iteratee = (0, _wrapAsync2.default)(iteratee);
|
10 | (0, _mapLimit2.default)(coll, limit, function (val, callback) {
|
11 | _iteratee(val, function (err, key) {
|
12 | if (err) return callback(err);
|
13 | return callback(null, { key: key, val: val });
|
14 | });
|
15 | }, function (err, mapResults) {
|
16 | var result = {};
|
17 |
|
18 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
19 |
|
20 | for (var i = 0; i < mapResults.length; i++) {
|
21 | if (mapResults[i]) {
|
22 | var key = mapResults[i].key;
|
23 | var val = mapResults[i].val;
|
24 |
|
25 | if (hasOwnProperty.call(result, key)) {
|
26 | result[key].push(val);
|
27 | } else {
|
28 | result[key] = [val];
|
29 | }
|
30 | }
|
31 | }
|
32 |
|
33 | return callback(err, result);
|
34 | });
|
35 | };
|
36 |
|
37 | var _noop = require('lodash/noop');
|
38 |
|
39 | var _noop2 = _interopRequireDefault(_noop);
|
40 |
|
41 | var _mapLimit = require('./mapLimit');
|
42 |
|
43 | var _mapLimit2 = _interopRequireDefault(_mapLimit);
|
44 |
|
45 | var _wrapAsync = require('./internal/wrapAsync');
|
46 |
|
47 | var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
48 |
|
49 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
50 |
|
51 | ;
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | module.exports = exports['default']; |
\ | No newline at end of file |