This class is a queue that works asynchronously:

  • Enqueuing via .put() is manual and synchronous (non-blocking) and can be done multiple times.
    • Rationale: Needed so that we can turn a callback-based (push) API into an asynchronous-iteration-based (pull) API.
  • Dequeuing is done via async iteration, which invokes method .next(). This operation blocks asynchronously until data is enqueued.

Type Parameters

  • T

Constructors

Methods

  • Dequeuing is done via async iteration. This method blocks asynchronously if the queue is empty.

    Returns Promise<IteratorResult<T, any>>

  • Enqueuing. This method is non-blocking. It can be called as often as you want and will buffer if more is enqeued than dequeued.

    Parameters

    • value: T

    Returns this