anxiety/scripts/lib/rsvp.min.js

1 line
15 KiB
JavaScript
Raw Normal View History

2019-02-18 20:59:10 +00:00
(function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.RSVP={})})(this,function(t){"use strict";function e(t){var e=t._promiseCallbacks;e||(e=t._promiseCallbacks={});return e}function r(t,e){if(2!==arguments.length)return dt[t];dt[t]=e}function n(){setTimeout(function(){for(var t=0;t<vt.length;t++){var e=vt[t],r=e.payload;r.guid=r.key+r.id;r.childGuid=r.key+r.childId;r.error&&(r.stack=r.error.stack);dt.trigger(e.name,e.payload)}vt.length=0},50)}function o(t,e,r){1===vt.push({name:t,payload:{key:e._guidKey,id:e._id,eventName:t,detail:e._result,childId:r&&r._id,label:e._label,timeStamp:Date.now(),error:dt["instrument-with-stack"]?new Error(e._label):null}})&&n()}function i(t,e){var r=this;if(t&&"object"==typeof t&&t.constructor===r)return t;var n=new r(c,e);_(n,t);return n}function s(){return new TypeError("A promises callback cannot return that same promise.")}function u(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}function c(){}function a(t){try{return t.then}catch(e){gt.error=e;return gt}}function f(){try{var t=jt;jt=null;return t.apply(this,arguments)}catch(e){gt.error=e;return gt}}function l(t){jt=t;return f}function h(t,e,r){dt.async(function(t){var n=!1,o=l(r).call(e,function(r){if(!n){n=!0;e===r?v(t,r):_(t,r)}},function(e){if(!n){n=!0;m(t,e)}},"Settle: "+(t._label||" unknown promise"));if(!n&&o===gt){n=!0;var i=gt.error;gt.error=null;m(t,i)}},t)}function p(t,e){if(e._state===bt)v(t,e._result);else if(e._state===wt){e._onError=null;m(t,e._result)}else b(e,void 0,function(r){e===r?v(t,r):_(t,r)},function(e){return m(t,e)})}function y(t,e,r){var n=e.constructor===t.constructor&&r===O&&t.constructor.resolve===i;if(n)p(t,e);else if(r===gt){var o=gt.error;gt.error=null;m(t,o)}else"function"==typeof r?h(t,e,r):v(t,e)}function _(t,e){t===e?v(t,e):u(e)?y(t,e,a(e)):v(t,e)}function d(t){t._onError&&t._onError(t._result);w(t)}function v(t,e){if(t._state===mt){t._result=e;t._state=bt;0===t._subscribers.length?dt.instrument&&o("fulfilled",t):dt.async(w,t)}}function m(t,e){if(t._state===mt){t._state=wt;t._result=e;dt.async(d,t)}}function b(t,e,r,n){var o=t._subscribers,i=o.length;t._onError=null;o[i]=e;o[i+bt]=r;o[i+wt]=n;0===i&&t._state&&dt.async(w,t)}function w(t){var e=t._subscribers,r=t._state;dt.instrument&&o(r===bt?"fulfilled":"rejected",t);if(0!==e.length){for(var n=void 0,i=void 0,s=t._result,u=0;u<e.length;u+=3){n=e[u];i=e[u+r];n?g(r,n,i,s):i(s)}t._subscribers.length=0}}function g(t,e,r,n){var o="function"==typeof r,i=void 0;i=o?l(r)(n):n;if(e._state!==mt);else if(i===e)m(e,s());else if(i===gt){var u=gt.error;gt.error=null;m(e,u)}else o?_(e,i):t===bt?v(e,i):t===wt&&m(e,i)}function j(t,e){var r=!1;try{e(function(e){if(!r){r=!0;_(t,e)}},function(e){if(!r){r=!0;m(t,e)}})}catch(n){m(t,n)}}function O(t,e,r){var n=this,i=n._state;if(i===bt&&!t||i===wt&&!e){dt.instrument&&o("chained",n,n);return n}n._onError=null;var s=new n.constructor(c,r),u=n._result;dt.instrument&&o("chained",n,s);if(i===mt)b(n,s,t,e);else{var a=i===bt?t:e;dt.async(function(){return g(i,s,a,u)})}return s}function A(t,e,r){this._remaining--;t===bt?this._result[e]={state:"fulfilled",value:r}:this._result[e]={state:"rejected",reason:r}}function E(t,e){return Array.isArray(t)?new Ot(this,t,(!0),e).promise:this.reject(new TypeError("Promise.all must be called with an array"),e)}function T(t,e){var r=this,n=new r(c,e);if(!Array.isArray(t)){m(n,new TypeError("Promise.race must be called with an array"));return n}for(var o=0;n._state===mt&&o<t.length;o++)b(r.resolve(t[o]),void 0,function(t){return _(n,t)},function(t){return m(n,t)});return n}function P(t,e){var r=this,n=new r(c,e);m(n,t);return n}function S(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function R(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function x(t,e){for(var r={},n=t.length,o=new Array(n),i=0;i<n;i++)o[i]=t[i];for(var s=0;s<e.l