From 049ec5cb21e6a43b66cff27c331570e5f07c9cea Mon Sep 17 00:00:00 2001 From: Taylor Hakes Date: Mon, 30 Mar 2015 18:23:30 -0400 Subject: [PATCH] Fixed an error with web workers not having window --- Promise.js | 4 +++- Promise.min.js | 4 ++-- bower.json | 2 +- package.json | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Promise.js b/Promise.js index 9c55485..1c3f7cc 100644 --- a/Promise.js +++ b/Promise.js @@ -3,8 +3,10 @@ if (typeof window === 'object' && window) { root = window; - } else { + } else if (typeof global === 'object' && global) { root = global; + } else { + root = {}; } // Use polyfill for setImmediate for performance gains diff --git a/Promise.min.js b/Promise.min.js index f3ee36e..b28d2bb 100644 --- a/Promise.min.js +++ b/Promise.min.js @@ -1,2 +1,2 @@ -/*! promise-polyfill 2.0.0 */ -!function(){function a(a,b){return function(){a.apply(b,arguments)}}function b(b){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof b)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],h(b,a(d,this),a(e,this))}function c(a){var b=this;return null===this._state?void this._deferreds.push(a):void j(function(){var c=b._state?a.onFulfilled:a.onRejected;if(null===c)return void(b._state?a.resolve:a.reject)(b._value);var d;try{d=c(b._value)}catch(e){return void a.reject(e)}a.resolve(d)})}function d(b){try{if(b===this)throw new TypeError("A promise cannot be resolved with itself.");if(b&&("object"==typeof b||"function"==typeof b)){var c=b.then;if("function"==typeof c)return void h(a(c,b),a(d,this),a(e,this))}this._state=!0,this._value=b,f.call(this)}catch(g){e.call(this,g)}}function e(a){this._state=!1,this._value=a,f.call(this)}function f(){for(var a=0,b=this._deferreds.length;b>a;a++)c.call(this,this._deferreds[a]);this._deferreds=null}function g(a,b,c,d){this.onFulfilled="function"==typeof a?a:null,this.onRejected="function"==typeof b?b:null,this.resolve=c,this.reject=d}function h(a,b,c){var d=!1;try{a(function(a){d||(d=!0,b(a))},function(a){d||(d=!0,c(a))})}catch(e){if(d)return;d=!0,c(e)}}var i;i="object"==typeof window&&window?window:global;var j=b.immediateFn||i.setImmediate||function(a){setTimeout(a,1)},k=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)};b.prototype["catch"]=function(a){return this.then(null,a)},b.prototype.then=function(a,d){var e=this;return new b(function(b,f){c.call(e,new g(a,d,b,f))})},b.all=function(){var a=Array.prototype.slice.call(1===arguments.length&&k(arguments[0])?arguments[0]:arguments);return new b(function(b,c){function d(f,g){try{if(g&&("object"==typeof g||"function"==typeof g)){var h=g.then;if("function"==typeof h)return void h.call(g,function(a){d(f,a)},c)}a[f]=g,0===--e&&b(a)}catch(i){c(i)}}if(0===a.length)return b([]);for(var e=a.length,f=0;fd;d++)a[d].then(b,c)})},"undefined"!=typeof module&&module.exports?module.exports=b:i.Promise||(i.Promise=b)}(); \ No newline at end of file +/*! promise-polyfill 2.0.1 */ +!function(){function a(a,b){return function(){a.apply(b,arguments)}}function b(b){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof b)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],h(b,a(d,this),a(e,this))}function c(a){var b=this;return null===this._state?void this._deferreds.push(a):void j(function(){var c=b._state?a.onFulfilled:a.onRejected;if(null===c)return void(b._state?a.resolve:a.reject)(b._value);var d;try{d=c(b._value)}catch(e){return void a.reject(e)}a.resolve(d)})}function d(b){try{if(b===this)throw new TypeError("A promise cannot be resolved with itself.");if(b&&("object"==typeof b||"function"==typeof b)){var c=b.then;if("function"==typeof c)return void h(a(c,b),a(d,this),a(e,this))}this._state=!0,this._value=b,f.call(this)}catch(g){e.call(this,g)}}function e(a){this._state=!1,this._value=a,f.call(this)}function f(){for(var a=0,b=this._deferreds.length;b>a;a++)c.call(this,this._deferreds[a]);this._deferreds=null}function g(a,b,c,d){this.onFulfilled="function"==typeof a?a:null,this.onRejected="function"==typeof b?b:null,this.resolve=c,this.reject=d}function h(a,b,c){var d=!1;try{a(function(a){d||(d=!0,b(a))},function(a){d||(d=!0,c(a))})}catch(e){if(d)return;d=!0,c(e)}}var i;i="object"==typeof window&&window?window:"object"==typeof global&&global?global:{};var j=b.immediateFn||i.setImmediate||function(a){setTimeout(a,1)},k=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)};b.prototype["catch"]=function(a){return this.then(null,a)},b.prototype.then=function(a,d){var e=this;return new b(function(b,f){c.call(e,new g(a,d,b,f))})},b.all=function(){var a=Array.prototype.slice.call(1===arguments.length&&k(arguments[0])?arguments[0]:arguments);return new b(function(b,c){function d(f,g){try{if(g&&("object"==typeof g||"function"==typeof g)){var h=g.then;if("function"==typeof h)return void h.call(g,function(a){d(f,a)},c)}a[f]=g,0===--e&&b(a)}catch(i){c(i)}}if(0===a.length)return b([]);for(var e=a.length,f=0;fd;d++)a[d].then(b,c)})},"undefined"!=typeof module&&module.exports?module.exports=b:i.Promise||(i.Promise=b)}(); \ No newline at end of file diff --git a/bower.json b/bower.json index 7374af1..dbc5e95 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "promise-polyfill", - "version": "2.0.0", + "version": "2.0.1", "homepage": "https://github.com/taylorhakes/promise-polyfill", "authors": [ "Taylor Hakes" diff --git a/package.json b/package.json index 75afee0..ebef7a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "promise-polyfill", - "version": "2.0.0", + "version": "2.0.1", "description": "Lightweight promise polyfill. A+ compliant", "main": "Promise.js", "scripts": {