Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

abort-utils

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abort-utils

Utility functions to use and combine `AbortSignal` and `AbortController` with Promises

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
936
decreased by-16.65%
Maintainers
0
Weekly downloads
 
Created
Source

abort-utils

Utility functions to use and combine AbortSignal and AbortController with Promises

Install

npm install abort-utils
import {
	onAbort,
	mergeSignals,
	linkControllers,
	promiseFromSignal,
	ReusableAbortController
} from 'abort-utils';

Usage

This package exports various utilities, just import what you need.

  • onAbort: Add multiple callbacks, observers and other abort controllers to a single signal.
  • mergeSignals: Create a new signal that aborts when any of the input signals aborts.
  • linkControllers: Link multiple controllers so that when one aborts, they all abort with the same reason.
  • signalFromEvent: Create an AbortSignal that is aborted when an event is dispatched.
  • abortAllAndClear: Aborts all controllers in an Array/Set and empties it.
  • signalFromPromise: Create an AbortSignal that is aborted when a Promise is resolved or rejected.
  • promiseFromSignal: Create a Promise that resolves or rejects when the signal aborts.
  • ReusableAbortController: Like AbortController, but it generates a new signal after it's aborted.

Demo

Here's a visual representation that might help understand how some of the methods differ and behave.

License

MIT © Federico Brigante

Keywords

FAQs

Package last updated on 17 Nov 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc