UNPKG

1.46 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _timesLimit = require('./timesLimit');
8
9var _timesLimit2 = _interopRequireDefault(_timesLimit);
10
11var _doLimit = require('./internal/doLimit');
12
13var _doLimit2 = _interopRequireDefault(_doLimit);
14
15function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
17/**
18 * Calls the `iteratee` function `n` times, and accumulates results in the same
19 * manner you would use with [map]{@link module:Collections.map}.
20 *
21 * @name times
22 * @static
23 * @memberOf module:ControlFlow
24 * @method
25 * @see [async.map]{@link module:Collections.map}
26 * @category Control Flow
27 * @param {number} n - The number of times to run the function.
28 * @param {AsyncFunction} iteratee - The async function to call `n` times.
29 * Invoked with the iteration index and a callback: (n, next).
30 * @param {Function} callback - see {@link module:Collections.map}.
31 * @example
32 *
33 * // Pretend this is some complicated async factory
34 * var createUser = function(id, callback) {
35 * callback(null, {
36 * id: 'user' + id
37 * });
38 * };
39 *
40 * // generate 5 users
41 * async.times(5, function(n, next) {
42 * createUser(n, function(err, user) {
43 * next(err, user);
44 * });
45 * }, function(err, users) {
46 * // we should now have 5 users
47 * });
48 */
49exports.default = (0, _doLimit2.default)(_timesLimit2.default, Infinity);
50module.exports = exports['default'];
\No newline at end of file