Dequeue an element, waiting for data to be available if necessary.
A promise which is fulfilled when an element (as queued by queue()) becomes available. If multiple dequeus() are issued sequentially, it is implementation-defined whether they are fulfilled in the same order or not. However, the data is still retrieved in FIFO fashion, meaning the first fulfilled promise gets the first element, the second fulfilled the second one and so forth.
Dequeue an element if available or throw an exception otherwise.
The first element of the queue.
Queue an element immediately.
Queue all elements of an iterable, e.g. an array or a generator function.
Queue all elements of an asynchronous iterable, e.g. an asynchronous generator functions.
Return the current size at the moment of the call.
Even though code like
if (queue.size() >= 1) {
const element = queue.poll();
}
is technically not wrong (due to JS' execution model), users are advised to avoid this pattern. Instead, users are encouraged to
Generated using TypeDoc
Asynchronous FIFO queue with a Promise-driven dequeue operation.
All element values are allowed, especially falsy ones, e.g. false, 0, undefined, null, [], {} are all valid elements which can be queued and dequeued.
The {@link AsyncIterable} interface iterates the queue's (future) contents ad infinitum. Users are advised to signal the end by manual insertion of a special value (a so-called poison pill):