source: trip-planner-front/node_modules/async/parallel.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.0 KB
Line 
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = parallelLimit;
7
8var _eachOf = require('./eachOf');
9
10var _eachOf2 = _interopRequireDefault(_eachOf);
11
12var _parallel = require('./internal/parallel');
13
14var _parallel2 = _interopRequireDefault(_parallel);
15
16function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
18/**
19 * Run the `tasks` collection of functions in parallel, without waiting until
20 * the previous function has completed. If any of the functions pass an error to
21 * its callback, the main `callback` is immediately called with the value of the
22 * error. Once the `tasks` have completed, the results are passed to the final
23 * `callback` as an array.
24 *
25 * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about
26 * parallel execution of code. If your tasks do not use any timers or perform
27 * any I/O, they will actually be executed in series. Any synchronous setup
28 * sections for each task will happen one after the other. JavaScript remains
29 * single-threaded.
30 *
31 * **Hint:** Use [`reflect`]{@link module:Utils.reflect} to continue the
32 * execution of other tasks when a task fails.
33 *
34 * It is also possible to use an object instead of an array. Each property will
35 * be run as a function and the results will be passed to the final `callback`
36 * as an object instead of an array. This can be a more readable way of handling
37 * results from {@link async.parallel}.
38 *
39 * @name parallel
40 * @static
41 * @memberOf module:ControlFlow
42 * @method
43 * @category Control Flow
44 * @param {Array|Iterable|Object} tasks - A collection of
45 * [async functions]{@link AsyncFunction} to run.
46 * Each async function can complete with any number of optional `result` values.
47 * @param {Function} [callback] - An optional callback to run once all the
48 * functions have completed successfully. This function gets a results array
49 * (or object) containing all the result arguments passed to the task callbacks.
50 * Invoked with (err, results).
51 *
52 * @example
53 * async.parallel([
54 * function(callback) {
55 * setTimeout(function() {
56 * callback(null, 'one');
57 * }, 200);
58 * },
59 * function(callback) {
60 * setTimeout(function() {
61 * callback(null, 'two');
62 * }, 100);
63 * }
64 * ],
65 * // optional callback
66 * function(err, results) {
67 * // the results array will equal ['one','two'] even though
68 * // the second function had a shorter timeout.
69 * });
70 *
71 * // an example using an object instead of an array
72 * async.parallel({
73 * one: function(callback) {
74 * setTimeout(function() {
75 * callback(null, 1);
76 * }, 200);
77 * },
78 * two: function(callback) {
79 * setTimeout(function() {
80 * callback(null, 2);
81 * }, 100);
82 * }
83 * }, function(err, results) {
84 * // results is now equals to: {one: 1, two: 2}
85 * });
86 */
87function parallelLimit(tasks, callback) {
88 (0, _parallel2.default)(_eachOf2.default, tasks, callback);
89}
90module.exports = exports['default'];
Note: See TracBrowser for help on using the repository browser.