Package Exports
- timeout-signal
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 (timeout-signal) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
timeout-signal 
Create an AbortSignal that aborts after a delay.
Install
npm install timeout-signal
Usage
const timeoutSignal = require("timeout-signal");
const fetch = require("cross-fetch");
try {
const response = await fetch("https://www.google.com", { signal: timeoutSignal(5000) })
// Handle response
} catch (error) {
if (error.message === "The user aborted a request.") {
// Handle abortion
}
}
API
timeoutSignal(timeout)
timeout
Type: integer
The milliseconds to wait.
timeoutSignal.clear(signal)
Clear the timeout associated with a signal.
signal
Type: Return value from timeoutSignal()
The signal to clear the timeout for.
const timeoutSignal = require("timeout-signal");
const fetch = require("cross-fetch");
const signal = timeoutSignal(5000)
try {
const response = await fetch("https://www.google.com", { signal })
timeoutSignal.clear(signal)
// Handle response
} catch (error) {
if (error.message === "The user aborted a request.") {
// Handle abortion
}
}