summaryrefslogtreecommitdiff
path: root/lib/queue.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/queue.js')
-rw-r--r--lib/queue.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/queue.js b/lib/queue.js
index 00b90ce..0fa7b96 100644
--- a/lib/queue.js
+++ b/lib/queue.js
@@ -3,7 +3,7 @@ import wrapAsync from './internal/wrapAsync';
/**
* A queue of tasks for the worker function to complete.
- * @typedef {Object} QueueObject
+ * @typedef {Iterable} QueueObject
* @memberOf module:ControlFlow
* @property {Function} length - a function returning the number of items
* waiting to be processed. Invoke with `queue.length()`.
@@ -53,6 +53,18 @@ import wrapAsync from './internal/wrapAsync';
* @property {Function} kill - a function that removes the `drain` callback and
* empties remaining tasks from the queue forcing it to go idle. No more tasks
* should be pushed to the queue after calling this function. Invoke with `queue.kill()`.
+ *
+ * @example
+ * const q = aync.queue(worker, 2)
+ * q.push(item1)
+ * q.push(item2)
+ * q.push(item3)
+ * // queues are iterable, spread into an array to inspect
+ * const items = [...q] // [item1, item2, item3]
+ * // or use for of
+ * for (let item of q) {
+ * console.log(item)
+ * }
*/
/**