@lolpants/ptimeout
v1.0.3
Published
Set a limit on promise execution time
Downloads
12
Maintainers
Readme
⌛ pTimeout
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
// 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