promise-polyfill
Advanced tools
Comparing version 1.0.5 to 1.0.6
{ | ||
"name": "promise-polyfill", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Light weight promise polyfill. A+ compliant", | ||
@@ -5,0 +5,0 @@ "main": "Promise.js", |
(function(global) { | ||
if(global.Promise) return; | ||
if(typeof module !== 'undefined' && module.exports) { | ||
module.exports = Promise; | ||
} else { | ||
module.exports = global.Promise ? global.Promise : Promise; | ||
} else if (!global.Promise) { | ||
global.Promise = Promise; | ||
} | ||
var asap = (global && global.setImmediate) || function(fn){ setTimeout(fn, 0) }; | ||
var asap = global.setImmediate || function(fn){ setTimeout(fn, 0) }; | ||
function bind(fn, thisArg) { | ||
@@ -16,5 +14,7 @@ return function() { | ||
} | ||
function isArray(value) { | ||
return Array.isArray ? Array.isArray(value) : Object.prototype.toString.call(value) === "[object Array]" | ||
} | ||
function Promise(fn) { | ||
@@ -82,3 +82,2 @@ if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new') | ||
function Handler(onFulfilled, onRejected, resolve, reject){ | ||
@@ -175,4 +174,2 @@ this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null | ||
}; | ||
})(this); | ||
})(this); |
@@ -1,5 +0,5 @@ | ||
(function(e){function g(a,b){return function(){a.apply(b,arguments)}}function q(a){return Array.isArray?Array.isArray(a):"[object Array]"===Object.prototype.toString.call(a)}function c(a){if("object"!==typeof this)throw new TypeError("Promises must be constructed via new");if("function"!==typeof a)throw new TypeError("not a function");this._value=this._state=null;this._deferreds=[];l(a,g(m,this),g(h,this))}function n(a){var b=this;null===this._state?this._deferreds.push(a):r(function(){var f=b._state? | ||
a.onFulfilled:a.onRejected;if(null===f)(b._state?a.resolve:a.reject)(b._value);else{var d;try{d=f(b._value)}catch(c){a.reject(c);return}a.resolve(d)}})}function m(a){try{if(a===this)throw new TypeError("A promise cannot be resolved with itself.");if(a&&("object"===typeof a||"function"===typeof a)){var b=a.then;if("function"===typeof b){l(g(b,a),g(m,this),g(h,this));return}}this._state=!0;this._value=a;p.call(this)}catch(f){h.call(this,f)}}function h(a){this._state=!1;this._value=a;p.call(this)}function p(){for(var a= | ||
0,b=this._deferreds.length;a<b;a++)n.call(this,this._deferreds[a]);this._deferreds=null}function s(a,b,f,d){this.onFulfilled="function"===typeof a?a:null;this.onRejected="function"===typeof b?b:null;this.resolve=f;this.reject=d}function l(a,b,f){var d=!1;try{a(function(a){d||(d=!0,b(a))},function(a){d||(d=!0,f(a))})}catch(c){d||(d=!0,f(c))}}if(!e.Promise){"undefined"!==typeof module&&module.exports?module.exports=c:e.Promise=c;var r=e&&e.setImmediate||function(a){setTimeout(a,0)};c.prototype["catch"]= | ||
(function(g){function e(a,b){return function(){a.apply(b,arguments)}}function q(a){return Array.isArray?Array.isArray(a):"[object Array]"===Object.prototype.toString.call(a)}function c(a){if("object"!==typeof this)throw new TypeError("Promises must be constructed via new");if("function"!==typeof a)throw new TypeError("not a function");this._value=this._state=null;this._deferreds=[];l(a,e(m,this),e(h,this))}function n(a){var b=this;null===this._state?this._deferreds.push(a):r(function(){var f=b._state? | ||
a.onFulfilled:a.onRejected;if(null===f)(b._state?a.resolve:a.reject)(b._value);else{var d;try{d=f(b._value)}catch(c){a.reject(c);return}a.resolve(d)}})}function m(a){try{if(a===this)throw new TypeError("A promise cannot be resolved with itself.");if(a&&("object"===typeof a||"function"===typeof a)){var b=a.then;if("function"===typeof b){l(e(b,a),e(m,this),e(h,this));return}}this._state=!0;this._value=a;p.call(this)}catch(f){h.call(this,f)}}function h(a){this._state=!1;this._value=a;p.call(this)}function p(){for(var a= | ||
0,b=this._deferreds.length;a<b;a++)n.call(this,this._deferreds[a]);this._deferreds=null}function s(a,b,f,d){this.onFulfilled="function"===typeof a?a:null;this.onRejected="function"===typeof b?b:null;this.resolve=f;this.reject=d}function l(a,b,f){var d=!1;try{a(function(a){d||(d=!0,b(a))},function(a){d||(d=!0,f(a))})}catch(c){d||(d=!0,f(c))}}"undefined"!==typeof module&&module.exports?module.exports=g.Promise?g.Promise:c:g.Promise||(g.Promise=c);var r=g.setImmediate||function(a){setTimeout(a,0)};c.prototype["catch"]= | ||
function(a){return this.then(null,a)};c.prototype.then=function(a,b){var f=this;return new c(function(d,c){n.call(f,new s(a,b,d,c))})};c.all=function(){var a=Array.prototype.slice.call(1===arguments.length&&q(arguments[0])?arguments[0]:arguments);return new c(function(b,c){function d(e,k){try{if(k&&("object"===typeof k||"function"===typeof k)){var h=k.then;if("function"===typeof h){h.call(k,function(a){d(e,a)},c);return}}a[e]=k;0===--g&&b(a)}catch(l){c(l)}}if(0===a.length)return b([]);for(var g=a.length, | ||
e=0;e<a.length;e++)d(e,a[e])})};c.resolve=function(a){return new c(function(b){b(a)})};c.reject=function(a){return new c(function(b,c){c(a)})};c.race=function(a){return new c(function(b,c){a.map(function(a){a.then(b,c)})})}}})(this); | ||
e=0;e<a.length;e++)d(e,a[e])})};c.resolve=function(a){return new c(function(b){b(a)})};c.reject=function(a){return new c(function(b,c){c(a)})};c.race=function(a){return new c(function(b,c){a.map(function(a){a.then(b,c)})})}})(this); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9956
176