1 |
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.ES6Promise=e()}(this,function(){function t(t){return"function"==typeof t}function e(){return function(){return process.nextTick(s)}}function n(){return"undefined"!=typeof P?function(){P(s)}:i()}function r(){var t=0,e=new k(s),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function o(){var t=new MessageChannel;return t.port1.onmessage=s,function(){return t.port2.postMessage(0)}}function i(){var t=setTimeout;return function(){return t(s,1)}}function s(){for(var t=0;M>t;t+=2)(0,Y[t])(Y[t+1]),Y[t]=void 0,Y[t+1]=void 0;M=0}function u(){try{var t=Function("return this")().require("vertx");return P=t.runOnLoop||t.runOnContext,n()}catch(e){return i()}}function c(t,e){var n=this,r=new this.constructor(f);void 0===r[D]&&j(r);var o=n._state;if(o){var i=arguments[o-1];C(function(){return A(o,r,i,n._result)})}else g(n,r,t,e);return r}function a(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=new this(f);return _(e,t),e}function f(){}function l(t){try{return t.then}catch(e){return U.error=e,U}}function h(t,e,n,r){try{t.call(e,n,r)}catch(o){return o}}function p(t,e,n){C(function(t){var r=!1,o=h(n,e,function(n){r||(r=!0,e!==n?_(t,n):m(t,n))},function(e){r||(r=!0,b(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&o&&(r=!0,b(t,o))},t)}function d(t,e){e._state===L?m(t,e._result):e._state===N?b(t,e._result):g(e,void 0,function(e){return _(t,e)},function(e){return b(t,e)})}function v(e,n,r){n.constructor===e.constructor&&r===c&&n.constructor.resolve===a?d(e,n):r===U?(b(e,U.error),U.error=null):void 0===r?m(e,n):t(r)?p(e,n,r):m(e,n)}function _(t,e){if(t===e)b(t,new TypeError("You cannot resolve a promise with itself"));else{var n=typeof e;null===e||"object"!==n&&"function"!==n?m(t,e):v(t,e,l(e))}}function y(t){t._onerror&&t._onerror(t._result),w(t)}function m(t,e){t._state===K&&(t._result=e,t._state=L,0!==t._subscribers.length&&C(w,t))}function b(t,e){t._state===K&&(t._state=N,t._result=e,C(y,t))}function g(t,e,n,r){var o=t._subscribers,i=o.length;t._onerror=null,o[i]=e,o[i+L]=n,o[i+N]=r,0===i&&t._state&&C(w,t)}function w(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r=void 0,o=void 0,i=t._result,s=0;s<e.length;s+=3)r=e[s],o=e[s+n],r?A(n,r,o,i):o(i);t._subscribers.length=0}}function A(e,n,r,o){var i=t(r),s=void 0,u=void 0,c=void 0,a=void 0;if(i){try{s=r(o)}catch(f){U.error=f,s=U}if(s===U?(a=!0,u=s.error,s.error=null):c=!0,n===s)return void b(n,new TypeError("A promises callback cannot return that same promise."))}else s=o,c=!0;n._state===K&&(i&&c?_(n,s):a?b(n,u):e===L?m(n,s):e===N&&b(n,s))}function S(t,e){try{e(function(e){_(t,e)},function(e){b(t,e)})}catch(n){b(t,n)}}function j(t){t[D]=W++,t._state=void 0,t._result=void 0,t._subscribers=[]}var E=void 0,T=E=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},M=0,P=void 0,x=void 0,C=function(t,e){Y[M]=t,Y[M+1]=e,M+=2,2===M&&(x?x(s):q())},O=(E="undefined"!=typeof window?window:void 0)||{},k=O.MutationObserver||O.WebKitMutationObserver,O="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),F="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,Y=Array(1e3),q=void 0,q=O?e():k?r():F?o():void 0===E&&"function"==typeof require?u():i(),D=Math.random().toString(36).substring(2),K=void 0,L=1,N=2,U={error:null},W=0,z=function(){function t(t,e){this._instanceConstructor=t,this.promise=new t(f),this.promise[D]||j(this.promise),T(e)?(this._remaining=this.length=e.length,this._result=Array(this.length),0===this.length?m(this.promise,this._result):(this.length=this.length||0,this._enumerate(e),0===this._remaining&&m(this.promise,this._result))):b(this.promise,Error("Array Methods must be provided an Array"))}return t.prototype._enumerate=function(t){for(var e=0;this._state===K&&e<t.length;e++)this._eachEntry(t[e],e)},t.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;r===a?(r=l(t),r===c&&t._state!==K?this._settledAt(t._state,e,t._result):"function"!=typeof r?(this._remaining--,this._result[e]=t):n===B?(n=new n(f),v(n,t,r),this._willSettleAt(n,e)):this._willSettleAt(new n(function(e){return e(t)}),e)):this._willSettleAt(r(t),e)},t.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===K&&(this._remaining--,t===N?b(r,n):this._result[e]=n),0===this._remaining&&m(r,this._result)},t.prototype._willSettleAt=function(t,e){var n=this;g(t,void 0,function(t){return n._settledAt(L,e,t)},function(t){return n._settledAt(N,e,t)})},t}(),B=function(){function e(t){if(this[D]=W++,this._result=this._state=void 0,this._subscribers=[],f!==t){if("function"!=typeof t)throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof e))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");S(this,t)}}return e.prototype["catch"]=function(t){return this.then(null,t)},e.prototype["finally"]=function(e){var n=this.constructor;return t(e)?this.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){throw t})}):this.then(e,e)},e}();return B.prototype.then=c,B.all=function(t){return new z(this,t).promise},B.race=function(t){var e=this;return new e(T(t)?function(n,r){for(var o=t.length,i=0;o>i;i++)e.resolve(t[i]).then(n,r)}:function(t,e){return e(new TypeError("You must pass an array to race."))})},B.resolve=a,B.reject=function(t){var e=new this(f);return b(e,t),e},B._setScheduler=function(t){x=t},B._setAsap=function(t){C=t},B._asap=C,B.polyfill=function(){var t=void 0;if("undefined"!=typeof global)t=global;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;if(n){var r=null;try{r=Object.prototype.toString.call(n.resolve())}catch(o){}if("[object Promise]"===r&&!n.cast)return}t.Promise=B},B.Promise=B});
|