/**
 * A token that can be passed to operations that support cancellation.
 */
export type CancelToken = Promise<unknown>;
/**
 * Allows cancellation of asynchronous operations.
 */
export declare class Cancellable {
    /**
     * A cancel token that is passed into cancellable operations. If
     * {@link cancel} is called, the promise will be rejected with an instance of
     * {@link support/Cancellable!Cancellation}.
     */
    token: CancelToken;
    constructor();
    /**
     * Signals cancellation to asynchronous operations that are associated with
     * the cancel token.
     *
     * @param reason Extra data signifying the reason for cancellation. This
     *   will part of the the {@link support/Cancellable!Cancellation} that is
     *   propagated from the cancel token.
     */
    cancel(reason?: unknown): void;
}
/**
 * Indicates that an operation was cancelled.
 */
export declare class Cancellation {
    /**
     * The reason for cancellation.
     */
    reason: unknown;
    /**
     * The cancel token that triggered the cancellation.
     */
    token: CancelToken;
    constructor(reason?: unknown, token?: CancelToken);
}
/**
 * Takes an existing promise and makes it cancellable via the given cancel
 * token. If the cancel token is never triggered, then the promise will resolve
 * as normal. However, if the cancel token is triggered and the promise is not
 * yet resolved, then it will be rejected with an instance of Cancellation.
 *
 * @param promise The original promise to make cancellable.
 * @param cancelToken The cancellation token obtained from a
 *   {@link support/Cancellable!Cancellable}.
 * @param onCancel On optional callback to trigger when the promise is about to
 *   be canceled.
 * @returns A new promise that adds cancellation semantics to the original
 *   promise.
 */
export declare function cancelify<T>(promise: PromiseLike<T>, cancelToken: CancelToken | undefined, onCancel?: (reason: unknown) => void): Promise<T>;
/**
 * Executes an asynchronous callback that takes an `AbortSignal` and makes it
 * cancellable via the given cancel token. If the cancel token is never
 * triggered, then the promise will resolve as normal. However, if the cancel
 * token is triggered and the promise is not yet resolved, then it will be
 * rejected with an instance of Cancellation.
 *
 * @param action The async callback to execute and make cancellable.
 * @param cancelToken The cancellation token obtained from a
 *   {@link support/Cancellable!Cancellable}.
 * @param onCancel On optional callback to trigger when the promise is about to
 *   be canceled.
 * @returns A new promise that adds cancellation semantics to the original
 *   promise.
 */
export declare function cancelifyWithAbortSignal<T>(action: (signal: AbortSignal) => PromiseLike<T>, cancelToken: CancelToken | undefined, onCancel?: (reason: unknown) => void): Promise<T>;
