promise-with-timeout

1.0.1 • Public • Published

promise-with-timeout npm version

Limit the time to resolve a promise.

Installation

npm install --save promise-with-timeout

Example

import withTimeout from 'promise-with-timeout';
 
async function test() {
  // Throw an error if there is no response after 10 seconds:
  let response = await withTimeout(fetch('https://www.w3.org/'), 10000);
}

License

MIT

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i promise-with-timeout

      Weekly Downloads

      2

      Version

      1.0.1

      License

      MIT

      Last publish

      Collaborators

      • mvila