'use strict';12Object.defineProperty(exports, "__esModule", {3value: true4});56var _eachOf = require('./eachOf.js');78var _eachOf2 = _interopRequireDefault(_eachOf);910var _withoutIndex = require('./internal/withoutIndex.js');1112var _withoutIndex2 = _interopRequireDefault(_withoutIndex);1314var _wrapAsync = require('./internal/wrapAsync.js');1516var _wrapAsync2 = _interopRequireDefault(_wrapAsync);1718var _awaitify = require('./internal/awaitify.js');1920var _awaitify2 = _interopRequireDefault(_awaitify);2122function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }2324/**25* Applies the function `iteratee` to each item in `coll`, in parallel.26* The `iteratee` is called with an item from the list, and a callback for when27* it has finished. If the `iteratee` passes an error to its `callback`, the28* main `callback` (for the `each` function) is immediately called with the29* error.30*31* Note, that since this function applies `iteratee` to each item in parallel,32* there is no guarantee that the iteratee functions will complete in order.33*34* @name each35* @static36* @memberOf module:Collections37* @method38* @alias forEach39* @category Collection40* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.41* @param {AsyncFunction} iteratee - An async function to apply to42* each item in `coll`. Invoked with (item, callback).43* The array index is not passed to the iteratee.44* If you need the index, use `eachOf`.45* @param {Function} [callback] - A callback which is called when all46* `iteratee` functions have finished, or an error occurs. Invoked with (err).47* @returns {Promise} a promise, if a callback is omitted48* @example49*50* // dir1 is a directory that contains file1.txt, file2.txt51* // dir2 is a directory that contains file3.txt, file4.txt52* // dir3 is a directory that contains file5.txt53* // dir4 does not exist54*55* const fileList = [ 'dir1/file2.txt', 'dir2/file3.txt', 'dir/file5.txt'];56* const withMissingFileList = ['dir1/file1.txt', 'dir4/file2.txt'];57*58* // asynchronous function that deletes a file59* const deleteFile = function(file, callback) {60* fs.unlink(file, callback);61* };62*63* // Using callbacks64* async.each(fileList, deleteFile, function(err) {65* if( err ) {66* console.log(err);67* } else {68* console.log('All files have been deleted successfully');69* }70* });71*72* // Error Handling73* async.each(withMissingFileList, deleteFile, function(err){74* console.log(err);75* // [ Error: ENOENT: no such file or directory ]76* // since dir4/file2.txt does not exist77* // dir1/file1.txt could have been deleted78* });79*80* // Using Promises81* async.each(fileList, deleteFile)82* .then( () => {83* console.log('All files have been deleted successfully');84* }).catch( err => {85* console.log(err);86* });87*88* // Error Handling89* async.each(fileList, deleteFile)90* .then( () => {91* console.log('All files have been deleted successfully');92* }).catch( err => {93* console.log(err);94* // [ Error: ENOENT: no such file or directory ]95* // since dir4/file2.txt does not exist96* // dir1/file1.txt could have been deleted97* });98*99* // Using async/await100* async () => {101* try {102* await async.each(files, deleteFile);103* }104* catch (err) {105* console.log(err);106* }107* }108*109* // Error Handling110* async () => {111* try {112* await async.each(withMissingFileList, deleteFile);113* }114* catch (err) {115* console.log(err);116* // [ Error: ENOENT: no such file or directory ]117* // since dir4/file2.txt does not exist118* // dir1/file1.txt could have been deleted119* }120* }121*122*/123function eachLimit(coll, iteratee, callback) {124return (0, _eachOf2.default)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);125}126127exports.default = (0, _awaitify2.default)(eachLimit, 3);128module.exports = exports['default'];129130