1 | import "./asyncIterable";
|
2 |
|
3 |
|
4 |
|
5 | export declare class AsyncBoundedQueue<T> {
|
6 | private _queue;
|
7 | private _state;
|
8 | |
9 |
|
10 |
|
11 |
|
12 |
|
13 | constructor(iterable?: Iterable<T | PromiseLike<T>>);
|
14 | /**
|
15 | * Gets the number of entries in the queue.
|
16 | * When positive, indicates the number of entries available to get.
|
17 | * When negative, indicates the number of requests waiting to be fulfilled.
|
18 | */
|
19 | get size(): number;
|
20 | /**
|
21 | * Adds a value to the end of the queue. If the queue is empty but has a pending
|
22 | * dequeue request, the value will be dequeued and the request fulfilled.
|
23 | *
|
24 | * @param value A value or promise to add to the queue.
|
25 | */
|
26 | put(value: T | PromiseLike<T>): void;
|
27 | /**
|
28 | * Indicates the queue is done adding and that no more items will be added to the queue.
|
29 | */
|
30 | end(): void;
|
31 | /**
|
32 | * Removes and returns a Promise for the first value in the queue. If the queue has
|
33 | * ended, returns a Promise for `undefined`. If the queue is empty, returns a Promise
|
34 | * for the next value to be added to the queue.
|
35 | */
|
36 | get(): Promise<T | undefined>;
|
37 | /**
|
38 | * Consumes all items in the queue until the queue ends.
|
39 | */
|
40 | drain(): AsyncIterableIterator<T>;
|
41 | private _dequeue;
|
42 | }
|