1
0
mirror of https://github.com/thangisme/notes.git synced 2024-11-06 22:37:27 -05:00
notes/node_modules/currently-unhandled/browser.js
Patrick Marsceill b7b0d0d7bf
Initial commit
2017-03-09 13:16:08 -05:00

28 lines
561 B
JavaScript

'use strict';
var core = require('./core');
function unwrapEvent(event) {
if (event && event.detail && event.detail.promise) {
return event.detail;
}
return event;
}
module.exports = function (w) {
w = w || window;
var c = core();
w.addEventListener('unhandledrejection', function (event) {
event = unwrapEvent(event);
c.onUnhandledRejection(event.reason, event.promise);
});
w.addEventListener('rejectionhandled', function (event) {
event = unwrapEvent(event);
c.onRejectionHandled(event.promise);
});
return c.currentlyUnhandled;
};