mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-17 22:44:18 +08:00
Added progress handlers to Q.when
This commit is contained in:
@@ -86,4 +86,7 @@ Q.all(promiseArray).then(nums => nums.map(num => num.toPrecision(2)).join(','));
|
||||
|
||||
Q.all<number>(myNums).then(nums => nums.map(Math.round));
|
||||
|
||||
Q.fbind((dateString) => new Date(dateString), "11/11/1991")().then(d => d.toLocaleDateString());
|
||||
Q.fbind((dateString) => new Date(dateString), "11/11/1991")().then(d => d.toLocaleDateString());
|
||||
|
||||
Q.when(8, num => num + "!");
|
||||
Q.when(Q(8), num => num + "!").then(str => str.split(','));
|
||||
12
q/Q.d.ts
vendored
12
q/Q.d.ts
vendored
@@ -62,14 +62,18 @@ declare module Q {
|
||||
valueOf(): any;
|
||||
}
|
||||
|
||||
// if no fulfill, reject, or progress provided, returned promise will be of same type
|
||||
export function when<T>(value: T): Promise<T>;
|
||||
export function when<T>(value: IPromise<T>): Promise<T>;
|
||||
|
||||
// If a non-promise value is provided, it will not reject or progress
|
||||
export function when<T, U>(value: T, onFulfilled: (val: T) => U): Promise<U>;
|
||||
export function when<T, U>(value: T, onFulfilled: (val: T) => IPromise<U>): Promise<U>;
|
||||
export function when<T, U>(value: IPromise<T>, onFulfilled: (val: T) => U, onRejected?: (reason) => U): Promise<U>;
|
||||
export function when<T, U>(value: IPromise<T>, onFulfilled: (val: T) => IPromise<U>, onRejected?: (reason) => U): Promise<U>;
|
||||
export function when<T, U>(value: IPromise<T>, onFulfilled: (val: T) => U, onRejected?: (reason) => IPromise<U>): Promise<U>;
|
||||
export function when<T, U>(value: IPromise<T>, onFulfilled: (val: T) => IPromise<U>, onRejected?: (reason) => IPromise<U>): Promise<U>;
|
||||
|
||||
export function when<T, U>(value: IPromise<T>, onFulfilled: (val: T) => U, onRejected?: (reason) => U, onProgress?: (progress) => any): Promise<U>;
|
||||
export function when<T, U>(value: IPromise<T>, onFulfilled: (val: T) => IPromise<U>, onRejected?: (reason) => U, onProgress?: (progress) => any): Promise<U>;
|
||||
export function when<T, U>(value: IPromise<T>, onFulfilled: (val: T) => U, onRejected?: (reason) => IPromise<U>, onProgress?: (progress) => any): Promise<U>;
|
||||
export function when<T, U>(value: IPromise<T>, onFulfilled: (val: T) => IPromise<U>, onRejected?: (reason) => IPromise<U>, onProgress?: (progress) => any): Promise<U>;
|
||||
|
||||
//export function try(method: Function, ...args: any[]): Promise<any>; // <- This is broken currently - not sure how to fix.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user