promise-timeout
A super-simple way to put a timeout on promise resolution.
It assumes you already have either platform support for promises (Node 0.12 or greater), or you have a polyfill (see es6-promise).
Installation
$ npm install promise-timeout
Usage
timeout(promise, timeoutMillis)
Rejects a promise with a TimeoutError
if it does not settle within the
specified timeout. Parameters:
promise: Promise
- Promise to monitor.timeoutMillis: number
- Number of milliseconds to wait on settling.
TimeoutError
Exception indicating that the timeout expired.
Examples
ES2015:
; let somePromise = ; ;
ES5:
'use strict'; var pt = ; var somePromise = ; pt ;