EnhancedAbortController
Defined in: src/EnhancedAbortController.ts:64
An AbortController with .NET CancellationTokenSource features. It is an AbortController,
and controller.signal is a real AbortSignal: pass it to fetch, AbortSignal.any, streams,
timers and any other API that takes a signal.
Example
Section titled “Example”const controller = new EnhancedAbortController().abortAfter(TimeSpan.fromSeconds(5));const response = await fetch(url, { signal: controller.signal });Extends
Section titled “Extends”AbortController
Implements
Section titled “Implements”Disposable
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new EnhancedAbortController():
EnhancedAbortController
Defined in: src/EnhancedAbortController.ts:69
Returns
Section titled “Returns”EnhancedAbortController
Overrides
Section titled “Overrides”AbortController.constructor
Accessors
Section titled “Accessors”isAborted
Section titled “isAborted”Get Signature
Section titled “Get Signature”get isAborted():
boolean
Defined in: src/EnhancedAbortController.ts:91
Same as signal.aborted.
Returns
Section titled “Returns”boolean
isDisposed
Section titled “isDisposed”Get Signature
Section titled “Get Signature”get isDisposed():
boolean
Defined in: src/EnhancedAbortController.ts:101
True after dispose.
Returns
Section titled “Returns”boolean
reason
Section titled “reason”Get Signature
Section titled “Get Signature”get reason():
unknown
Defined in: src/EnhancedAbortController.ts:96
Same as signal.reason: why it aborted, undefined until then.
Returns
Section titled “Returns”unknown
signal
Section titled “signal”Get Signature
Section titled “Get Signature”get signal():
EnhancedSignal
Defined in: src/EnhancedAbortController.ts:86
The controller’s signal: a real AbortSignal, always the same object.
Returns
Section titled “Returns”Overrides
Section titled “Overrides”AbortController.signal
Methods
Section titled “Methods”[dispose]()
Section titled “[dispose]()”[dispose]():
void
Defined in: src/EnhancedAbortController.ts:139
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Disposable.[dispose]
abort()
Section titled “abort()”abort(
reason?):void
Defined in: site/node_modules/typescript/lib/lib.dom.d.ts:2729
The abort() method of the AbortController interface aborts an asynchronous operation before it has completed.
Parameters
Section titled “Parameters”reason?
Section titled “reason?”any
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”AbortController.abort
abortAfter()
Section titled “abortAfter()”abortAfter(
delay):this
Defined in: src/EnhancedAbortController.ts:114
Aborts after delay, like .NET’s CancelAfter: calling it again replaces the previous schedule,
and Infinity / -1 / TimeSpan.infinite cancel it. The reason is a DOMException named
TimeoutError, as with AbortSignal.timeout. The timer never keeps the process alive, and delays
longer than 24.8 days work. Does nothing once aborted. Returns the controller, for chaining.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”this
Throws
Section titled “Throws”RangeError for NaN, negative (other than -1) or non-numeric delays.
Throws
Section titled “Throws”Error if the controller was disposed.
abortAfterTimeSpan()
Section titled “abortAfterTimeSpan()”abortAfterTimeSpan(
timeSpan):this
Defined in: src/EnhancedAbortController.ts:124
Same as abortAfter with a TimeSpan. Kept for 1.x code.
Parameters
Section titled “Parameters”timeSpan
Section titled “timeSpan”Returns
Section titled “Returns”this
dispose()
Section titled “dispose()”dispose():
void
Defined in: src/EnhancedAbortController.ts:133
Releases what the controller holds: the scheduled abort and the listeners it put on linked parent
signals. It does not abort (like .NET’s Dispose); call abort() first if work should stop.
abort() still works afterwards. Safe to call more than once; supports using.
Returns
Section titled “Returns”void
createLinkedController()
Section titled “createLinkedController()”
staticcreateLinkedController<C>(this, …signals):C
Defined in: src/EnhancedAbortController.ts:160
A controller that aborts as soon as any of signals aborts, with that signal’s reason, like .NET’s
CreateLinkedTokenSource. Aborting the linked controller does not affect the parents. Its listeners
on the parents are removed when it aborts or is disposed, so short-lived links on a long-lived parent
don’t leak. undefined/null entries (optional signals) and EnhancedAbortSignal.none are skipped.
Type Parameters
Section titled “Type Parameters”C extends EnhancedAbortController
Parameters
Section titled “Parameters”new () => C
signals
Section titled “signals”…(AbortSignal | null | undefined)[]
Returns
Section titled “Returns”C
linkSignals()
Section titled “linkSignals()”
staticlinkSignals<C>(this, …signals):C
Defined in: src/EnhancedAbortController.ts:177
Same as createLinkedController.
Type Parameters
Section titled “Type Parameters”C extends EnhancedAbortController
Parameters
Section titled “Parameters”new () => C
signals
Section titled “signals”…(AbortSignal | null | undefined)[]
Returns
Section titled “Returns”C
timeout()
Section titled “timeout()”
statictimeout<C>(this,delay):C
Defined in: src/EnhancedAbortController.ts:150
A controller that aborts after delay, with a TimeoutError reason.
Type Parameters
Section titled “Type Parameters”C extends EnhancedAbortController
Parameters
Section titled “Parameters”new () => C
Returns
Section titled “Returns”C