Installation
npm i @ylcnfrht/enhanced-abort-controllerpnpm add @ylcnfrht/enhanced-abort-controlleryarn add @ylcnfrht/enhanced-abort-controllerbun add @ylcnfrht/enhanced-abort-controllerZero runtime dependencies. Requires Node 20 or later; also runs in Bun, Deno and modern browsers.
Import
Section titled “Import”import { EnhancedAbortController, TimeSpan, register, whenAborted, isAbortError } from '@ylcnfrht/enhanced-abort-controller';const { EnhancedAbortController, TimeSpan } = require('@ylcnfrht/enhanced-abort-controller');The package ships separate ESM and CommonJS builds with their own type declarations. A TimeSpan created by one build is accepted by the other (delays are checked by shape, not by instanceof).
TypeScript
Section titled “TypeScript”Types are included. Two settings matter:
usingdeclarations need TypeScript 5.2 or later. TypeScript compiles them down for runtimes that don’t support them natively; Node 24 and Chrome 134 run them as is. Withoutusing, callcontroller.dispose()in afinally.- The
Disposabletype. In Node projects@types/nodeprovides it. Browser-only projects without@types/nodeneed the disposable lib:
{ "compilerOptions": { "target": "ES2022", "lib": ["ES2022", "ESNext.Disposable", "DOM"] }}Upgrading
Section titled “Upgrading”Coming from 1.x? 2.0 changes how the signal works. Read Upgrading from 1.x first.