'use strict';12Object.defineProperty(exports, "__esModule", {3value: true4});5exports.default = cargo;67var _queue = require('./internal/queue.js');89var _queue2 = _interopRequireDefault(_queue);1011function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }1213/**14* Creates a `cargo` object with the specified payload. Tasks added to the15* cargo will be processed altogether (up to the `payload` limit). If the16* `worker` is in progress, the task is queued until it becomes available. Once17* the `worker` has completed some tasks, each callback of those tasks is18* called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)19* for how `cargo` and `queue` work.20*21* While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers22* at a time, cargo passes an array of tasks to a single worker, repeating23* when the worker is finished.24*25* @name cargo26* @static27* @memberOf module:ControlFlow28* @method29* @see [async.queue]{@link module:ControlFlow.queue}30* @category Control Flow31* @param {AsyncFunction} worker - An asynchronous function for processing an array32* of queued tasks. Invoked with `(tasks, callback)`.33* @param {number} [payload=Infinity] - An optional `integer` for determining34* how many tasks should be processed per round; if omitted, the default is35* unlimited.36* @returns {module:ControlFlow.QueueObject} A cargo object to manage the tasks. Callbacks can37* attached as certain properties to listen for specific events during the38* lifecycle of the cargo and inner queue.39* @example40*41* // create a cargo object with payload 242* var cargo = async.cargo(function(tasks, callback) {43* for (var i=0; i<tasks.length; i++) {44* console.log('hello ' + tasks[i].name);45* }46* callback();47* }, 2);48*49* // add some items50* cargo.push({name: 'foo'}, function(err) {51* console.log('finished processing foo');52* });53* cargo.push({name: 'bar'}, function(err) {54* console.log('finished processing bar');55* });56* await cargo.push({name: 'baz'});57* console.log('finished processing baz');58*/59function cargo(worker, payload) {60return (0, _queue2.default)(worker, 1, payload);61}62module.exports = exports['default'];6364