Skip to content

BoundedQueue

Defined in: packages/data/src/queue/bounded-queue.ts:30

A FIFO queue that holds at most capacity items and throws once full.

A fixed-size queue needs no class of its own — hand it a storage that already knows how big it is and the capacity follows:

new BoundedQueue(undefined, {
storage: new RingVector(undefined, { capacity: 1024 }),
});

T extends DefinedValue

The type of elements in the queue.

new BoundedQueue<T>(iterable, options): BoundedQueue<T>

Defined in: packages/data/src/queue/bounded-queue.ts:36

Iterable<T, any, any> | undefined

BoundedQueueOptions<T>

BoundedQueue<T>

readonly capacity: number

Defined in: packages/data/src/queue/bounded-queue.ts:34

The maximum number of elements the collection can hold.

Note: Infinity is not a legal value here — an unbounded type omits this mixin.

IBounded.capacity

[iterator](): Iterator<T>

Defined in: packages/data/src/queue/bounded-queue.ts:46

Iterator<T>

IQueue.[iterator]


clear(): void

Defined in: packages/data/src/queue/bounded-queue.ts:50

Removes all elements from the collection.

void

IQueue.clear


count(): number

Defined in: packages/data/src/queue/bounded-queue.ts:54

The number of elements in the collection.

A method, not a getter: its async counterpart needs a round trip to the backing store, and a member must have the same shape in both.

number

IQueue.count


dequeue(): T | undefined

Defined in: packages/data/src/queue/bounded-queue.ts:85

Removes and returns the item at the front of the queue.

T | undefined

The item at the front of the queue, or undefined if the queue is empty.

IQueue.dequeue


enqueue(item): void

Defined in: packages/data/src/queue/bounded-queue.ts:65

Same as IQueue.enqueue, but throws once the queue is full.

T

void

If the operation would exceed the queue’s capacity.

IQueue.enqueue

IQueue.enqueue


enqueueAll(items): void

Defined in: packages/data/src/queue/bounded-queue.ts:79

Same as IQueue.enqueueAll, but throws once the queue is full. Nothing is added when it throws — the check is made against the whole batch.

readonly T[]

void

If the operation would exceed the queue’s capacity.

IQueue.enqueueAll

IQueue.enqueueAll


front(): T | undefined

Defined in: packages/data/src/queue/bounded-queue.ts:89

Returns the item at the front of the queue without removing it.

T | undefined

The item at the front of the queue, or undefined if the queue is empty.

IQueue.front