AsyncStack Class
Package: @esfx/async-stack
An asynchronous Stack.
Declaration
export declare class AsyncStack<T>
Constructors
constructor(iterable)
Initializes a new instance of the AsyncStack class.
Declaration
constructor(iterable?: Iterable<T | PromiseLike<T>>);
Parameters
Properties
done
Gets a value indicating whether the stack has ended and there are no more items available.
Declaration
get done(): boolean;
Property Value
readable
Gets a value indicating whether items can be read from the stack.
Declaration
get readable(): boolean;
Property Value
size
Gets the number of entries in the stack. When positive, indicates the number of entries available to get. When negative, indicates the number of requests waiting to be fulfilled.
Declaration
get size(): number;
Property Value
writable
Gets a value indicating whether new items can be added to the stack.
Declaration
get writable(): boolean;
Property Value
Methods
doneReading()
Blocks attempts to read from the stack until it is empty. Available items in the stack can still be read until the stack is empty.
Declaration
doneReading(): void;
Returns
doneWriting()
Blocks attempts to write to the stack. Pending requests in the stack can still be resolved until the stack is empty.
Declaration
doneWriting(): void;
Returns
end()
Blocks future attempts to read or write from the stack. Available items in the stack
can still be read until the stack is empty. Pending reads from the stack are rejected
with a CancelError
.
Declaration
end(): void;
Returns
pop(cancelable)
Removes and returns a Promise for the top value of the stack. If the stack is empty, returns a Promise for the next value to be pushed on to the stack.
Declaration
pop(cancelable?: Cancelable): Promise<T>;
Parameters
Returns
push(this)
Adds a value to the top of the stack. If the stack is empty but has a pending pop request, the value will be popped and the request fulfilled.
Declaration
push(this: AsyncStack<void>): void;
Parameters
- this
- AsyncStack<void>
Returns
push(value)
Adds a value to the top of the stack. If the stack is empty but has a pending pop request, the value will be popped and the request fulfilled.
Declaration
push(value: T | PromiseLike<T>): void;
Parameters
Returns