Socket
Socket
Sign inDemoInstall

browser-unhandled-rejection

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    browser-unhandled-rejection

Run browser and node tests with coverage reports


Version published
Weekly downloads
1.9K
increased by26.22%
Maintainers
1
Install size
9.40 kB
Created
Weekly downloads
 

Readme

Source

browser-unhandled-rejection

build status dependencies status npm version

A ponyfill/polyfill for browser Promise unhandledrejection events.

See: https://www.chromestatus.com/features/4805872211460096

sauce labs test status

Install

npm i browser-unhandled-rejection

or

yarn add browser-unhandled-rejection

Usage

Automatic polyfill

This automatically applies the polyfill to the global Promise object if it is needed.

import {auto} from 'browser-unhandled-rejection';

auto(); // Applies polyfill if necessary to window.Promise

Manual polyfill

The following snippet is equivalent to auto():

import {polyfill} from 'browser-unhandled-rejection';

if (typeof PromiseRejectionEvent !== 'undefined') {
  polyfill(); // Polyfills window.Promise
}

Ponyfill

This may may useful if you don't want to mutate window.Promise:

import MyPromise from 'browser-unhandled-rejection';

window.addEventListener('unhandledrejection', () => {
  console.log('unhandledrejection was triggered');
});

MyPromise.reject('will trigger unhandledrejection event');

new MyPromise((resolve, reject) => {
  reject('will also trigger unhandledrejection event');
});

FAQs

Last updated on 29 Mar 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc