UNPKG

881 BTypeScriptView Raw
1/**
2 * Deferred provides a Promise-like API that exposes methods to resolve and
3 * reject the Promise. It is most useful when converting non-Promise code to use
4 * Promises.
5 *
6 * If you want to export the Promise without exposing access to the resolve and
7 * reject methods, you should export `getPromise` which returns a Promise with
8 * the same semantics excluding those methods.
9 */
10declare class Deferred<Tvalue, Treason> {
11 getPromise(): Promise<any>;
12 resolve(value: Tvalue): void;
13 reject(reason: Treason): void;
14 catch(onReject?: ((error: any) => any) | null): Promise<any>;
15 then(onFulfill?: ((value: any) => any) | null, onReject?: ((error: any) => any) | null): Promise<any>;
16 done(onFulfill?: ((value: any) => any) | null, onReject?: ((error: any) => any) | null): void;
17 isSettled(): boolean;
18}
19
20declare namespace Deferred {}
21
22export = Deferred;
23
\No newline at end of file