export interface SafePromise { (): Promise; checkPending(): boolean; } /** * Saving a long-lived reference to a promise that can reject can be unsafe, * since rejecting the promise causes an unhandled rejection error (even if the * rejection is handled everywhere promise result is expected). * * To avoid that, we add both resolution and rejection handlers to the promise. * That way, the saved promise never rejects. A callback is provided as return * value to build a *new* promise, that resolves and rejects along with * the original promise. * @param promise Promise to wrap, which possibly rejects * @returns Callback to build a new promise, which resolves and rejects along * with the original promise */ export declare function makeSafePromise(promise: Promise): SafePromise; export type PromiseWithResolvers = { promise: Promise; resolve: (value: T | PromiseLike) => void; reject: (reason: any) => void; isResolved: () => boolean; isRejected: () => boolean; }; /** * Creates a new promise with resolvers. * * Based on: * - https://github.com/tc39/proposal-promise-with-resolvers/blob/main/polyfills.js */ export declare const promiseWithResolvers: () => PromiseWithResolvers;