@lolpants/ptimeout
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

pTimeout

NPM version NPM downloads Build status Dependencies Coverage Status

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

Package Sidebar

Install

npm i @lolpants/ptimeout

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

6.79 kB

Total Files

13

Last publish

Collaborators

  • lolpants