- Class: AsyncQueue
- Class: AsyncBoundedQueue
- Class: AsyncStack
- Function: delay(msec, value?)
- Function: delay(token, msec, value?)
An asynchronous queue.
export declare class AsyncQueue<T> {
constructor(iterable?: Iterable<T | PromiseLike<T>>);
put(value: T | PromiseLike<T>): void;
get(): Promise<T>;
}
Initializes a new instance of the AsyncQueue class.
iterable
<Iterable> An optional iterable of values or promises.
Gets the number of entries in the queue. When positive, indicates the number of entries available to get. When negative, indicates the number of requests waiting to be fulfilled.
Adds a value to the end of the queue. If the queue is empty but has a pending dequeue request, the value will be dequeued and the request fulfilled.
value
<any
> A value or promise to add to the queue.
Removes and returns a Promise for the first value in the queue. If the queue is empty, returns a Promise for the next value to be added to the queue.
- Returns: <Promise>
An asynchronous queue with a bounded endpoint.
export declare class AsyncBoundedQueue<T> {
constructor(iterable?: Iterable<T | PromiseLike<T>>);
put(value: T | PromiseLike<T>): void;
end(): void;
get(): Promise<T | undefined>;
drain(): AsyncIterableIterator<T>;
}
Initializes a new instance of the AsyncBoundedQueue class.
iterable
<Iterable> An optional iterable of values or promises.
Gets the number of entries in the queue. When positive, indicates the number of entries available to get. When negative, indicates the number of requests waiting to be fulfilled.
Adds a value to the end of the queue. If the queue is empty but has a pending dequeue request, the value will be dequeued and the request fulfilled.
value
<any
> A value or promise to add to the queue.
Indicates the queue is done adding and that no more items will be added to the queue.
Removes and returns a Promise for the first value in the queue. If the queue has
ended, returns a Promise for undefined
. If the queue is empty, returns a Promise
for the next value to be added to the queue.
- Returns: <Promise>
Consumes all items in the queue until the queue ends.
An asynchronous stack.
export declare class AsyncStack<T> {
constructor(iterable?: Iterable<T | PromiseLike<T>>);
push(value: T | PromiseLike<T>): void;
pop(): Promise<T>;
}
Initializes a new instance of the AsyncStack class.
iterable
<Iterable> An optional iterable of values or promises.
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.
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.
value
<any
> A value or promise to add to the stack.
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.
- Returns: <Promise>
Waits the specified number of milliseconds before resolving with the provided value.
msec
<Number> The number of milliseconds to delay.value
<any
> The resolution value for the promise.- Returns: <Promise>
export declare function delay(msec: number): Promise<void>;
export declare function delay<T>(msec: number, value?: T | PromiseLike<T>): Promise<T>;
Waits the specified number of milliseconds before resolving with the provided value.
token
<CancellationToken> A CancellationToken.msec
<Number> The number of milliseconds to delay.value
<any
> The resolution value for the promise.- Returns: <Promise>
export declare function delay(token: CancellationToken, msec: number): Promise<void>;
export declare function delay<T>(token: CancellationToken, msec: number, value?: T | PromiseLike<T>): Promise<T>;