race-cancellation
Version:
Utilities for using Promise.race([task, cancellation]) for async/await code.
11 lines • 868 B
TypeScript
import { CancellableAsyncFn, DisposableCancelExecutorFn, RaceCancelFn } from "./interfaces.js";
/**
* Run a {@link CancellableAsyncFn} function with a {@link RaceCancelFn} adapted from a {@link DisposableCancelExecutorFn} function.
*
* @param cancellableAsync - a {@link CancellableAsyncFn} function
* @param disposableCancelExecutor - a {@link DisposableCancelExecutorFn} function that will only be called once
* @param outerRaceCancel - an optional outer {@link RaceCancelFn} function that will be composed with the {@link RaceCancelFn} function before being passed to the {@link CancellableAsyncFn} function.
* @public
*/
export default function withCancel<TResult>(cancellableAsync: CancellableAsyncFn<TResult>, disposableCancelExecutor: DisposableCancelExecutorFn, outerRaceCancel?: RaceCancelFn): Promise<TResult>;
//# sourceMappingURL=withCancel.d.ts.map