UNPKG

1.45 kBTypeScriptView Raw
1/**
2 * Thenable class that behaves like a Promise and follows it's interface
3 * but is not async internally
4 */
5declare class SyncPromise<T> implements PromiseLike<T> {
6 private _state;
7 private _handlers;
8 private _value;
9 constructor(executor: (resolve: (value?: T | PromiseLike<T> | null) => void, reject: (reason?: any) => void) => void);
10 /** JSDoc */
11 static resolve<T>(value: T | PromiseLike<T>): PromiseLike<T>;
12 /** JSDoc */
13 static reject<T = never>(reason?: any): PromiseLike<T>;
14 /** JSDoc */
15 static all<U = any>(collection: Array<U | PromiseLike<U>>): PromiseLike<U[]>;
16 /** JSDoc */
17 then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
18 /** JSDoc */
19 catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): PromiseLike<T | TResult>;
20 /** JSDoc */
21 finally<TResult>(onfinally?: (() => void) | null): PromiseLike<TResult>;
22 /** JSDoc */
23 toString(): string;
24 /** JSDoc */
25 private readonly _resolve;
26 /** JSDoc */
27 private readonly _reject;
28 /** JSDoc */
29 private readonly _setResult;
30 /** JSDoc */
31 private readonly _attachHandler;
32 /** JSDoc */
33 private readonly _executeHandlers;
34}
35export { SyncPromise };
36//# sourceMappingURL=syncpromise.d.ts.map
\No newline at end of file