Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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