Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

promise-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-polyfill - npm Package Compare versions

Comparing version 5.2.1 to 6.0.0

CHANGELOG.md

2

package.json
{
"name": "promise-polyfill",
"version": "5.2.1",
"version": "6.0.0",
"description": "Lightweight promise polyfill. A+ compliant",

@@ -5,0 +5,0 @@ "main": "promise.js",

@@ -7,17 +7,4 @@ (function (root) {

function noop() {
}
// Use polyfill for setImmediate for performance gains
var asap = (typeof setImmediate === 'function' && setImmediate) ||
function (fn) {
setTimeoutFunc(fn, 0);
};
var onUnhandledRejection = function onUnhandledRejection(err) {
if (typeof console !== 'undefined' && console) {
console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console
}
};
function noop() {}
// Polyfill for Function.prototype.bind

@@ -50,3 +37,3 @@ function bind(fn, thisArg) {

self._handled = true;
asap(function () {
Promise._immediateFn(function () {
var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;

@@ -100,5 +87,5 @@ if (cb === null) {

if (self._state === 2 && self._deferreds.length === 0) {
asap(function() {
Promise._immediateFn(function() {
if (!self._handled) {
onUnhandledRejection(self._value);
Promise._unhandledRejectionFn(self._value);
}

@@ -213,15 +200,32 @@ });

// Use polyfill for setImmediate for performance gains
Promise._immediateFn = (typeof setImmediate === 'function' && setImmediate) ||
function (fn) {
setTimeoutFunc(fn, 0);
};
Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
if (typeof console !== 'undefined' && console) {
console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console
}
};
/**
* Set the immediate function to execute callbacks
* @param fn {function} Function to execute
* @private
* @deprecated
*/
Promise._setImmediateFn = function _setImmediateFn(fn) {
asap = fn;
Promise._immediateFn = fn;
};
/**
* Change the function to execute on unhandled rejection
* @param {function} fn Function to execute on unhandled rejection
* @deprecated
*/
Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {
onUnhandledRejection = fn;
Promise._unhandledRejectionFn = fn;
};
if (typeof module !== 'undefined' && module.exports) {

@@ -228,0 +232,0 @@ module.exports = Promise;

@@ -52,2 +52,7 @@ <a href="http://promises-aplus.github.com/promises-spec">

## Deprecations
- `Promise._setImmediateFn(<immediateFn>)` has been deprecated. Use `Promise._immediateFn = <immediateFn>;` instead.
- `Promise._setUnhandledRejectionFn(<rejectionFn>)` has been deprecated. Use `Promise._unhandledRejectionFn = <rejectionFn>` instead.
These functions will be removed in the next major version.
## Performance

@@ -57,3 +62,3 @@ By default promise-polyfill uses `setImmediate`, but falls back to `setTimeout` for executing asynchronously. If a browser does not support `setImmediate` (IE/Edge are the only browsers with setImmediate), you may see performance issues.

If you polyfill `window.setImmediate` or use `Promise._setImmediateFn(immedateFn)` it will be used instead of `window.setTimeout`
If you polyfill `window.setImmediate` or use `Promise._immediateFn = yourImmediateFn` it will be used instead of `window.setTimeout`
```

@@ -65,3 +70,3 @@ npm install setasap --save

var setAsap = require('setasap');
Promise._setImmediateFn(setAsap);
Promise._immediateFn = setAsap;
```

@@ -73,3 +78,3 @@

```js
Promise._setUnhandledRejectionFn(function(rejectError) {});
Promise._unhandledRejectionFn = function(rejectError) {};
```

@@ -76,0 +81,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc