UNPKG

abort-utils

Version:

Utility functions to use and combine `AbortSignal` and `AbortController` with Promises

12 lines (11 loc) 597 B
/** * Returns a `Promise` that resolves or rejects when the signal is aborted. This lets you await a signal or combine it with other promises. * * The promise will use the abort reason as a resolved/rejected value. * * @param signal The signal to listen to. If you pass a controller, it will automatically extract its signal. * @param options.rejects If `true`, the promise will reject instead of resolve when the signal is aborted. */ export declare function promiseFromSignal(signal: AbortSignal | AbortController, { rejects }?: { rejects?: boolean | undefined; }): Promise<unknown>;