UNPKG

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