Skip to content
Buy me a coffee

Installation

Terminal window
npm i @ylcnfrht/enhanced-abort-controller

Zero runtime dependencies. Requires Node 20 or later; also runs in Bun, Deno and modern browsers.

import { EnhancedAbortController, TimeSpan, register, whenAborted, isAbortError } from '@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).

Types are included. Two settings matter:

  • using declarations 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. Without using, call controller.dispose() in a finally.
  • The Disposable type. In Node projects @types/node provides it. Browser-only projects without @types/node need the disposable lib:
tsconfig.json
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2022", "ESNext.Disposable", "DOM"]
}
}

Coming from 1.x? 2.0 changes how the signal works. Read Upgrading from 1.x first.