# Class AsyncQueue<T>

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>

#####
Index

### Constructors

constructor

### Accessors

isDone

### Methods

[asyncIterator]
add
addMany
done
reject

##
Constructors

### constructor

- new AsyncQueue<T>(): AsyncQueue<T>

- #### Type Parameters

  - T

  #### Returns AsyncQueue<T>

##
Accessors

### isDone

- get isDone(): boolean

- Indicates that no more items are going to be added to the queue.

  #### Returns boolean

##
Methods

### [asyncIterator]

- [asyncIterator](): AsyncIterator<T, any, any>

- An iterator that returns the items in the queue.

  #### Returns AsyncIterator<T, any, any>

  Implementation of AsyncIterable.[asyncIterator]

### add

- add(item): void

- 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

### addMany

- addMany(items): 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

### done

- done(): 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

### reject

- reject(reason): 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