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

abort-controller-multiplexer

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-controller-multiplexer

Combine multiple AbortControllers or AbortSignals into a single instance

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
320
increased by86.05%
Maintainers
1
Weekly downloads
 
Created
Source

AbortController Multiplexer

Combine multiple AbortControllers or AbortSignals into a single instance

abort-controller-multiplexer Tests status GitHub

AbortControllers are very useful mechanisms in JavaScript that allow one to insert abort signals into application components with ease. You can pass an AbortController's signal (AbortSignal) into methods you call, abort it later, and use it to:

  • Cancel asynchronous operations
    • Cancel requests
  • Throw if the signal was previously aborted
  • Etc.

Sometimes, in sufficiently complicated applications, you may run across situations where you need multiple abort signals. This library can be used to group them together into one large signal/controller, that you can abort from a single method or watch using a single signal.

Installation

Install using npm:

npm install abort-controller-multiplexer --save

Note that this library uses ESM. You must consume it in an ESM-friendly environment.

Usage

Combine several abort controllers:

import { combineControllers } from "abort-controller-multiplexer";

const ac1 = new AbortController();
const ac2 = new AbortController();
const controller = combineControllers(ac1, ac2);

controller.abort();

Note that combineControllers calls combineSignals under the hood.

Combine several signals:

import { combineSignals } from "abort-controller-multiplexer";

const ac1 = new AbortController();
const ac2 = new AbortController();
const signal = combineSignals(ac1.signal, ac2.signal);

ac1.abort();

signal.throwIfAborted(); // Throws

Note that these combination methods do not modify the underlying AbortController and AbortSignal instances.

Keywords

FAQs

Package last updated on 14 Nov 2023

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