TimeSpan is an immutable interval stored in milliseconds. Every API that takes a delay (abortAfter, timeout, EnhancedAbortSignal.timeout) accepts a number of milliseconds or a TimeSpan.
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.
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.
@throws ― RangeError for NaN, negative (other than -1) or non-numeric delays.
@throws ― Error if the controller was disposed.
abortAfter(
classTimeSpan
An immutable time interval, stored in milliseconds. Modeled on .NET's TimeSpan.
Every factory throws a RangeError for NaN and ±Infinity: TimeSpan.fromSeconds(NaN) fails where it is written, not later as an instant abort.
TimeSpan itself allows negatives (for arithmetic), but a delay must be non-negative: abortAfter(TimeSpan.fromSeconds(-5)) throws a RangeError. The one exception is -1 ms (TimeSpan.infinite), which means “no deadline”.