Add definition with test for when.settle, add a test for when.all

This commit is contained in:
Michael Nahkies
2015-06-10 16:38:16 +12:00
parent 52dc8fc393
commit eb5f7c2d2a
2 changed files with 36 additions and 0 deletions
+26
View File
@@ -101,6 +101,32 @@ declare module When {
*/
function all<T>(promisesOrValues: any[]): Promise<T>;
/**
* Describes the status of a promise.
* state may be one of:
* "fulfilled" - the promise has resolved
* "pending" - the promise is still pending to resolve/reject
* "rejected" - the promise has rejected
*/
interface Descriptor<T> {
state: string;
value?: T;
reason?: any;
}
/**
* Returns a promise for an array containing the same number of elements as the input array.
* Each element is a descriptor object describing of the outcome of the corresponding element in the input.
* The returned promise will only reject if array itself is a rejected promise. Otherwise,
* it will always fulfill with an array of descriptors. This is in contrast to when.all,
* which will reject if any element of array rejects.
* @memberOf when
*
* @param promisesOrValues array of anything, may contain a mix
* of {@link Promise}s and values
*/
function settle<T>(promisesOrValues: any[]): Promise<Descriptor<T>[]>;
/**
* Creates a {promise, resolver} pair, either or both of which
* may be given out safely to consumers.