/
index.min.js
1 lines (1 loc) · 2.06 KB
/
index.min.js
1
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).PromisePolyfill=n()}(this,function(){"use strict";function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var a="pending",s="fulfilled",l="rejected",y=void 0===y?setTimeout:y;function d(t){this.status=a,this.value=void 0,this.reason=void 0,this.onResolvedCallback=[],this.onRejectedCallback=[];var e=this;function n(n){y(function(){if(e.status===a){e.status=l,e.reason=n;for(var t=0;t<e.onRejectedCallback.length;t++)e.onRejectedCallback[t](e.reason)}})}try{t(function(n){y(function(){if(e.status===a){e.status=s,e.value=n;for(var t=0;t<e.onResolvedCallback.length;t++)e.onResolvedCallback[t](e.value)}})},n)}catch(t){n(t)}}function h(n,t,e,o){if(n===t)return o(new TypeError("Cycle Chain Detected in promise"));if(t instanceof d)return t.status===a?t.then(function(t){return h(n,t,e,o)},o):t.then(e,o);if((null===t||"object"!==i(t))&&"function"!=typeof t)return e(t);var r=!1;try{var u=t.then;if("function"!=typeof u)return e(t);u.call(t,function(t){if(!r)return r=!0,h(n,t,e,o)},function(t){if(!r)return r=!0,o(t)})}catch(t){return r?void 0:(r=!0,o(t))}}return d.prototype.then=function(r,u){var i=this;if(r="function"==typeof r?r:function(t){return t},u="function"==typeof u?u:function(t){throw t},i.status===a){var f=new d(function(e,o){i.onResolvedCallback.push(function(t){try{var n=r(t);return h(f,n,e,o)}catch(t){return o(t)}}),i.onRejectedCallback.push(function(t){try{var n=u(t);return h(f,n,e,o)}catch(t){return o(t)}})});return f}if(i.status===s){var o=new d(function(n,e){y(function(){try{var t=r(i.value);return h(o,t,n,e)}catch(t){return e(t)}})});return o}if(i.status===l){var c=new d(function(n,e){y(function(){try{var t=u(i.reason);return h(c,t,n,e)}catch(t){return e(t)}})});return c}},"undefined"==typeof Promise?d:Promise});