someSeries.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _createTester = require('./internal/createTester.js');
  6. var _createTester2 = _interopRequireDefault(_createTester);
  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 [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
  14. *
  15. * @name someSeries
  16. * @static
  17. * @memberOf module:Collections
  18. * @method
  19. * @see [async.some]{@link module:Collections.some}
  20. * @alias anySeries
  21. * @category Collection
  22. * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
  23. * @param {AsyncFunction} iteratee - An async truth test to apply to each item
  24. * in the collections in series.
  25. * The iteratee should complete with a boolean `result` value.
  26. * Invoked with (item, callback).
  27. * @param {Function} [callback] - A callback which is called as soon as any
  28. * iteratee returns `true`, or after all the iteratee functions have finished.
  29. * Result will be either `true` or `false` depending on the values of the async
  30. * tests. Invoked with (err, result).
  31. * @returns {Promise} a promise, if no callback provided
  32. */
  33. function someSeries(coll, iteratee, callback) {
  34. return (0, _createTester2.default)(Boolean, res => res)(_eachOfSeries2.default, coll, iteratee, callback);
  35. }
  36. exports.default = (0, _awaitify2.default)(someSeries, 3);
  37. module.exports = exports['default'];