https://github.com/node-fetch/timeout-signal
Create an AbortSignal that aborts after a delay.
https://github.com/node-fetch/timeout-signal
Last synced: 5 months ago
JSON representation
Create an AbortSignal that aborts after a delay.
- Host: GitHub
- URL: https://github.com/node-fetch/timeout-signal
- Owner: node-fetch
- License: mit
- Created: 2020-05-24T04:09:15.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-12-19T15:16:14.000Z (almost 3 years ago)
- Last Synced: 2024-04-25T23:44:33.363Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 23.4 KB
- Stars: 15
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# timeout-signal
> Create an AbortSignal that aborts after a delay
## Install
```sh
npm install timeout-signal
```
## Usage
```js
import timeoutSignal from 'timeout-signal';
const signal = timeoutSignal(5000);
try {
const response = await fetch('https://www.google.com', {signal});
// Handle response
} catch (error) {
if (signal.aborted) {
// Handle abortion
}
}
```
## API
### timeoutSignal(timeout)
#### timeout
Type: `integer`
The milliseconds to wait.