Primeout
Create a promise with a timeout.
npm install primeout
const primeout =// Will reject if the `connectToDb()` promise does// not respond within 30 seconds.
Contents
Examples
All of these examples assume that connect()
returns a promise.
// Set a timeout of 5 seconds
// Set a timeout of 5 minutes
// Set a timeout that rejects if the// promise is not resolved or rejected// before the next event loop.
For a clear-cut explanation of that last example (especially if you're new to node.js) see Understanding the node.js event loop.
API reference
primeout
The only export from the module. A function used to return the timeout-enabled promise desired.
Arguments
time
The timeout being specified. Can either be a number specifying the amount of milliseconds or a valid timestring.promise
The promise you wish to set a timeout for.