Socket
Socket
Sign inDemoInstall

race-signal

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    race-signal

Race a promise against an AbortSignal


Version published
Weekly downloads
12K
decreased by-15.44%
Maintainers
1
Install size
11.7 kB
Created
Weekly downloads
 

Changelog

Source

1.0.2 (2023-11-16)

Bug Fixes

  • update error name to AbortError (#46) (050e94d)

Readme

Source

race-signal

codecov CI

Race a promise against an AbortSignal

Table of contents

Install

$ npm i race-signal

Browser <script> tag

Loading this module through a script tag will make it's exports available as RaceSignal in the global namespace.

<script src="https://unpkg.com/race-signal/dist/index.min.js"></script>

Example

const { raceSignal } = require('race-signal')

const controller = new AbortController()

const promise = new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve('a value')
  }, 1000)
})

setTimeout(() => {
  controller.abort()
}, 500)

// throws an AbortError
const resolve = await raceSignal(promise, controller.signal)

API Docs

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

FAQs

Last updated on 16 Nov 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc