TimeoutError to allow an ease-of-use usage of promises that reject after a given timeout, unless their purpose was either resolved or rejected before the given timeout.
I was implementing this for work, and couldn't find any good examples online, so I figured I'd publish a module.
The timeout promise modules that I did find, made usage of
Promise.race() which isn't supported by Internet Explorer,
This module uses ES6 only and supports all browsers.
Simply install this module in your project with
$ npm install simple-timeout-promise --save
Given a function that returns a promise -
promiseFunc, and a
delay in miliseconds, create a wrapped promise:
const TimeoutPromise TimeoutError =const timeoutPromise = delay promiseFunctimeoutPromise