Function handleAborted
Parameters
- signal: AbortSignal
An optional AbortSignal to check.
- onAbort: (reason?: unknown) => void
A callback invoked when the signal is aborted. Receives the abort
reasonif any.
Returns boolean
trueif the signal was aborted and the callback was invoked; otherwisefalse.- signal: AbortSignal
Handles cooperative cancellation for an AbortSignal by invoking the provided abort callback when the signal has been aborted.
This utility centralizes the common pattern of checking
signal.aborted, executing cleanup logic, and short-circuiting control flow. It is intended for use inside loops and async operations where early termination should occur without throwing.