Add signature for promise.tap(onFulfilled)

This commit is contained in:
Florent Chiron
2015-05-01 03:30:41 +02:00
parent 1b9a6247ff
commit c969d6275c
2 changed files with 15 additions and 0 deletions
+9
View File
@@ -64,6 +64,15 @@ Q.allResolved([])
})
});
Q(42)
.tap(() => "hello")
.tap(x => {
console.log(x);
})
.then(x => {
console.log("42 == " + x);
});
declare var arrayPromise: Q.IPromise<number[]>;
declare var stringPromise: Q.IPromise<string>;
declare function returnsNumPromise(text: string): Q.Promise<number>;
Vendored
+6
View File
@@ -122,6 +122,12 @@ declare module Q {
* A sugar method, equivalent to promise.then(function () { throw reason; }).
*/
thenReject(reason: any): Promise<T>;
/**
* Attaches a handler that will observe the value of the promise when it becomes fulfilled, returning a promise for that same value, perhaps deferred but not replaced by the promise returned by the onFulfilled handler.
*/
tap(onFulfilled: (value: T) => any): Promise<T>;
timeout(ms: number, message?: string): Promise<T>;
/**
* Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed.