a zip code crypto-currency system good for red ONLY

concatLimit.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = function (coll, limit, iteratee, callback) {
  6. callback = callback || _noop2.default;
  7. var _iteratee = (0, _wrapAsync2.default)(iteratee);
  8. (0, _mapLimit2.default)(coll, limit, function (val, callback) {
  9. _iteratee(val, function (err /*, ...args*/) {
  10. if (err) return callback(err);
  11. return callback(null, (0, _slice2.default)(arguments, 1));
  12. });
  13. }, function (err, mapResults) {
  14. var result = [];
  15. for (var i = 0; i < mapResults.length; i++) {
  16. if (mapResults[i]) {
  17. result = _concat.apply(result, mapResults[i]);
  18. }
  19. }
  20. return callback(err, result);
  21. });
  22. };
  23. var _noop = require('lodash/noop');
  24. var _noop2 = _interopRequireDefault(_noop);
  25. var _wrapAsync = require('./internal/wrapAsync');
  26. var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
  27. var _slice = require('./internal/slice');
  28. var _slice2 = _interopRequireDefault(_slice);
  29. var _mapLimit = require('./mapLimit');
  30. var _mapLimit2 = _interopRequireDefault(_mapLimit);
  31. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  32. var _concat = Array.prototype.concat;
  33. /**
  34. * The same as [`concat`]{@link module:Collections.concat} but runs a maximum of `limit` async operations at a time.
  35. *
  36. * @name concatLimit
  37. * @static
  38. * @memberOf module:Collections
  39. * @method
  40. * @see [async.concat]{@link module:Collections.concat}
  41. * @category Collection
  42. * @param {Array|Iterable|Object} coll - A collection to iterate over.
  43. * @param {number} limit - The maximum number of async operations at a time.
  44. * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
  45. * which should use an array as its result. Invoked with (item, callback).
  46. * @param {Function} [callback] - A callback which is called after all the
  47. * `iteratee` functions have finished, or an error occurs. Results is an array
  48. * containing the concatenated results of the `iteratee` function. Invoked with
  49. * (err, results).
  50. */
  51. module.exports = exports['default'];