browser-unhandled-rejection
browser-unhandled-rejection copied to clipboard
A ponyfill/polyfill for browser Promise unhandledrejection events
I did `npm i browser-unhandled-rejection`. And in my code: ```js import { auto } from 'browser-unhandled-rejection'; ``` But my terminal is outputting `Can't resolve 'browser-unhandled-rejection'` error. Using `node` 10.8.0 and...
https://github.com/rtsao/browser-unhandled-rejection/blob/119a301dac2b0461e95539e9e2a79ad5d328e7ce/src/promise.js#L17 Here is my demo: ```javascript new InstrumentedPromise ((resolve, reject) => { reject('will also trigger unhandledrejection event'); }).then(()=>{console.log(1)}); ``` I test the code , the result is below:  You...
The native implementation of Promise.prototype.finally in Chrome doesn't work quite right with this polyfill. When doing something like `Promise.reject('test').finally(() => {})` the polyfill will not emit an unhandledrejection.
``` test(`does not trigger event for recovered downstream 2 (${name})`, t => { t.plan(1); let count = 0; const reason = 'rejection'; const listener = (e) => { count++; }...
### Steps to reproduce Run polyfill in environment that natively supports `unhandledrejection` event (tested in Chrome 65). ### Sample code ```js window.addEventListener('unhandledrejection', (e) => { if (e instanceof PromiseRejectionEvent) {...
For use cases where native subclassing of Promise is supported, it is preferable to use native subclassing instead of `__proto__`. This package should provide this version as well.
Right now this package is opinionated in that it dispatches `unhandledrejection` events. Others may want to call `window.onunhandledrejection`. Or others may want to do something else entirely. This package should...