UNPKG

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