@jostft/promise-timeout

0.1.4 • Public • Published

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);
parameters type description
timeoutInMiliseconds number The miliseconds it takes for the promise to timeout
timeoutMessage string the error message to be thrown when it times out
promise Promise the promise that needs to complete before the timeout

Readme

Keywords

Package Sidebar

Install

npm i @jostft/promise-timeout

Weekly Downloads

1

Version

0.1.4

License

ISC

Unpacked Size

4.63 kB

Total Files

9

Last publish

Collaborators

  • jostft