From eccdff71683c41728991895c3fd2d436892a5216 Mon Sep 17 00:00:00 2001 From: Alexander Early Date: Sun, 8 Jul 2018 21:54:58 -0700 Subject: [PATCH] docs --- lib/queue.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/queue.js b/lib/queue.js index 00b90cee9..a29dca9f6 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,21 @@ 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 + * + * // queues are iterable + * + * const q = aync.queue(worker, 2) + * q.push(item1) + * q.push(item2) + * q.push(item3) + * // spread into an array to inspect + * const items = [...q] // [item1, item2, item3] + * // or use for of + * for (let item of q) { + * console.log(item) + * } */ /**