https://github.com/luludotdev/ptimeout
https://github.com/luludotdev/ptimeout
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/luludotdev/ptimeout
- Owner: luludotdev
- License: mit
- Created: 2019-08-25T10:00:39.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-06T15:03:43.000Z (about 3 years ago)
- Last Synced: 2025-06-28T10:43:37.513Z (11 months ago)
- Language: TypeScript
- Size: 496 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ⌛ pTimeout
[](https://www.npmjs.com/package/@lolpants/ptimeout)
[](https://www.npmjs.com/package/@lolpants/ptimeout)
[](https://travis-ci.com/lolPants/pTimeout)
[](https://david-dm.org/lolpants/ptimeout)
[](https://coveralls.io/github/lolPants/pTimeout?branch=master)
_Set a limit on promise execution time._
Written in TypeScript, compiled down to ES2017 for use in any Node.js >=10.x!
## 💾 Installation
The package is on the NPM registry as `@lolpants/ptimeout`. Simply install it with your NPM client of choice.
## 🔧 Usage
```ts
// Import (CommonJS)
const pTimeout = require('@lolpants/ptimeout')
// Import (ESM)
import pTimeout from '@lolpants/ptimeout'
// Use
const longPromise = () => new Promise(/* something that takes ages */)
await pTimeout(() => longPromise(), 1000 * 10)
// Will throw an error if timeout takes longer than 10s
```