1.0.5 • Published 7 years ago

promise-timeout-rejection v1.0.5

Weekly downloads
8
License
MIT
Repository
github
Last release
7 years ago

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)
  })
1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago