An asynchronous producer/consumer queue. Allows one or more producers to populate the queue while one or more consumers are iterating over the queue, completely independently of one another.

Type Parameters

  • T

Implements

  • AsyncIterable<T>

Constructors

Accessors

Methods

Constructors

Accessors

  • get isDone(): boolean
  • Indicates that no more items are going to be added to the queue.

    Returns boolean

Methods

  • An iterator that returns the items in the queue.

    Returns AsyncIterator<T, any, any>

  • Adds an item to the queue. Once done is called, no more items can be added.

    Parameters

    • item: T | PromiseLike<T>

      The item (or promise of the item) to add to the queue.

    Returns void

  • Adds items to the queue. Once done is called, no more items can be added.

    Parameters

    • items: Iterable<T | PromiseLike<T>, any, any>

      The items (or item promises) to add to the queue.

    Returns void

  • Indicates that no more items will be added to the queue. This will cause any iterators that are iterating over the queue to eventually reach the end of iteration.

    Returns void

  • Signals an error to consumers. No more items can be added to the queue after this method is called. Consumers iterating over the queue will still be able to iterate over all items that were added up until the error was signaled, at which point the iteration will abort with the given error.

    Parameters

    • reason: unknown

      The reason for rejection (e.g. error, cancellation, etc.).

    Returns void