vulpix
Version:
CSP-like channels library
19 lines (18 loc) • 735 B
TypeScript
import { type Callback } from '../../auxiliary-types';
import { ExtensiblePromise } from '../extensible-promise';
import { type PromiseExecutor } from '../promise-types';
import { StatefulPromise } from '../stateful-promise';
interface CancelablePromiseExecutor<T> {
(...args: Parameters<PromiseExecutor<T>>): CleanupFunction;
}
declare type CleanupFunction = Callback;
declare class CancelationError extends Error {
constructor();
}
declare class CancelablePromise<T> extends ExtensiblePromise<T, StatefulPromise<T>> {
private readonly reject;
private readonly cleanupFunction;
constructor(executor: CancelablePromiseExecutor<T>);
cancel(error?: Error): void;
}
export { CancelablePromise, CancelationError };