Skip to content

Instantly share code, notes, and snippets.

@NikolayMakhonin
Created February 12, 2020 08:52
Show Gist options
  • Save NikolayMakhonin/7af1341897aa5a744d528fa37ab8c31e to your computer and use it in GitHub Desktop.
Save NikolayMakhonin/7af1341897aa5a744d528fa37ab8c31e to your computer and use it in GitHub Desktop.
DependentFunc (test)
var DependentFunc=function(t){"use strict";var r;(function(t){var r=function(t){var r,e=Object.prototype,n=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",a=o.toStringTag||"@@toStringTag";function s(t,r,e,n){var o=r&&r.prototype instanceof y?r:y,i=Object.create(o.prototype),u=new O(n||[]);return i._invoke=function(t,r,e){var n=c;return function(o,i){if(n===h)throw new Error("Generator is already running");if(n===v){if("throw"===o)throw i;return A()}for(e.method=o,e.arg=i;;){var u=e.delegate;if(u){var a=x(u,e);if(a){if(a===p)continue;return a}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if(n===c)throw n=v,e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n=h;var s=l(t,r,e);if("normal"===s.type){if(n=e.done?v:f,s.arg===p)continue;return{value:s.arg,done:e.done}}"throw"===s.type&&(n=v,e.method="throw",e.arg=s.arg)}}}(t,e,u),i}function l(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var c="suspendedStart",f="suspendedYield",h="executing",v="completed",p={};function y(){}function d(){}function m(){}var b={};b[i]=function(){return this};var w=Object.getPrototypeOf,g=w&&w(w(R([])));g&&g!==e&&n.call(g,i)&&(b=g);var E=m.prototype=y.prototype=Object.create(b);function _(t){["next","throw","return"].forEach(function(r){t[r]=function(t){return this._invoke(r,t)}})}function k(t){var r;this._invoke=function(e,o){function i(){return new Promise(function(r,i){!function r(e,o,i,u){var a=l(t[e],t,o);if("throw"!==a.type){var s=a.arg,c=s.value;return c&&"object"==typeof c&&n.call(c,"__await")?Promise.resolve(c.__await).then(function(t){r("next",t,i,u)},function(t){r("throw",t,i,u)}):Promise.resolve(c).then(function(t){s.value=t,i(s)},function(t){return r("throw",t,i,u)})}u(a.arg)}(e,o,r,i)})}return r=r?r.then(i,i):i()}}function x(t,e){var n=t.iterator[e.method];if(n===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=r,x(t,e),"throw"===e.method))return p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var o=l(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function S(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function j(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function R(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,u=function e(){for(;++o<t.length;)if(n.call(t,o))return e.value=t[o],e.done=!1,e;return e.value=r,e.done=!0,e};return u.next=u}}return{next:A}}function A(){return{value:r,done:!0}}return d.prototype=E.constructor=m,m.constructor=d,m[a]=d.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===d||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,a in t||(t[a]="GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},_(k.prototype),k.prototype[u]=function(){return this},t.AsyncIterator=k,t.async=function(r,e,n,o){var i=new k(s(r,e,n,o));return t.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},_(E),E[a]="Generator",E[i]=function(){return this},E.toString=function(){return"[object Generator]"},t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=R,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(j),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function o(n,o){return a.type="throw",a.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var u=this.tryEntries[i],a=u.completion;if("root"===u.tryLoc)return o("end");if(u.tryLoc<=this.prev){var s=n.call(u,"catchLoc"),l=n.call(u,"finallyLoc");if(s&&l){if(this.prev<u.catchLoc)return o(u.catchLoc,!0);if(this.prev<u.finallyLoc)return o(u.finallyLoc)}else if(s){if(this.prev<u.catchLoc)return o(u.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<u.finallyLoc)return o(u.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var u=i?i.completion:{};return u.type=t,u.arg=r,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(u)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),p},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),j(e),p}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;j(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:R(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),p}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}})(r={exports:{}},r.exports);function e(t,r,e,n,o,i,u){try{var a=t[i](u),s=a.value}catch(t){return void e(t)}a.done?r(s):Promise.resolve(s).then(n,o)}function n(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function o(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t,r,e){return r&&o(t.prototype,r),e&&o(t,e),t}function u(){return(u=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t}).apply(this,arguments)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,r){return(s=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}function l(t,r,e){return(l=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct:function(t,r,e){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(t,n));return e&&s(o,e.prototype),o}).apply(null,arguments)}function c(t){var r="function"==typeof Map?new Map:void 0;return(c=function(t){if(null===t||(e=t,-1===Function.toString.call(e).indexOf("[native code]")))return t;var e;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,n)}function n(){return l(t,arguments,a(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),s(n,t)})(t)}function f(t,r){return!r||"object"!=typeof r&&"function"!=typeof r?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):r}function h(t){return null!=t&&"function"==typeof t[Symbol.iterator]&&"function"==typeof t.next}var v,p;!function(){try{new Function("a","b","return a + b")}catch(t){return!1}}();function y(t){return null!=t&&"function"==typeof t.then}function d(t,r,e,n,o){if(!h(t))return v.None;return function e(n,i,u,a){try{return function(){for(;;){var s=void 0;if(i?(i=!1,s=t.throw(n)):s=t.next(n),s.done)return u(s.value,r),r?v.ImmediateError:v.Immediate;var l=b(s.value,!1,function(t,r){n=t,i=r},function(t,r){e(t,r,a,a)},o);if(0!=(l&v.Deferred))return l}}()}catch(t){return u(t,!0),v.ImmediateError}}(void 0,!1,e,n)}function m(t,r,e,n){if(!y(t))return v.None;var o,i=r?v.DeferredError:v.Deferred;return(t.thenLast||t.then).call(t,function(t){o?n(t,r):(i=r?v.ImmediateError:v.Immediate,e(t,r))},function(t){o?n(t,!0):(i=v.ImmediateError,e(t,!0))}),o=!0,i}function b(t,r,e,n,o){for(var i=function(e,n){n&&(r=!0),t=e},u=function(t,e){b(t,r||e,n,n,o)};;){var a=m(t,r,i,u);if(0!=(a&v.Deferred))return a;if(0==(a&v.Immediate)){var s=d(t,r,i,u,o);if(0!=(s&v.Deferred))return s;if(0==(s&v.Immediate)){if(null!=t&&null!=o){var l=o(t);if(l!==t){t=l;continue}}return e(t,r),r?v.ImmediateError:v.Immediate}}}}function w(t,r,e,n){return b(t,!1,r,e,n)}function g(t,r){var e=new _(null,r);return e.resolve(t),e}function E(t,r){var e=new _(null,r);return e.reject(t),e}!function(t){t[t.None=0]="None",t[t.Immediate=1]="Immediate",t[t.Deferred=2]="Deferred",t[t.Error=4]="Error",t[t.ImmediateError=5]="ImmediateError",t[t.DeferredError=6]="DeferredError"}(v||(v={})),function(t){t.Resolving="Resolving",t.Resolved="Resolved",t.Rejected="Rejected"}(p||(p={}));var _=function(){function t(r,e){if(n(this,t),null!=e&&(this._customResolveValue=e),r)try{r(this.resolve.bind(this),this.reject.bind(this))}catch(t){this.reject(t)}}return i(t,[{key:"resolve",value:function(t){if(null!=this._status)throw new Error("Multiple call resolve/reject() is forbidden; status = "+this._status);this._resolve(t)}},{key:"_resolve",value:function(t){var r=this,e=this._status;if(null!=e&&e!==p.Resolving)throw new Error("Multiple call resolve/reject() is forbidden; status = "+e);var n=w(t,function(e,n){n?r._reject(e):t=e},function(t,e){e?r._reject(t):r._resolve(t)},this._customResolveValue);if(0==(n&v.Deferred)){if(0==(n&v.Error)){this._status=p.Resolved,this._value=t;var o=this._onfulfilled;if(o){this._onfulfilled=void 0,this._onrejected=void 0;for(var i=0,u=o.length;i<u;i++)o[i](t)}}}else this._status=p.Resolving}},{key:"reject",value:function(t){if(null!=this._status)throw new Error("Multiple call resolve/reject() is forbidden; status = "+this._status);this._reject(t)}},{key:"_reject",value:function(t){var r=this,e=this._status;if(null!=e&&e!==p.Resolving)throw new Error("Multiple call resolve/reject() is forbidden; status = "+e);if(0==(w(t,function(r){t=r},function(t){r._reject(t)},this._customResolveValue)&v.Deferred)){this._status=p.Rejected,this._error=t;var n=this._onrejected;if(n){this._onfulfilled=void 0,this._onrejected=void 0;for(var o=0,i=n.length;o<i;o++)n[o](t)}}else this._status=p.Resolving}},{key:"_then",value:function(r,e,n,o){var i=function(r){if(!e){if(n)throw r;return t.createRejected(r,o)}var i,u=k(r=function(){try{return e(r)}catch(t){return i=!0,t}}(),null,null,!n,o);if(y(u))return i?u.then(function(t){return E(t,o)}):u;if(n){if(!i)return u;throw u}return i?E(u,o):g(u,o)};switch(this._status){case p.Resolved:var u,a=this._value;if(!r)return n?a:this;if(a=function(){try{return r(a)}catch(t){return u=!0,t}}(),u){var s=k(a,null,null,!n,o);return y(s)?s.then(function(t){return i(t)},e):i(s)}var l=k(a,null,e,!n,o);return n||y(l)?l:g(l,o);case p.Rejected:return e||n||o&&o!==this._customResolveValue?i(this._error):this;default:if(!(r||e||o&&o!==this._customResolveValue))return this;var c=new t(null,o),f=this._onrejected;f||(this._onrejected=f=[]);var h=e?function(t){var r;t=function(){try{return e(t)}catch(t){return r=!0,t}}(),r?c.reject(t):c.resolve(t)}:function(t){c.reject(t)};f.push(h);var v=this._onfulfilled;return v||(this._onfulfilled=v=[]),v.push(r?function(t){var e;t=function(){try{return r(t)}catch(t){return e=!0,t}}(),e?w(t,h,h,o):c.resolve(t)}:function(t){c.resolve(t)}),c}}},{key:"then",value:function(t,r,e){return this._then(t,r,!1,!1===e?null:e||this._customResolveValue)}},{key:"thenLast",value:function(t,r,e){return this._then(t,r,!0,!1===e?null:e||this._customResolveValue)}}]),t}();function k(t,r,e,n,o){if(!r&&(!y(u=t)&&!h(u))){if(null==t||!o)return t;var i=o(t);if(t===i)return t;t=i}var u;return function(t,r,e,n,o){var i,u,a,s=function(t,r){i=t,u=r},l=function(){return a||(a=new _(function(t,r){s=function(e,n){n?r(e):t(e)}},o)),a},c=function(t,n){var u=n?e:r;u?0!=(function(t,r,e,n){try{return w(t(),r,e,n)}catch(t){return r(t,!0),v.ImmediateError}}(function(){return u(t)},function(t,r){s(t,r)},function(t,r){s(t,r)},o)&v.Deferred)&&(i=l()):s(t,n)};if(0!=(w(t,c,c,o)&v.Deferred))return l();if(u){if(n)return _.createRejected(i,o);throw i}return i}(t,r,e,n,o)}_.createResolved=g,_.createRejected=E,_.isThenable=y,_.resolve=k;var x=regeneratorRuntime.mark(U),S=new function t(){n(this,t),this.size=0,this.maxSize=1e6,this.stack=[]};function j(t){if(null==t)throw new Error("obj == null");S.size<S.maxSize&&(S.stack[S.size]=t,S.size++)}function O(t,r,e,n){var o=function(){var t=S.size-1;if(t>=0){var r=S.stack[t];if(S.stack[t]=null,S.size=t,null==r)throw new Error("obj == null");return r}return null}();return null!=o?(o.state=t,o.value=r,o.prev=e,o.next=n,o):{state:t,value:r,prev:e,next:n}}function R(t,r){if(null!=t){var e=r.prev,n=r.next;null==e?null==n?(t._subscribersFirst=null,t._subscribersLast=null):(t._subscribersFirst=n,n.prev=null,r.next=null):(null==n?(t._subscribersLast=e,e.next=null):(e.next=n,n.prev=e,r.next=null),r.prev=null),r.state=null,r.value=null,j(r)}}function A(t,r){if(!(r.callId>t.callId)){var e=function(t,r){var e=t._subscribersLast,n=O(t,r,e,null);return null==e?t._subscribersFirst=n:e.next=n,t._subscribersLast=n,n}(r,t),n=t._unsubscribers;null==n?(t._unsubscribers=[e],t._unsubscribersLength=1):n[t._unsubscribersLength++]=e}}var L=1,P=2,I=3,q=4,N=5,M=6;function C(t,r,e){var n=t.status;switch(t.status=r,r){case L:if(n===P)return;if(n!==L&&n!==N&&n!==M)throw new Error("Set status "+r+" called when current status is "+n);!function(t){var r=t._unsubscribers;if(null!=r){for(var e=t._unsubscribersLength,n=0;n<e;n++){var o=r[n];R(o.state,o),r[n]=null}t._unsubscribersLength=0,e>256&&(r.length=256)}}(t),D(t,r);break;case P:if(n!==L)return;D(t,r);break;case I:if(null!=n&&n!==L&&n!==P)throw new Error("Set status "+r+" called when current status is "+n);break;case q:if(n!==I)throw new Error("Set status "+r+" called when current status is "+n);t.valueAsync=e;break;case N:if(n!==I&&n!==q)throw new Error("Set status "+r+" called when current status is "+n);void 0!==t.valueAsync&&(t.valueAsync=null),t.error=void 0,t.value=e,t.hasError=!1,t.hasValue=!0;break;case M:if(n!==I&&n!==q)throw new Error("Set status "+r+" called when current status is "+n);void 0!==t.valueAsync&&(t.valueAsync=null),t.error=e,t.hasError=!0;break;default:throw new Error("Unknown FuncCallStatus: "+r)}}function F(t,r){null==r?(C(t,L),C(t,P)):C(t,r)}function D(t,r){if(null!=t._subscribersFirst){for(var e,n,o=t._subscribersFirst;o;o=o.next){var i=O(t,o.value,null,o.next);null==n?e=i:n.next=i,n=i}for(var u=e;u;){F(u.value,r),u.value=null;var a=u.next;u.next=null,j(u),u=a}}}var T,z=function t(r,e,o){n(this,t),this.status=P,this.hasValue=!1,this.hasError=!1,this.valueAsync=null,this.value=void 0,this.error=void 0,this.parentCallState=null,this._subscribersFirst=null,this._subscribersLast=null,this.callId=0,this._unsubscribers=null,this._unsubscribersLength=0,this.func=r,this._this=e,this.dependentFunc=o};function V(t,r,e){return new z(t,r,e)}var G=1;function Y(){var t=arguments;return function(){if(T&&A(T,this),this.callId=G++,this.status)switch(this.status){case N:return this.value;case L:case P:break;case q:for(var r=this.parentCallState;r;){if(r===this)throw new Error("Recursive async loop detected");r=r.parentCallState}return this.valueAsync;case M:throw this.error;case I:throw new Error("Recursive sync loop detected");default:throw new Error("Unknown FuncStatus: "+this.status)}this.parentCallState=T,T=this;try{C(this,I);var e=this.func.apply(this._this,t);if(h(e))return y(e=k(U(this,e)))&&C(this,q,e),e;if(y(e))throw new Error("You should use iterator instead thenable for async functions");return C(this,N,e),e}catch(t){throw C(this,M,t),t}finally{T=this.parentCallState,this.parentCallState=null}}}function U(t,r,e){var n,o;return regeneratorRuntime.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:T=t,i.prev=1,n=r.next();case 3:if(n.done){i.next=13;break}return h(o=n.value)&&(o=U(t,o,!0)),i.next=8,o;case 8:o=i.sent,T=t,n=r.next(o),i.next=3;break;case 13:return e||C(t,N,n.value),i.abrupt("return",n.value);case 17:throw i.prev=17,i.t0=i.catch(1),e||C(t,M,i.t0),i.t0;case 21:return i.prev=21,T=null,t.parentCallState=null,i.finish(21);case 25:case"end":return i.stop()}},x,null,[[1,17,21,25]])}function W(t){return null!=t&&("object"==typeof t||"function"==typeof t)}function H(t,r){var e;if(W(r)){var n=t.weakMap;n&&(e=n.get(r))}else{var o=t.map;o&&(e=o.get(r))}return null==e?null:e}function B(t,r,e){if(W(r)){var n=t.weakMap;n||(t.weakMap=n=new WeakMap),n.set(r,e)}else{var o=t.map;o||(t.map=o=new Map),o.set(r,e)}}var J=function(){};var K,Q=new WeakMap,X=function(t){return function(r){return t.get(r)||J}}(Q),Z=function(t){return function(r){if(t.get(r))throw new Error("Multiple call makeDependentFunc() for func: "+r);var e=function(t,r){return function(){var e,n=arguments.length,o=r.get(n);if(o||(o={map:null,weakMap:null},r.set(n,o)),n){var i=H(o,this);i||B(o,this,i={map:null,weakMap:null});for(var u=0;u<n-1;u++){var a=arguments[u],s=H(i,a);s||B(i,a,s={map:null,weakMap:null}),i=s}var l=arguments[n-1];(e=H(i,l))||B(i,l,e=V(t,this,Y.apply(void 0,arguments)))}else(e=H(o,this))||B(o,this,e=V(t,this,Y.apply(void 0,arguments)));return e}}(r,new Map);t.set(r,e);var n=function(t){return function(){return t.apply(this,arguments).dependentFunc()}}(e);return t.set(n,e),n}}(Q);!function(t){t[t.Invalidating=1]="Invalidating",t[t.Invalidated=2]="Invalidated",t[t.Calculating=3]="Calculating",t[t.CalculatingAsync=4]="CalculatingAsync",t[t.Calculated=5]="Calculated",t[t.Error=6]="Error"}(K||(K={}));var $=1;var tt="458d576952bc489ab45e98ac7f296fd9";function rt(t){if(null==t)return null;var r=t[tt];if(null!=r)return r;if(Object.isFrozen(t))return null;var e=$++;return Object.defineProperty(t,tt,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}var et=regeneratorRuntime.mark(ot);function nt(t){return null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"function"==typeof t||t instanceof Error}function ot(t){var r,e,n,o,i;return regeneratorRuntime.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:r=t,e=Array.isArray(r),n=0,r=e?r:r[Symbol.iterator]();case 1:if(!e){u.next=7;break}if(!(n>=r.length)){u.next=4;break}return u.abrupt("break",16);case 4:o=r[n++],u.next=11;break;case 7:if(!(n=r.next()).done){u.next=10;break}return u.abrupt("break",16);case 10:o=n.value;case 11:return i=o,u.next=14,i;case 14:u.next=1;break;case 16:case"end":return u.stop()}},et)}var it=function(){function t(r){var e=void 0===r?{}:r,o=e.commonOptions,i=e.cloneOptions,u=e.equalOptions;n(this,t),o&&(this.commonOptions=o),i&&(this.cloneOptions=i),u&&(this.equalOptions=u)}return i(t,[{key:"isPrimitive",value:function(t){var r=this.commonOptions,e=r&&r.customIsPrimitive||nt;return e(t)}},{key:"clone",value:function(t,r,e){var n=(r=u({},this.commonOptions,{},this.cloneOptions,{},r))&&r.customClone,o=r&&r.customIsPrimitive||nt,i=function t(i){if(o(i))return i;var u,a;if(r&&r.circular)if(u=rt(i),e){var s=e[u];if(null!=s)return s}else e=[];if(n){var l=n(i,function(t){a=t,null!=u&&(e[u]=t)},t);if(null!=l)return l;null!=u&&null!=a&&(e[u]=null)}if(i[Symbol.iterator]&&i.next)return a=ot(t(Array.from(i[Symbol.iterator]()))),null!=u&&(e[u]=a),a;var c=i.constructor,f=i.valueOf();if(f!==i)return a=new c(f),null!=u&&(e[u]=a),a;a=new c,null!=u&&(e[u]=a);var h,v=i[Symbol.toStringTag];switch(a[Symbol.toStringTag]!==v&&(a[Symbol.toStringTag]=v),v){case"Set":var p=i,y=Array.isArray(p),d=0;for(p=y?p:p[Symbol.iterator]();;){var m;if(y){if(d>=p.length)break;m=p[d++]}else{if((d=p.next()).done)break;m=d.value}var b=m;a.add(t(b))}return a;case"Map":var w=i,g=Array.isArray(w),E=0;for(w=g?w:w[Symbol.iterator]();;){var _;if(g){if(E>=w.length)break;_=w[E++]}else{if((E=w.next()).done)break;_=E.value}var k=_;a.set(t(k[0]),t(k[1]))}return a}for(var x in i[Symbol.iterator]&&!a[Symbol.iterator]&&(a[Symbol.iterator]=(h=t(Array.from(i[Symbol.iterator]())),function(){return ot(h)})),i)Object.prototype.hasOwnProperty.call(i,x)&&(a[x]=t(i[x]));return a};return i(t)}},{key:"equal",value:function(t,r,e){var n,o,i,a,s,l,c,f=(e=u({},this.commonOptions,{},this.equalOptions,{},e))&&e.customEqual,h=e&&e.customIsPrimitive||nt,v=function t(r,u){if(h(r)||h(u))return!(!(r===u||Number.isNaN(r)&&Number.isNaN(u))&&(e&&e.strictEqualFunctions||"function"!=typeof r||"function"!=typeof u||r.toString()!==u.toString()));if(null==i&&(i=1),e&&(e.circular||e.equalInnerReferences)){var v=rt(r),p=rt(u);if(null==v||n||(n=[]),null==p||o||(o=[]),null==v){if(null!=p)return!1;if(r===u)return!0}else{if(null==p)return!1;if(r===u)return!e.noCrossReferences&&(n[v]=i,o[p]=i,!0);if(e.noCrossReferences&&(n[p]||o[v]))return!1;if(e.equalInnerReferences&&(n[v]||i)!==(o[p]||i))return!1;if(n[v]&&o[p])return!0;null==l||n[v]||a.push(v),null==c||o[v]||s.push(p),n[v]=i,o[p]=i}}else if(r===u)return!e||!e.noCrossReferences;if(f){var y=f(r,u,t);if(null!=y)return y}if(e&&e.equalTypes&&r.constructor!==u.constructor)return!1;var d=r.valueOf(),m=u.valueOf();if(d!==r||m!==u)return!!(d===m||Number.isNaN(d)&&Number.isNaN(m));if("function"==typeof r[Symbol.iterator]){if("function"!=typeof u[Symbol.iterator])return!1;if(!Array.isArray(r)||!Array.isArray(u)){if((r.size||r.length)!==(u.size||u.length))return!1;if(e&&!e.equalMapSetOrder){var b=r[Symbol.toStringTag],w=u[Symbol.toStringTag],g="Map"===b||"Map"===w;if("Set"===b||"Set"===w||g){if(b&&w&&b!==w)return!1;a||(a=[]),s||(s=[]),null==l&&(l=0),null==c&&(c=0);var E=l,_=c,k=r,x=Array.isArray(k),S=0;for(k=x?k:k[Symbol.iterator]();;){var j;if(x){if(S>=k.length)break;j=k[S++]}else{if((S=k.next()).done)break;j=S.value}var O=j;if(g&&(!Array.isArray(O)||2!==O.length))return!1;var R=void 0,A=u,L=Array.isArray(A),P=0;for(A=L?A:A[Symbol.iterator]();;){var I;if(L){if(P>=A.length)break;I=A[P++]}else{if((P=A.next()).done)break;I=P.value}var q=I;if(g&&(!Array.isArray(q)||2!==q.length))return!1;var N=i,M=l,C=c;if(i++,g?t(O[0],q[0])&&t(O[1],q[1]):t(O,q)){R=!0;break}i=N;for(var F=M,D=l;F<D;F++)n[a[F]]=0;a.length=M;for(var T=C,z=c;T<z;T++)o[s[T]]=0;s.length=C}if(!R)return!1}return 0===E&&(l=null),0===_&&(c=null),!0}}for(var V=r[Symbol.iterator](),G=u[Symbol.iterator]();;){var Y=V.next(),U=G.next();if(i++,!t(Y.value,U.value))return!1;if(Y.done){if(!U.done)return!1;break}}return!0}if(r.length!==u.length)return!1}else if("function"==typeof u[Symbol.iterator])return!1;for(var W in r)if(Object.prototype.hasOwnProperty.call(r,W)){if(!Object.prototype.hasOwnProperty.call(u,W))return!1;if(i++,!t(r[W],u[W]))return!1}for(var H in u)if(Object.prototype.hasOwnProperty.call(u,H)&&!Object.prototype.hasOwnProperty.call(r,H))return!1;return!0};return v(t,r)}}]),t}(),ut="function"==typeof require?require("assertion-error"):function(t){function r(){return n(this,r),f(this,a(r).apply(this,arguments))}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),r&&s(t,r)}(r,c(Error)),r}(),at=new it;console.debug||(console.debug=console.info);var st=function(){function t(r){n(this,t),this.deepCloneEqual=r||at}return i(t,[{key:"fail",value:function(t){this.throwAssertionError(null,null,t)}},{key:"ok",value:function(t,r){t||this.throwAssertionError(t,!0,r)}},{key:"notOk",value:function(t,r){t&&this.throwAssertionError(t,!1,r)}},{key:"strictEqual",value:function(t,r,e){t!==r&&this.throwAssertionError(t,r,e)}},{key:"notStrictEqual",value:function(t,r,e){t===r&&this.throwAssertionError(t,r,e)}},{key:"deepStrictEqual",value:function(t,r,e,n){this.deepCloneEqual.equal(t,r,n)||this.throwAssertionError(t,r,e)}},{key:"circularDeepStrictEqual",value:function(t,r,e,n){this.deepCloneEqual.equal(t,r,u({},n,{circular:!0}))||this.throwAssertionError(t,r,e)}},{key:"equal",value:function(t,r,e){t!=r&&this.throwAssertionError(t,r,e)}},{key:"notEqual",value:function(t,r,e){t==r&&this.throwAssertionError(t,r,e)}},{key:"equalCustom",value:function(t,r,e,n){e(t,r)||this.throwAssertionError(t,r,n)}},{key:"assertError",value:function(r,e,n,o){if(this.ok(r),r instanceof ut){var i=t.errors.indexOf(r);t.errors.splice(i,1)}if(e){var u=r.constructor;Array.isArray(e)?e.some(function(t){return t===u})||this.throwAssertionError(u.name,e.map(function(t){return t&&t.name}),r?(o||"")+"\r\n"+r+"\r\n"+r.stack:o):u!==e&&this.throwAssertionError(u.name,e.name,r?(o||"")+"\r\n"+r+"\r\n"+r.stack:o)}n&&this.ok(n.test(r.message))}},{key:"throwsAsync",value:function(){var t,r=(t=regeneratorRuntime.mark(function t(r,e,n,o){var i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,r();case 3:t.next=8;break;case 5:t.prev=5,t.t0=t.catch(0),i=t.t0;case 8:this.assertError(i);case 9:case"end":return t.stop()}},t,this,[[0,5]])}),function(){var r=this,n=arguments;return new Promise(function(o,i){var u=t.apply(r,n);function a(t){e(u,o,i,a,s,"next",t)}function s(t){e(u,o,i,a,s,"throw",t)}a(void 0)})});return function(t,e,n,o){return r.apply(this,arguments)}}()},{key:"throws",value:function(t,r,e,n){var o;try{t()}catch(t){o=t}this.assertError(o)}},{key:"assertNotHandledErrors",value:function(){if(t.errors.length){var r=t.errors[0];throw t.errors=[],r}}},{key:"throwAssertionError",value:function(r,e,n){console.debug("actual: ",r),console.debug("expected: ",e);var o=new ut(n,{actual:r,expected:e,showDiff:!0});throw t.errors?t.errors.push(o):t.errors=[o],o}}]),t}();st.errors=[];var lt=new st;function ct(t,r,e){void 0===e&&(e=!0);for(var n=r*t+2,o=Z(function(){return 1}),i=[],u=function(t){i[t]=Z(function(r,e){return t*r*e*o()*this})},a=0;a<t;a++)u(a);for(var s,l=[i],c=0;c<r-1;c++){for(var f=[],h=function(r){var e=i;f[r]=Z(function(r,n){for(var o=0,i=0;i<t;i++)o+=e[i].call(this,r,n);return o})},v=0;v<t;v++)h(v);i=f,l.push(i)}var p,y=i;s=Z(function(r,e){for(var n=0,o=0;o<t;o++)n+=y[o].call(this,r,e);return n});var d=X(o)();return e&&(lt.strictEqual(s.call(2,5,10).toPrecision(6),((t-1)*t/2*100*Math.pow(t,r-1)).toPrecision(6)),F(d),lt.strictEqual(s.call(2,5,10).toPrecision(6),((t-1)*t/2*100*Math.pow(t,r-1)).toPrecision(6))),{getStates:function(){return p||(p=l.flatMap(function(t){return t}).map(function(t){return X(t)()})),p},countFuncs:n,input:o,inputState:d,output:s}}var ft=ct(2,2),ht=ft.inputState,vt=ft.output;var pt=function(t,r,e){void 0===e&&(e=!0);for(var n,o=[],i=function(t){o[t]=function(r,e){return t*r*e*1*this}},u=0;u<t;u++)i(u);for(var a=0;a<r-1;a++){for(var s=[],l=function(r){var e=o;s[r]=function(r,n){for(var o=0,i=0;i<t;i++)o+=e[i].call(this,r,n);return o}},c=0;c<t;c++)l(c);o=s}var f=o;return n=function(r,e){for(var n=0,o=0;o<t;o++)n+=f[o].call(this,r,e);return n},e&&lt.strictEqual(n.call(2,5,10).toPrecision(6),((t-1)*t/2*100*Math.pow(t,r-1)).toPrecision(6)),n}(2,2);return t.testCreate=function(){F(ct(2,2).inputState)},t.testRecalc=function(){F(ht),vt.call(2,5,10)},t.testRecalcNaked=function(){pt.call(2,5,10)},t}({});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment