UNPKG

2.41 kBJavaScriptView Raw
1var Luar=function(){function t(t){return t&&"object"==typeof t&&!Array.isArray(t)}function e(t){return"function"==typeof t}function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function o(){return Object.create(null)}function r(t){return e(t)&&t.name?t.name:"anonymous"}function a(t,e,n){return"[Luar] "+(n?"WRN ":"ERR ")+t+"\n"+e}function u(t,e){Object.defineProperty(t,e,{enumerable:!1,value:!0})}function i(){for(var t=[],e=w.length-11;e<w.length;e++)t[t.length]=e+": "+r(w[e]);throw new Error(a("Maximum computed task stack length exceeded (overflow!)","Last 10 tasks in the stack:\n"+t.join("\n")))}function c(){if(!j){j=!0;try{for(;y<w.length;y++){var t=w[y];n(t,k)||t(),y>b&&i()}}finally{w=[],y=0,j=!1}}}function s(t){for(var e=y;e<w.length;e++)if(w[e]===t)return;w[w.length]=t,c()}function f(t,e,n){t:{var o=w[y];if(o){var r=e[n];r||(e[n]=r=[]);for(var a=0;a<r.length;a++)if(r[a]===o)break t;r[r.length]=o}}return t[n]}function d(e,o,r,a){t(a)&&p(a),e[r]=a;var u=o[r];if(u)for(var i=0;i<u.length;i++){var c=u[i];c&&(n(c,k)?u[i]=null:s(c))}}function l(e,n,o,r,a){n[a]={get:function(){return f(o,r,a)},set:function(t){d(o,r,a,t)}};var u=e[a];t(u)&&p(u),o[a]=u}function p(t){if(!n(t,g)){u(t,g);var e=o(),r=o(),a=o();for(var i in t)n(t,i)&&"__proto__"!==i&&l(t,a,e,r,i);Object.defineProperties(t,a)}}function m(n){if(!t(n)&&!e(n))throw new Error(a("Attempted to observe a value that is not an object",'observe(obj) expects "obj" to be an object, got "'+n+'"'));return p(n),n}function h(t){if(!e(t))throw new Error(a("Attempted to register a value that is not a function as a computed task",'computed(task) expects "task" to to be a function, got "'+t+'"'));return j&&console.warn(a("Creating computed tasks from within another computed task is not recommended","Offending computed task: "+r(w[y])+"\nNewly created computed task: "+r(t),!0)),s(t),t}function v(t){if(null==t){if(!(t=w[y]))throw new Error(a("Attempted to dispose of current computed task while no computed task is running",'dispose(task) was called without "task" but there is currently no executing computed task to dispose of'))}else if(!e(t))throw new Error(a("Attempted to dispose of a value that is not a function",'dispose(task) expects "task" to be a function, got "'+t+'"'));u(t,k)}var g="__luar",k="__disposed",b=2e3,w=[],y=0,j=!1,_={observe:m,computed:h,dispose:v};return"undefined"!=typeof module&&(module.exports=_),_}();
\No newline at end of file