Add Q.Promise.all, the member function (#18308)

This commit is contained in:
Eric Wieser
2017-07-27 14:49:34 +01:00
committed by Andy
parent 936e0b0e12
commit 4331ee51ba
2 changed files with 24 additions and 0 deletions

22
types/q/v0/index.d.ts vendored
View File

@@ -166,6 +166,28 @@ declare namespace Q {
* - { state: "rejected", reason: <rejection reason> }
*/
inspect(): PromiseState<T>;
all<A, B, C, D, E, F>(this: Promise<[IWhenable<A>, IWhenable<B>, IWhenable<C>, IWhenable<D>, IWhenable<E>, IWhenable<F>]>): Promise<[A, B, C, D, E, F]>;
/**
* Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
*/
all<A, B, C, D, E>(this: Promise<[IWhenable<A>, IWhenable<B>, IWhenable<C>, IWhenable<D>, IWhenable<E>]>): Promise<[A, B, C, D, E]>;
/**
* Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
*/
all<A, B, C, D>(this: Promise<[IWhenable<A>, IWhenable<B>, IWhenable<C>, IWhenable<D>]>): Promise<[A, B, C, D]>;
/**
* Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
*/
all<A, B, C>(this: Promise<[IWhenable<A>, IWhenable<B>, IWhenable<C>]>): Promise<[A, B, C]>;
/**
* Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
*/
all<A, B>(this: Promise<[IWhenable<A>, IWhenable<B>]>): Promise<[A, B]>;
/**
* Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
*/
all<T>(this: Promise<IWhenable<T>[]>): Promise<T[]>;
}
interface PromiseState<T> {

View File

@@ -220,7 +220,9 @@ var y2 = Q().then(() => {
return <[typeof s, typeof n]>[s, n];
});
var p1: Q.Promise<[string, number]> = y1.all();
var p2: Q.Promise<[string, number]> = y1.then(val => Q.all(val));
var p3: Q.Promise<[string, number]> = Q.all(y1);
var p4: Q.Promise<[string, number]> = y2.all();
var p5: Q.Promise<[string, number]> = y2.then(val => Q.all(val));
var p6: Q.Promise<[string, number]> = Q.all(y2);