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.1.0 to 5.2.0

2

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

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

@@ -102,5 +102,5 @@ (function (root) {

}
}, 1);
});
}
for (var i = 0, len = self._deferreds.length; i < len; i++) {

@@ -148,3 +148,4 @@ handle(self, self._deferreds[i]);

Promise.prototype.then = function (onFulfilled, onRejected) {
var prom = new Promise(noop);
var prom = new (this.constructor)(noop);
handle(this, new Handler(onFulfilled, onRejected, prom));

@@ -219,3 +220,3 @@ return prom;

};
Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {

@@ -222,0 +223,0 @@ onUnhandledRejection = fn;

@@ -1,1 +0,1 @@

!function(e){function t(){}function n(e,t){return function(){e.apply(t,arguments)}}function o(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],s(e,this)}function r(e,t){for(;3===e._state;)e=e._value;return 0===e._state?void e._deferreds.push(t):(e._handled=!0,void a(function(){var n=1===e._state?t.onFulfilled:t.onRejected;if(null===n)return void(1===e._state?i:f)(t.promise,e._value);var o;try{o=n(e._value)}catch(r){return void f(t.promise,r)}i(t.promise,o)}))}function i(e,t){try{if(t===e)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var r=t.then;if(t instanceof o)return e._state=3,e._value=t,void u(e);if("function"==typeof r)return void s(n(r,t),e)}e._state=1,e._value=t,u(e)}catch(i){f(e,i)}}function f(e,t){e._state=2,e._value=t,u(e)}function u(e){2===e._state&&0===e._deferreds.length&&a(function(){e._handled||d(e._value)},1);for(var t=0,n=e._deferreds.length;n>t;t++)r(e,e._deferreds[t]);e._deferreds=null}function c(e,t,n){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=n}function s(e,t){var n=!1;try{e(function(e){n||(n=!0,i(t,e))},function(e){n||(n=!0,f(t,e))})}catch(o){if(n)return;n=!0,f(t,o)}}var l=setTimeout,a="function"==typeof setImmediate&&setImmediate||function(e){l(e,1)},d=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.then=function(e,n){var i=new o(t);return r(this,new c(e,n,i)),i},o.all=function(e){var t=Array.prototype.slice.call(e);return new o(function(e,n){function o(i,f){try{if(f&&("object"==typeof f||"function"==typeof f)){var u=f.then;if("function"==typeof u)return void u.call(f,function(e){o(i,e)},n)}t[i]=f,0===--r&&e(t)}catch(c){n(c)}}if(0===t.length)return e([]);for(var r=t.length,i=0;i<t.length;i++)o(i,t[i])})},o.resolve=function(e){return e&&"object"==typeof e&&e.constructor===o?e:new o(function(t){t(e)})},o.reject=function(e){return new o(function(t,n){n(e)})},o.race=function(e){return new o(function(t,n){for(var o=0,r=e.length;r>o;o++)e[o].then(t,n)})},o._setImmediateFn=function(e){a=e},o._setUnhandledRejectionFn=function(e){d=e},"undefined"!=typeof module&&module.exports?module.exports=o:e.Promise||(e.Promise=o)}(this);
!function(t){function e(){}function n(t,e){return function(){t.apply(e,arguments)}}function o(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],s(t,this)}function r(t,e){for(;3===t._state;)t=t._value;return 0===t._state?void t._deferreds.push(e):(t._handled=!0,void a(function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null===n)return void(1===t._state?i:f)(e.promise,t._value);var o;try{o=n(t._value)}catch(r){return void f(e.promise,r)}i(e.promise,o)}))}function i(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var r=e.then;if(e instanceof o)return t._state=3,t._value=e,void u(t);if("function"==typeof r)return void s(n(r,e),t)}t._state=1,t._value=e,u(t)}catch(i){f(t,i)}}function f(t,e){t._state=2,t._value=e,u(t)}function u(t){2===t._state&&0===t._deferreds.length&&a(function(){t._handled||d(t._value)});for(var e=0,n=t._deferreds.length;n>e;e++)r(t,t._deferreds[e]);t._deferreds=null}function c(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function s(t,e){var n=!1;try{t(function(t){n||(n=!0,i(e,t))},function(t){n||(n=!0,f(e,t))})}catch(o){if(n)return;n=!0,f(e,o)}}var l=setTimeout,a="function"==typeof setImmediate&&setImmediate||function(t){l(t,1)},d=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};o.prototype["catch"]=function(t){return this.then(null,t)},o.prototype.then=function(t,n){var o=new this.constructor(e);return r(this,new c(t,n,o)),o},o.all=function(t){var e=Array.prototype.slice.call(t);return new o(function(t,n){function o(i,f){try{if(f&&("object"==typeof f||"function"==typeof f)){var u=f.then;if("function"==typeof u)return void u.call(f,function(t){o(i,t)},n)}e[i]=f,0===--r&&t(e)}catch(c){n(c)}}if(0===e.length)return t([]);for(var r=e.length,i=0;i<e.length;i++)o(i,e[i])})},o.resolve=function(t){return t&&"object"==typeof t&&t.constructor===o?t:new o(function(e){e(t)})},o.reject=function(t){return new o(function(e,n){n(t)})},o.race=function(t){return new o(function(e,n){for(var o=0,r=t.length;r>o;o++)t[o].then(e,n)})},o._setImmediateFn=function(t){a=t},o._setUnhandledRejectionFn=function(t){d=t},"undefined"!=typeof module&&module.exports?module.exports=o:t.Promise||(t.Promise=o)}(this);

@@ -5,3 +5,3 @@ <a href="http://promises-aplus.github.com/promises-spec">

</a>
# Promise
# Promise Polyfill
[![travis][travis-image]][travis-url]

@@ -22,12 +22,7 @@

## Downloads
- [Promise](https://raw.github.com/taylorhakes/promise-polyfill/master/promise.js)
- [Promise-min](https://raw.github.com/taylorhakes/promise-polyfill/master/promise.min.js)
### Node
### NPM Use
```
npm install promise-polyfill
npm install promise-polyfill --save-exact
```
### Bower
### Bower Use
```

@@ -37,2 +32,7 @@ bower install promise-polyfill

## Downloads
- [Promise](https://raw.github.com/taylorhakes/promise-polyfill/master/promise.js)
- [Promise-min](https://raw.github.com/taylorhakes/promise-polyfill/master/promise.min.js)
## Simple use

@@ -39,0 +39,0 @@ ```js

@@ -18,7 +18,7 @@ var Promise = require('../promise');

var spy = sinon.spy();
function immediateFn(fn) {
spy();
fn();
};
}
Promise._setImmediateFn(immediateFn);

@@ -36,3 +36,3 @@ var done = false;

var spy1 = sinon.spy();
function immediateFn1(fn) {

@@ -42,5 +42,5 @@ spy1();

}
var spy2 = sinon.spy();
function immediateFn2(fn) {

@@ -50,3 +50,3 @@ spy2();

}
Promise._setImmediateFn(immediateFn1);

@@ -144,3 +144,3 @@ var done = false;

prom.catch(function() {
});

@@ -160,2 +160,35 @@ setTimeout(function() {

});
});

describe('Promise.prototype.then', function() {
var spy,
SubClass;
beforeEach(function() {
spy = sinon.spy();
SubClass = function() {
spy();
Promise.apply(this, arguments);
};
function __() { this.constructor = SubClass; }
__.prototype = Promise.prototype;
SubClass.protptype = new __();
SubClass.prototype.then = function() {
return Promise.prototype.then.apply(this, arguments);
};
});
it('subclassed Promise resolves to subclass', function() {
var prom = new SubClass(function(resolve) {
resolve();
}).then(function() {}, function() {});
assert(spy.calledTwice);
assert(prom instanceof SubClass);
});
it('subclassed Promise rejects to subclass', function() {
var prom = new SubClass(function(_, reject) {
reject();
}).then(function() {}, function() {});
assert(spy.calledTwice);
assert(prom instanceof SubClass);
});
});
});

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