diff options
Diffstat (limited to 'lib/cargo.js')
-rw-r--r-- | lib/cargo.js | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/cargo.js b/lib/cargo.js index 01329e7..d86cb67 100644 --- a/lib/cargo.js +++ b/lib/cargo.js @@ -2,17 +2,18 @@ import queue from './internal/queue'; /** * A cargo of tasks for the worker function to complete. Cargo inherits all of - * the same methods and event callbacks as {@link async.queue}. - * @typedef {Object} cargo + * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}. + * @typedef {Object} CargoObject + * @memberOf module:ControlFlow * @property {Function} length - A function returning the number of items - * waiting to be processed. Invoke with (). + * waiting to be processed. Invoke like `cargo.length()`. * @property {number} payload - An `integer` for determining how many tasks * should be process per round. This property can be changed after a `cargo` is * created to alter the payload on-the-fly. * @property {Function} push - Adds `task` to the `queue`. The callback is * called once the `worker` has finished processing the task. Instead of a * single task, an array of `tasks` can be submitted. The respective callback is - * used for every task in the list. Invoke with (task, [callback]). + * used for every task in the list. Invoke like `cargo.push(task, [callback])`. * @property {Function} saturated - A callback that is called when the * `queue.length()` hits the concurrency and further tasks will be queued. * @property {Function} empty - A callback that is called when the last item @@ -20,13 +21,13 @@ import queue from './internal/queue'; * @property {Function} drain - A callback that is called when the last item * from the `queue` has returned from the `worker`. * @property {Function} idle - a function returning false if there are items - * waiting or being processed, or true if not. Invoke with (). + * waiting or being processed, or true if not. Invoke like `cargo.idle()`. * @property {Function} pause - a function that pauses the processing of tasks - * until `resume()` is called. Invoke with (). + * until `resume()` is called. Invoke like `cargo.pause()`. * @property {Function} resume - a function that resumes the processing of - * queued tasks when the queue is paused. Invoke with (). + * queued tasks when the queue is paused. Invoke like `cargo.resume()`. * @property {Function} kill - a function that removes the `drain` callback and - * empties remaining tasks from the queue forcing it to go idle. Invoke with (). + * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`. */ /** @@ -37,22 +38,23 @@ import queue from './internal/queue'; * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966) * for how `cargo` and `queue` work. * - * While [queue](#queue) passes only one task to one of a group of workers + * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers * at a time, cargo passes an array of tasks to a single worker, repeating * when the worker is finished. * * @name cargo * @static - * @memberOf async - * @see async.queue + * @memberOf module:ControlFlow + * @method + * @see [async.queue]{@link module:ControlFlow.queue} * @category Control Flow * @param {Function} worker - An asynchronous function for processing an array * of queued tasks, which must call its `callback(err)` argument when finished, - * with an optional `err` argument. Invoked with (tasks, callback). + * with an optional `err` argument. Invoked with `(tasks, callback)`. * @param {number} [payload=Infinity] - An optional `integer` for determining * how many tasks should be processed per round; if omitted, the default is * unlimited. - * @returns {cargo} A cargo object to manage the tasks. Callbacks can + * @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can * attached as certain properties to listen for specific events during the * lifecycle of the cargo and inner queue. * @example |