🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

abort-signal

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abort-signal

A utility library for working with AbortSignal in JavaScript and TypeScript.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

abort-signal

CI NPM Version MIT License npm bundle size Install Size

abort-signal is a utility library for working with AbortSignal in JavaScript and TypeScript. It provides a modern, intuitive API to simplify common cancellation and timeout patterns.

📦 Installation

pnpm install abort-signal
Install using your favorite package manager

npm

npm install abort-signal

yarn

yarn add abort-signal

đź“– Usage

Timeout

The most common use case: aborting an operation if it takes too long.

try {
  // Request will fail if it takes longer than 3 seconds.
  const response = await fetch(url, { signal: Abort.timeout(3000) });
} catch (error) {
  if (error instanceof TimeoutError) {
    console.log('Request timed out!');
  }
}

Combining Signals

Abort an operation from one of several sources, like a timeout OR a user click.

const userClickSignal = Abort.fromEvent(cancelButton, 'click');
const timeoutSignal = Abort.timeout(10000);

// Aborts on user click OR timeout, whichever comes first.
const combinedSignal = Abort.any([userClickSignal, timeoutSignal]);
await longRunningOperation({ signal: combinedSignal });

From an Event

Bridge the DOM/event world with the cancellation world.

// Signal will abort as soon as the user navigates away or closes the tab.
const signal = Abort.fromEvent(window, 'unload');
await saveDraftToServer({ signal });

📚 Documentation

For detailed API documentation on all methods, please see the API docs.

🤝 Contributing

Want to contribute? Awesome! To show your support is to star the project, or to raise issues on GitHub.

Thanks again for your support, it is much appreciated! 🙏

License

MIT © Shahrad Elahi and contributors.

Keywords

abort

FAQs

Package last updated on 23 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts