/** @module async */ /** */ import { canceledError } from './makeCancelable'; export { canceledError }; /** * * Creates a promise that can be canceled after starting. Canceling the promise does not stop it from executing but will * cause it to reject with the value `{ isCanceled: true }` once it finishes, regardless of outcome. * * ```ts * * const promise = new CancelablePromise(res => setTimeout(res, 3000, 'I finished!')) * * // Stop the cancelable promise from resolving * cancelablePromise.cancel() * * cancelablePromise * .then(result => console.log('Cancelable', result)) // Never fires, the promise will not resolve after being cancelled * .catch(err => console.log('Cancelable', err)) // Resolves after 3000ms with the value `{ isCanceled: true }` * ``` * */ export declare class CancelablePromise extends Promise { private canceled; protected promise: Promise; get [Symbol.toStringTag](): string; get hasCanceled(): boolean; constructor(executor: (resolve: (value: T) => void, reject: (err?: any) => void) => void); cancel(): void; then(onfulfilled: (value: T) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; catch(onrejected: (reason: any) => TResult | PromiseLike): Promise; finally(onfinally: () => void): Promise; } export default CancelablePromise;