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

any-signal

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

any-signal

Combines an array of AbortSignals into a single signal that is aborted when any signal is

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
110K
increased by4.17%
Maintainers
1
Weekly downloads
 
Created
Source

any-signal

Build Status dependencies Status JavaScript Style Guide

Combines an array of AbortSignals into a single signal that is aborted when any signal is.

Install

npm install any-signal

Usage

const anySignal = require('any-signal')

const userController = new AbortController()
const timeoutController = new AbortController()

const combinedSignal = anySignal([userController.signal, timeoutController.signal])
combinedSignal.addEventListener('abort', () => console.log('Abort!'))

// Abort after 1 second
const timeoutId = setTimeout(() => timeoutController.abort(), 1000)

// The user or the timeout can now abort the action
await performSomeAction({ signal: combinedSignal })
clearTimeout(timeoutId)

API

anySignal(signals)

Parameters
NameTypeDescription
signalsArray<AbortSignal>The Signals that will be observed and mapped to the returned Signal
Returns
TypeDescription
AbortSignalA Signal that will be aborted as soon as any one of its parent signals are aborted.

The returned AbortSignal will only be aborted once, and as soon as one of its parent signals is aborted.

Acknowledgements

The anySignal function is taken from a comment by jakearchibald

LICENSE

MIT © Jacob Heun

FAQs

Package last updated on 12 Jan 2022

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