allSeries.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
  14. *
  15. * @name everySeries
  16. * @static
  17. * @memberOf module:Collections
  18. * @method
  19. * @see [async.every]{@link module:Collections.every}
  20. * @alias allSeries
  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 collection in series.
  25. * The iteratee must complete with a boolean result value.
  26. * Invoked with (item, callback).
  27. * @param {Function} [callback] - A callback which is called after all the
  28. * `iteratee` functions have finished. Result will be either `true` or `false`
  29. * depending on the values of the async tests. Invoked with (err, result).
  30. * @returns {Promise} a promise, if no callback provided
  31. */
  32. function everySeries(coll, iteratee, callback) {
  33. return (0, _createTester2.default)(bool => !bool, res => !res)(_eachOfSeries2.default, coll, iteratee, callback);
  34. }
  35. exports.default = (0, _awaitify2.default)(everySeries, 3);
  36. module.exports = exports['default'];