require-polyfills
Version:
Collection of polyfils that load automatically using require-bundle-js by detecting what is missing in the browser.
3 lines (2 loc) • 3.28 kB
JavaScript
!function(e){("object"!=typeof exports||"undefined"==typeof module)&&"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";function e(n){var t=this.constructor;return this.then(function(e){return t.resolve(n()).then(function(){return e})},function(e){return t.resolve(n()).then(function(){return t.reject(e)})})}var n=setTimeout;function c(e){return Boolean(e&&void 0!==e.length)}function o(){}function i(e){if(!(this instanceof i))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(t,o){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,i._immediateFn(function(){var e,n=1===t._state?o.onFulfilled:o.onRejected;if(null!==n){try{e=n(t._value)}catch(e){return void u(o.promise,e)}f(o.promise,e)}else(1===t._state?f:u)(o.promise,t._value)})):t._deferreds.push(o)}function f(n,e){try{if(e===n)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var t=e.then;if(e instanceof i)return n._state=3,n._value=e,void a(n);if("function"==typeof t)return void s((o=t,r=e,function(){o.apply(r,arguments)}),n)}n._state=1,n._value=e,a(n)}catch(e){u(n,e)}var o,r}function u(e,n){e._state=2,e._value=n,a(e)}function a(e){2===e._state&&0===e._deferreds.length&&i._immediateFn(function(){e._handled||i._unhandledRejectionFn(e._value)});for(var n=0,t=e._deferreds.length;n<t;n++)r(e,e._deferreds[n]);e._deferreds=null}function l(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}function s(e,n){var t=!1;try{e(function(e){t||(t=!0,f(n,e))},function(e){t||(t=!0,u(n,e))})}catch(e){if(t)return;t=!0,u(n,e)}}i.prototype.catch=function(e){return this.then(null,e)},i.prototype.then=function(e,n){var t=new this.constructor(o);return r(this,new l(e,n,t)),t},i.prototype.finally=e,i.all=function(n){return new i(function(r,i){if(!c(n))return i(new TypeError("Promise.all accepts an array"));var f=Array.prototype.slice.call(n);if(0===f.length)return r([]);var u=f.length;for(var e=0;e<f.length;e++)!function n(t,e){try{if(e&&("object"==typeof e||"function"==typeof e)){var o=e.then;if("function"==typeof o)return void o.call(e,function(e){n(t,e)},i)}f[t]=e,0==--u&&r(f)}catch(e){i(e)}}(e,f[e])})},i.resolve=function(n){return n&&"object"==typeof n&&n.constructor===i?n:new i(function(e){e(n)})},i.reject=function(t){return new i(function(e,n){n(t)})},i.race=function(r){return new i(function(e,n){if(!c(r))return n(new TypeError("Promise.race accepts an array"));for(var t=0,o=r.length;t<o;t++)i.resolve(r[t]).then(e,n)})},i._immediateFn="function"==typeof setImmediate?function(e){setImmediate(e)}:function(e){n(e,0)},i._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var t=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();"Promise"in t?t.Promise.prototype.finally||(t.Promise.prototype.finally=e):t.Promise=i});
//# sourceMappingURL=maps/polyfill-Promise.min.js.map