currently-rejected
Track the list of currently rejected promises.
Install
$ npm install --save currently-rejected
Usage
const currentlyRejected = require('currently-rejected')(); // <- note the invocation
var fooError = new Error('foo');
var p = Promise.reject(new Error('foo'));
// on the next tick - unhandled rejected promise is added to the list:
currentlyRejected();
//=> [{promise: p, reason: fooError}]'
p.catch(() => {});
// on the next tick - handled promise is now removed from the list:
currentlyRejected();
//=> [];
API
currentlyRejected()
Returns an array of objects with promise
and reason
properties. The list is updated as unhandledRejections are published, and later handled.
License
MIT © James Talmage