UNPKG

1.39 kBTypeScriptView Raw
1/*! *****************************************************************************
2Copyright (c) Microsoft Corporation.
3Licensed under the Apache License, Version 2.0.
4
5See LICENSE file in the project root for details.
6***************************************************************************** */
7/**
8 * An asynchronous Stack.
9 */
10export declare class AsyncStack<T> {
11 private _available;
12 private _pending;
13 /**
14 * Initializes a new instance of the AsyncStack class.
15 *
16 * @param iterable An optional iterable of values or promises.
17 */
18 constructor(iterable?: Iterable<T | PromiseLike<T>>);
19 /**
20 * Gets the number of entries in the stack.
21 * When positive, indicates the number of entries available to get.
22 * When negative, indicates the number of requests waiting to be fulfilled.
23 */
24 get size(): number;
25 /**
26 * Adds a value to the top of the stack. If the stack is empty but has a pending
27 * pop request, the value will be popped and the request fulfilled.
28 *
29 * @param value A value or promise to add to the stack.
30 */
31 push(value: T | PromiseLike<T>): void;
32 /**
33 * Removes and returns a Promise for the top value of the stack. If the stack is empty,
34 * returns a Promise for the next value to be pushed on to the stack.
35 */
36 pop(): Promise<T>;
37}