You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
56 KiB
1 line
56 KiB
|
8 years ago
|
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.lua2js=t():e.lua2js=t()}(global,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r.w={},r(r.s=18)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.registerLibs=function(e){i=e.string,s=e.getn},t.default=void 0;var n,o=(n=r(1))&&n.__esModule?n:{default:n},a=r(5);let i,s,u=0;class c{constructor(e){if(this.index=++u,this.numValues=[void 0],this.strValues={},this.keys=[],this.values=[],this.metatable=null,e)if("function"==typeof e)e(this);else{let t=e instanceof Array;for(let r in e)if(e.hasOwnProperty(r)){let n=e[r];null===n&&(n=void 0);let o=t?parseInt(r,10)+1:r,a="object"==typeof n&&n.constructor===Object||n instanceof Array;this.set(o,a?new c(n):n)}}else;}get(e){if(!(this instanceof c)){if("string"==(0,a.type)(this))return i.get(e);if(("userdata"===(0,a.type)(this)||"function"===(0,a.type)(this)&&"new"===e)&&e in this)return this[e];throw new o.default(`attempt to index a ${(0,a.type)(this)} value`)}let t=this.rawget(e);if(void 0===t){let r,n;if((r=this.metatable)&&(n=r.get("__index")))switch(n.constructor){case c:return n.get(e);case Function:return(t=n.call(void 0,this,e))instanceof Array?t[0]:t}}return t}rawget(e){switch(typeof e){case"string":return Object.prototype.hasOwnProperty.call(this.strValues,e)?this.strValues[e]:void 0;case"number":if(e>0&&e==e>>0)return this.numValues[e];default:let t=this.keys.indexOf(e);return t>=0?this.values[t]:void 0}}set(e,t){if(!(this instanceof c)){if("userdata"==(0,a.type)(this))return void(this[e]=t);throw new o.default(`attempt to index a ${(0,a.type)(this)} value`)}let r,n;if((r=this.metatable)&&(n=r.get("__newindex"))){let r;switch(typeof e){case"string":r=this.strValues[e];break;case"number":if(e>0&&e==e>>0){r=this.numValues[e];break}default:let t=this.keys.indexOf(e);r=-1==t?void 0:this.values[t]}if(void 0===r)switch(n.constructor){case c:return n.set(e,t);case Function:return n(this,e,t)}}this.rawset(e,t)}rawset(e,t){switch(t instanceof Array&&(t=t[0]),typeof e){case"string":this.strValues[e]=t;break;case"number":if(e>0&&e==e>>0){this.numValues[e]=t;break}default:let r=this.keys,n=r.indexOf(e);n<0&&(r[n=r.length]=e),this.values[n]=t}}insert(...e){this.numValues.push(...e)}toString(){let e,t;return(e=this.metatable)&&(t=e.get("__tostring"))?t(this)[0]:"table: 0x"+this.index.toString(16)}toObject(){const e=s(this)>0?[]:{},t=this.numValues,r=this.strValues;let n;const o=t.length;for(n=1;n<o;n++){const r=t[n];e[n-1]=r instanceof c?r.toObject():r}for(n in r)if(r.hasOwnProperty(n)){const t=r[n];e[n]=t instanceof c?t.toObject():t}return e}}t.default=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default=class extends Error{constructor(e){super(),this.message=e}toString(){return`LuaError: ${this.message}`}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.coerceToBoolean=function(e){return!(!1===e||void 0===e)},t.coerceToNumber=p,t.coerceToString=d,t.coerceArgToNumber=function(e,t,r){return g(e,p,"number",t,r)},t.coerceArgToString=function(e,t,r){return g(e,d,"string",t,r)},t.coerceArgToTable=function(e,t,r){if(e instanceof a.default)return e;{let a=(0,n.type)(e);throw new o.default(`bad argument #${r} to '${t}' (table expected, got ${a})`)}},t.coerceArgToFunction=function(e,t,r){if(e instanceof Function)return e;{let a=(0,n.type)(e);throw new o.default(`bad argument #${r} to '${t}' (function expected, got ${a})`)}},t.s
|