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)