2 var arrayFindIndex = require('array-find-index');
4 module.exports = function () {
5 var unhandledRejections = [];
7 function onUnhandledRejection(reason, promise) {
8 unhandledRejections.push({reason: reason, promise: promise});
11 function onRejectionHandled(promise) {
12 var index = arrayFindIndex(unhandledRejections, function (x) {
13 return x.promise === promise;
16 unhandledRejections.splice(index, 1);
19 function currentlyUnhandled() {
20 return unhandledRejections.map(function (entry) {
23 promise: entry.promise
29 onUnhandledRejection: onUnhandledRejection,
30 onRejectionHandled: onRejectionHandled,
31 currentlyUnhandled: currentlyUnhandled