prex-es5
Version:
Async coordination primitives and extensions on top of ES6 Promises
38 lines (36 loc) • 1.36 kB
TypeScript
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Licensed under the Apache License, Version 2.0.
See LICENSE file in the project root for details.
***************************************************************************** */
/**
* An asynchronous Stack.
*/
export declare class AsyncStack<T> {
private _available;
private _pending;
/**
* Initializes a new instance of the AsyncStack class.
*
* @param iterable An optional iterable of values or promises.
*/
constructor(iterable?: Iterable<T | PromiseLike<T>>);
/**
* 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.
*/
readonly size: number;
/**
* 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.
*
* @param value A value or promise to add to the stack.
*/
push(value: T | PromiseLike<T>): void;
/**
* 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.
*/
pop(): Promise<T>;
}