Changelog
A redesign around the native AbortSignal. See Upgrading from 1.x for the full before/after table.
Breaking
EnhancedAbortControllerextendsAbortController;controller.signalis the nativeAbortSignal(nosignal.signal).EnhancedAbortSignalis a helper object of functions for anyAbortSignal, not a wrapper class.throwIfAborted()is the native one and throws the reason.- Timeouts abort with a
TimeoutErrorDOMException. dispose()releases resources and does not abort;abort()works after it;abortAfter()after it throws.- Invalid delays (
NaN, negative other than -1) throwRangeError. abortAftertimers are unref’d.
New
abortAfter()is chainable, acceptsTimeSpan, resets likeCancelAfter, cancels withInfinity/ -1 /TimeSpan.infinite, and supports delays over 24.8 days.- Linked controllers forward the parent’s reason, remove their parent listeners on abort or dispose, and skip
undefined/null/none. - Standalone
register(signal, cb)andwhenAborted(signal)for any signal; callbacks receive the reason;AbortRegistrationsupportsusing. isAbortError,isTimeoutError;AbortErrortakes acause.EnhancedAbortSignal.timeoutand.anybuild on the native implementations;noneis one shared signal that never collects listeners.TimeSpan:add,subtract,equals,compareTo,valueOf,toString,infinite; validation.usingsupport for controllers and registrations.- ESM and CommonJS builds; zero dependencies; Node 20+.
1.1.0 and earlier
Section titled “1.1.0 and earlier”The wrapper-based API. Its signal could not be passed to platform APIs directly, and dispose() was documented as aborting. Superseded by 2.0.