Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/khrj/p-timeout

Timeout a promise after a specified amount of time
https://github.com/khrj/p-timeout

deno module port promise timeout typescript

Last synced: 3 months ago
JSON representation

Timeout a promise after a specified amount of time

Awesome Lists containing this project

README

        


People standing in Timeout illustration

Promise Timeout



Timeout a promise after a specified amount of time. Deno port of sindresorhus's p-timeout for node



build status
language
code size
issues
license
version



View on deno.land








## Usage

```js
import pTimeout from "https://deno.land/x/[email protected]/mod.ts"

const delayedPromise = new Promise(resolve => setTimeout(resolve, 500))

await pTimeout({
promise: delayedPromise,
milliseconds: 50,
})

// => [TimeoutError: Promise timed out after 50 milliseconds]
```

## API

See https://doc.deno.land/https/deno.land/x/[email protected]/mod.ts

## Supporters

- HUGE thanks to @sindresorhus -- this repository is mostly his code, modified to work with Deno

[![Stargazers repo roster for @khrj/p-timeout](https://reporoster.com/stars/khrj/p-timeout)](https://github.com/khrj/p-timeout/stargazers)

[![Forkers repo roster for @khrj/p-timeout](https://reporoster.com/forks/khrj/p-timeout)](https://github.com/khrj/p-timeout/network/members)

## Related

- [p-queue](https://github.com/khrj/p-queue)
- [p-retried](https://github.com/khrj/p-retried)
- [retried](https://github.com/khrj/retried)
- [...more](https://github.com/khrj/deno-modules)

## License

- Promise Timeout is licensed under the MIT license.
- Code is adapted from [Sindre's p-timeout for node](https://github.com/sindresorhus/p-timeout) (also under the MIT license)