# extra-abort

> ```sh npm install --save extra-abort # or yarn add extra-abort ```

Latest version **0.5.1** (published 2026-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install extra-abort
pnpm add extra-abort
yarn add extra-abort
bun add extra-abort
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.5.1 |
| Published | 2026-05-24 |
| First published | 2021-12-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 7 |
| Unpacked size | 26 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | BlackGlory |
| Maintainers | black_glory |

## Links

- npm: https://www.npmjs.com/package/extra-abort
- Repository: https://github.com/BlackGlory/extra-abort
- Homepage: https://github.com/BlackGlory/extra-abort#readme
- Issues: https://github.com/BlackGlory/extra-abort/issues
- npm.io page: https://npm.io/package/extra-abort

## Dependencies (7)

- [justypes](https://npm.io/package/justypes.md) ^4.5.0
- [extra-defer](https://npm.io/package/extra-defer.md) ^0.3.1
- [extra-timers](https://npm.io/package/extra-timers.md) ^0.3.1
- [@blackglory/go](https://npm.io/package/@blackglory/go.md) ^2.0.0
- [@blackglory/pass](https://npm.io/package/@blackglory/pass.md) ^1.1.1
- [iterable-operator](https://npm.io/package/iterable-operator.md) ^6.0.0
- [@blackglory/errors](https://npm.io/package/@blackglory/errors.md) ^3.1.0

## Recent versions

- 0.5.1 (latest) — 2026-05-24
- 0.5.0 — 2026-05-24
- 0.4.1 — 2026-02-14
- 0.4.0 — 2024-12-10
- 0.3.10 — 2024-12-02
- 0.3.9 — 2023-12-30
- 0.3.8 — 2023-12-29
- 0.3.7 — 2023-06-10
- 0.3.6 — 2023-04-03
- 0.3.5 — 2023-04-02
- 0.3.4 — 2023-03-26
- 0.3.3 — 2023-03-24
- 0.3.2 — 2023-03-09
- 0.3.1 — 2023-01-22
- 0.2.2 — 2023-01-22
- … 9 more at https://npm.io/package/extra-abort/versions

## README

# extra-abort
## Install
```sh
npm install --save extra-abort
# or
yarn add extra-abort
```

## API
### AbortController, AbortSignal
The WHATWG `AbortController` and `AbortSignal`.

### AbortError
```ts
class AbortError extends CustomError {}
```

It is not the real `AbortError`,
but you can do `err instance AbortError` like it is,
because it can recognizes other errors that match the pattern of `AbortError`.

### TimeoutError
```ts
class TimeoutError extends AbortError {}
```

It is not the real `TimeoutError`,
but you can do `err instance TimeoutError` like it is,
because it can recognizes other errors that match the pattern of `TimeoutError`.

### LinkedAbortController
```ts
class LinkedAbortController extends AbortController {
  constructor(signal: AbortSignal)
}
```

It is a special `AbortController` that takes an `AbortSignal` as a parameter.
It will abort itself when its parameter signal aborts,
you can make it abort by calling its `abort` method too.

### timeoutSignal
```ts
function timeoutSignal(ms: number): AbortSignal
```

It will abort after `ms` milliseconds.

```ts
await fetch('http://example.com', { signal: timeoutSignal(5000) })
```

### withAbortSignal
```ts
/**
 * @throws {AbortError}
 */
function withAbortSignal<T>(signal: AbortSignal | Falsy, fn: () => PromiseLike<T>): Promise<T>
```

If `AbortSignal` is aborted, the promise will be rejected with `AbortError`.

### raceAbortSignals
```ts
function raceAbortSignals(signals: Array<AbortSignal | Falsy>): AbortSignal
```

The `Promise.race` function for `AbortSignal`.

### isAbortSignal
```ts
function isAbortSignal(val: unknown): val is AbortSignal
```

### lastCallOnly
```ts
function lastCallOnly<T, Args extends unknown[]>(
  fn: (...args: [...args: Args, signal: AbortSignal]) => PromiseLike<T>
): (...args: [...args: Args, signal: AbortSignal | Falsy]) => Promise<T>
```

---
_Source: https://npm.io/package/extra-abort · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
