selectSeries.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _filter2 = require('./internal/filter.js');
  6. var _filter3 = _interopRequireDefault(_filter2);
  7. var _eachOfSeries = require('./eachOfSeries.js');
  8. var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
  9. var _awaitify = require('./internal/awaitify.js');
  10. var _awaitify2 = _interopRequireDefault(_awaitify);
  11. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12. /**
  13. * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
  14. *
  15. * @name filterSeries
  16. * @static
  17. * @memberOf module:Collections
  18. * @method
  19. * @see [async.filter]{@link module:Collections.filter}
  20. * @alias selectSeries
  21. * @category Collection
  22. * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
  23. * @param {Function} iteratee - A truth test to apply to each item in `coll`.
  24. * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
  25. * with a boolean argument once it has completed. Invoked with (item, callback).
  26. * @param {Function} [callback] - A callback which is called after all the
  27. * `iteratee` functions have finished. Invoked with (err, results)
  28. * @returns {Promise} a promise, if no callback provided
  29. */
  30. function filterSeries(coll, iteratee, callback) {
  31. return (0, _filter3.default)(_eachOfSeries2.default, coll, iteratee, callback);
  32. }
  33. exports.default = (0, _awaitify2.default)(filterSeries, 3);
  34. module.exports = exports['default'];