Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mvila/promise-with-timeout
Limit the time to resolve a promise
https://github.com/mvila/promise-with-timeout
Last synced: about 1 month ago
JSON representation
Limit the time to resolve a promise
- Host: GitHub
- URL: https://github.com/mvila/promise-with-timeout
- Owner: mvila
- Created: 2016-09-01T07:51:05.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-01T07:52:55.000Z (about 8 years ago)
- Last Synced: 2024-09-26T08:06:09.834Z (about 2 months ago)
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# promise-with-timeout [![npm version](https://img.shields.io/npm/v/promise-with-timeout.svg)](https://www.npmjs.com/package/promise-with-timeout)
Limit the time to resolve a promise.
## Installation
```
npm install --save promise-with-timeout
```## Example
```javascript
import withTimeout from 'promise-with-timeout';async function test() {
// Throw an error if there is no response after 10 seconds:
let response = await withTimeout(fetch('https://www.w3.org/'), 10000);
}
```## License
MIT