Skip to content

BlockingStack

Defined in: packages/data/src/stack/blocking-stack.ts:23

A LIFO stack that holds at most capacity items, and whose waitPush suspends until room frees up instead of throwing.

push still throws — this type adds a way to wait, it does not change the way to fail.

T extends DefinedValue

The type of elements in the stack.

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

Defined in: packages/data/src/stack/blocking-stack.ts:30

Iterable<T, any, any> | undefined

BlockingStackOptions<T>

BlockingStack<T>

readonly capacity: number

Defined in: packages/data/src/stack/blocking-stack.ts:28

The maximum number of elements the collection can hold.

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

IWaitableStack.capacity

[iterator](): Iterator<T>

Defined in: packages/data/src/stack/blocking-stack.ts:44

Iterator<T>

IWaitableStack.[iterator]


clear(): void

Defined in: packages/data/src/stack/blocking-stack.ts:48

Removes all elements from the collection.

void

IWaitableStack.clear


count(): number

Defined in: packages/data/src/stack/blocking-stack.ts:55

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

IWaitableStack.count


pop(): T | undefined

Defined in: packages/data/src/stack/blocking-stack.ts:92

Removes and returns the item at the top of the stack.

T | undefined

The item at the top of the stack, or undefined if the stack is empty.

IWaitableStack.pop


push(item): void

Defined in: packages/data/src/stack/blocking-stack.ts:59

Adds an item to the top of the stack.

T

The item to add to the stack.

void

IWaitableStack.push


pushAll(items): void

Defined in: packages/data/src/stack/blocking-stack.ts:64

Adds every item to the top of the stack, in array order, so the last one is the first to be popped.

readonly T[]

The items to add to the stack.

void

IWaitableStack.pushAll


top(): T | undefined

Defined in: packages/data/src/stack/blocking-stack.ts:102

Returns the item at the top of the stack without removing it.

T | undefined

The item at the top of the stack, or undefined if the stack is empty.

IWaitableStack.top


waitPush(item, signal?): Promise<void>

Defined in: packages/data/src/stack/blocking-stack.ts:73

Same as push, but waits for capacity if the operation would exceed it.

T

AbortSignal | null

Optional abort signal to cancel the operation.

Promise<void>

IStack.push

IWaitableStack.waitPush


waitPushAll(items, signal?): Promise<void>

Defined in: packages/data/src/stack/blocking-stack.ts:78

Same as pushAll, but waits for capacity if the operation would exceed it. The whole batch lands at once, never interleaved with another waiter’s.

Iterable<T>

AbortSignal | null

Optional abort signal to cancel the operation.

Promise<void>

IStack.pushAll

IWaitableStack.waitPushAll