UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

25 lines (24 loc) 884 B
import type { PromiseExecutor } from "../types"; /** * LazyPromise, execute async operation when user await it. * * @author Theo Sun * * @category Async * @since 5.18.0 */ export declare class LazyPromise<T = any> implements Promise<T> { private _executor; private _promise; /** * LazyPromise, execute async operation when user await it. * * @param executor Promise executor */ constructor(executor: PromiseExecutor<T>); [Symbol.toStringTag]: string; private _getPromise; then<TResult1 = T, TResult2 = never>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; catch<TResult = never>(onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>; finally(onfinally?: () => void): Promise<T>; }