This package has been deprecated

Author message:

Development of this module has been stopped.

promise-timeout-rejection

1.0.5 • Public • Published

promise timeout rejection

NPM version Build status License Code style

Reject a promise if it takes more than a set duration.

Installation

$ npm install --save promise-timeout-rejection

...or:

$ yarn add promise-timeout-rejection

Usage

Wrap a promise and define a timeout in milliseconds. If the promise resolves or rejects in that time then it acts in the exact same way as the original promise, otherwise it's rejected with a specific PromiseTimeOutError error.

promiseTimeout(promise, timeout)

const promiseTimeout = require('promise-timeout-rejection')
const pausePromise = require('pause-promise')
 
// `pausePromise` takes an argument of the amount of milliseconds
// it will take to resolve
 
promiseTimeout(pause(1500), 2000)
  .catch(err => {
    assert(err instanceof promiseTimeout.PromiseTimeOutError)
  })

Readme

Keywords

Package Sidebar

Install

npm i promise-timeout-rejection

Weekly Downloads

0

Version

1.0.5

License

MIT

Last publish

Collaborators

  • roryrjb