0.1.4 • Published 5 years ago

@jostft/promise-timeout v0.1.4

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

PromiseTimeout

It allows for executing promises, but with set timeouts.

example: I request from a server, but if I don't receieve a response before 15 seconds, then I want the promise to time out.

const serverPromise = getUsers();
const result = await PromiseTimeout(15, "timed out!", serverPromise);
parameterstypedescription
timeoutInMilisecondsnumberThe miliseconds it takes for the promise to timeout
timeoutMessagestringthe error message to be thrown when it times out
promisePromisethe promise that needs to complete before the timeout