source: trip-planner-front/node_modules/async/each.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: 2.8 KB
Line 
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = eachLimit;
7
8var _eachOf = require('./eachOf');
9
10var _eachOf2 = _interopRequireDefault(_eachOf);
11
12var _withoutIndex = require('./internal/withoutIndex');
13
14var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
15
16var _wrapAsync = require('./internal/wrapAsync');
17
18var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
19
20function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
22/**
23 * Applies the function `iteratee` to each item in `coll`, in parallel.
24 * The `iteratee` is called with an item from the list, and a callback for when
25 * it has finished. If the `iteratee` passes an error to its `callback`, the
26 * main `callback` (for the `each` function) is immediately called with the
27 * error.
28 *
29 * Note, that since this function applies `iteratee` to each item in parallel,
30 * there is no guarantee that the iteratee functions will complete in order.
31 *
32 * @name each
33 * @static
34 * @memberOf module:Collections
35 * @method
36 * @alias forEach
37 * @category Collection
38 * @param {Array|Iterable|Object} coll - A collection to iterate over.
39 * @param {AsyncFunction} iteratee - An async function to apply to
40 * each item in `coll`. Invoked with (item, callback).
41 * The array index is not passed to the iteratee.
42 * If you need the index, use `eachOf`.
43 * @param {Function} [callback] - A callback which is called when all
44 * `iteratee` functions have finished, or an error occurs. Invoked with (err).
45 * @example
46 *
47 * // assuming openFiles is an array of file names and saveFile is a function
48 * // to save the modified contents of that file:
49 *
50 * async.each(openFiles, saveFile, function(err){
51 * // if any of the saves produced an error, err would equal that error
52 * });
53 *
54 * // assuming openFiles is an array of file names
55 * async.each(openFiles, function(file, callback) {
56 *
57 * // Perform operation on file here.
58 * console.log('Processing file ' + file);
59 *
60 * if( file.length > 32 ) {
61 * console.log('This file name is too long');
62 * callback('File name too long');
63 * } else {
64 * // Do work to process file here
65 * console.log('File processed');
66 * callback();
67 * }
68 * }, function(err) {
69 * // if any of the file processing produced an error, err would equal that error
70 * if( err ) {
71 * // One of the iterations produced an error.
72 * // All processing will now stop.
73 * console.log('A file failed to process');
74 * } else {
75 * console.log('All files have been processed successfully');
76 * }
77 * });
78 */
79function eachLimit(coll, iteratee, callback) {
80 (0, _eachOf2.default)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
81}
82module.exports = exports['default'];
Note: See TracBrowser for help on using the repository browser.