Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/khrj/p-timeout
- Owner: khrj
- License: mit
- Created: 2021-02-08T11:29:40.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-11-02T10:59:47.000Z (about 2 years ago)
- Last Synced: 2024-10-28T12:15:55.387Z (3 months ago)
- Topics: deno, module, port, promise, timeout, typescript
- Language: TypeScript
- Homepage: https://deno.land/x/p_timeout
- Size: 220 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Promise Timeout
Timeout a promise after a specified amount of time. Deno port of sindresorhus's p-timeout for node
## 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)