JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 46165
  • Score
    100M100P100Q153459F
  • License ISC

Race a promise against an AbortSignal

Package Exports

  • race-signal
  • race-signal/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (race-signal) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

race-signal

Races a promise against an AbortSignal

Table of contents

Install

$ npm i --save race-signal

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)