-
Notifications
You must be signed in to change notification settings - Fork 2
/
SPromiseMeSpeed.min.js
16 lines (16 loc) · 7.11 KB
/
SPromiseMeSpeed.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'use strict';var G="function"==typeof Object.defineProperties?Object.defineProperty:function(p,r,t){p!=Array.prototype&&p!=Object.prototype&&(p[r]=t.value)};function L(p){p=["object"==typeof globalThis&&globalThis,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global,p];for(var r=0;r<p.length;++r){var t=p[r];if(t&&t.Math==Math)return t}throw Error("Cannot find global object");}var M=L(this);function Q(){Q=function(){};M.Symbol||(M.Symbol=R)}
function S(p,r){this.a=p;G(this,"description",{configurable:!0,writable:!0,value:r})}S.prototype.toString=function(){return this.a};var R=function(){function p(t){if(this instanceof p)throw new TypeError("Symbol is not a constructor");return new S("jscomp_symbol_"+(t||"")+"_"+r++,t)}var r=0;return p}();
(function(p){function r(b){b()}function t(b){b(this)}function H(){if(y){do u=!1,D.shift()();while(--y)}u=!1}function B(b,k,d){this.then=b;this["catch"]=k;this["finally"]=d}function v(b){function k(a){0===h&&(F(a)?a.then(k,d):(g=a,h=2,null!==e&&("function"===typeof e?e(a):e.forEach(t,a),e=null),c=null,null!==l&&("function"===typeof l?l():l.forEach(r),l=null)))}function d(a){0===h&&(g=a,h=1,null!==c&&("function"===typeof c?c(a):c.forEach(t,a),c=null),e=null,null!==l&&("function"===typeof l?l():l.forEach(r),
l=null))}var g,h=0,e=null,c=null,l=null,f=new B(function(a,m){void 0!=a&&"function"!==typeof a&&console.warn(Object.prototype.toString.call(a)+" is not a valid function to be called after a successful promise");void 0!=m&&"function"!==typeof m&&console.warn(Object.prototype.toString.call(m)+" is not a valid function to be called after a rejected promise");if(0===h)return I(function(w,C){var z="function"===typeof a?function(){w(a(g))}:w,J="function"===typeof m?function(){C(m(g))}:C;null!==e?"function"===
typeof e?e=[e,z]:e.push(z):e=z;null!==c?"function"===typeof c?c=[c,J]:c.push(J):c=J});try{return 2===h?"function"===typeof a?E(a(g)):x:"function"===typeof m?q(m(g)):x}catch(w){return q(w)}},function(a){void 0!=a&&"function"!==typeof a&&console.warn(Object.prototype.toString.call(a)+" is not a valid function to be called after a rejected promise");if(0===h)return I(function(m){null!==c?"function"===typeof c?c=[c,function(){m(a(g))}]:c.push(function(){m(a(g))}):c=function(){m(a(g))};null!==e?"function"===
typeof e?e=[e,m]:e.push(m):e=m});if(2===h)return E(g);try{return"function"===typeof a?E(a(g)):x}catch(m){return q(m)}},function(a){void 0!=a&&"function"!==typeof a&&console.warn(Object.prototype.toString.call(a)+" is not a valid function to be called 'finally' after promise");if(0===h)null!==l?"function"===typeof l?l=[l,a]:l.push(a):l=a;else try{a()}catch(m){return q(m)}return f});if(!0===u)D.push(function(){try{b(k,d)}catch(a){d(a)}}),y=y+1|0;else{n=n+1|0;if(u=128===n)try{b(k,d)}catch(a){d(a)}else{try{b(k,
d)}catch(a){d(a)}!0===u&&1===n&&H()}n=n-1|0}return f}function I(b){function k(f){0===g&&(d=f,g=1,null!==e&&("function"===typeof e?e(f):e.forEach(t,f),e=null),h=null,null!==c&&("function"===typeof c?c():c.forEach(r),c=null))}var d,g=0,h=null,e=null,c=null,l=new B(function(f,a){f&&"function"!==typeof f&&console.error(Object.prototype.toString.call(f)+" is not a valid function to be called after a successful promise");a&&"function"!==typeof a&&console.error(Object.prototype.toString.call(a)+" is not a valid function to be called after a rejected promise");
if(0===g)return v(function(m,w){var C="function"===typeof f?function(){m(f(d))}:m,z="function"===typeof a?function(){w(a(d))}:w;null!==h?"function"===typeof h?h=[h,C]:h.push(C):h=C;null!==e?"function"===typeof e?e=[e,z]:e.push(z):e=z});try{return 2===g?"function"===typeof f?A(f(d)):x:"function"===typeof a?q(a(d)):x}catch(m){return q(m)}},function(f){f&&"function"!==typeof f&&console.error(Object.prototype.toString.call(f)+" is not a valid function to be called after a rejected promise");if(0===g)return v(function(a){null!==
e?"function"===typeof e?e=[e,function(){a(f(d))}]:e.push(function(){a(f(d))}):e=function(){a(f(d))};null!==h?"function"===typeof h?h=[h,a]:h.push(a):h=a});if(2===g)return A(d);try{return"function"===typeof f?A(f(d)):x}catch(a){return q(a)}},function(f){"function"!==typeof f&&console.error(Object.prototype.toString.call(f)+" is not a valid function to be called 'finally' after promise");0===g?null!==c?"function"===typeof c?c=[c,f]:c.push(f):c=f:f();return l});try{b(function m(a){0===g&&(F(a)?a.then(m,
k):(d=a,g=2,null!==h&&("function"===typeof h?h(a):h.forEach(t,a),h=null),null!==c&&("function"===typeof c?c():c.forEach(r),c=null),e=null))},k)}catch(f){k(f)}return l}function A(b){if("object"===typeof b&&null!==b&&"function"===typeof b.then)return b;var k=new B(function(d){if("function"!==typeof d)return k;if(!0===u)return I(function(h,e){D.push(function(){try{h(d(b))}catch(c){e(c)}});y=y+1|0});n=n+1|0;var g=null;try{(u=128===n)?D.push(function(){d(b)}):(g=d(b),!0===u&&1===n&&H())}catch(h){return q(h)}finally{n=
n-1|0}return E(g)},function(){return k},function(d){if("function"===typeof d)if(!0===u)D.push(d),y=y+1|0;else{n=n+1|0;try{(u=128===n)?(d(),u=!1):(d(),!0===u&&1===n&&H())}catch(g){return q(g)}finally{n=n-1|0}}return k});return k}function E(b){if("object"===typeof b&&null!==b&&"function"===typeof b.then)return b;var k=new B(function(d){try{return"function"===typeof d?A(d(b)):x}catch(g){return q(g)}},function(){return k},function(d){try{"function"===typeof d&&d()}catch(g){return q(g)}return k});return k}
function q(b){if("object"===typeof b&&null!==b&&"function"===typeof b.then)return b;var k=new B(function(d,g){try{return"function"===typeof g?A(g(b)):x}catch(h){return q(h)}},function(d){try{return"function"===typeof d?A(d(b)):x}catch(g){return q(g)}},function(d){try{"function"===typeof d&&d()}catch(g){return q(g)}return k});return k}function N(b,k){if("object"!==typeof b||"function"!==typeof b.forEach)return console.error(Object.prototype.toString.call(b)+" is not a valid iterable array of promises. If you are using an array-like object, you must call Array.prototype.slice.call on the object before passing it to SPromise."+
k),x}function K(b){return b===p?b.b=v:v}var D=[],F=v.isPromise=function(b){return"object"===typeof b&&null!==b&&"function"===typeof b.then},n=0,u=!1,y=0;Q();Q();var O=""+void 0!==typeof Symbol&&Symbol.toStringTag,x=A(void 0);"symbol"===typeof O&&(B.prototype[O]="Promise");v.resolve=E;v.reject=q;var P=!1;v.race=function(b){N(b,"race");P||b.length||(P=!0,console.warn(Object.prototype.toString.call(b)+" is an empty array of promises passed to SPromise"));return v(function(k,d){function g(f){e&&(e=
0,k(f))}function h(f){e&&(e=0,d(f))}for(var e=1,c=0,l;c<b.length&&e;c=c+1|0)F(l=b[c])?l.then(g,h):g(l)})};v.all=function(b){N(b,"all");return v(function(k,d){function g(m){a.then(function(w){l[m|0]=w;c=c-1|0;0===c&&k(l)},function(w){0<c&&(c=-1,d(w))})}for(var h=null,e=b.length|0,c=e,l=[],f=0,a;f<e;f=f+1|0)F(a=b[f])?(l[f]=h,g(f)):(c=c-1|0,l[f]=h=a);0===c&&k(l)})};"object"===typeof exports&&""+void 0!==typeof module?module.exports=v:typeof define==typeof K&&"function"===typeof define&&define.amd?
define(K):K(p)})("object"==typeof self?self:"object"==typeof global?global:this);//AnonyCo
//# sourceMappingURL=https://cdn.jsdelivr.net/gh/AnonyCo/SPromiseMeSpeed/dist/SPromiseMeSpeed.min.js.map