From 2a6993bf0e23e2a3759abb9d7127525577dc346c Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Sun, 12 Mar 2017 16:48:53 +0100 Subject: Testing 8-bit strings --- src/lobject.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/lobject.js') diff --git a/src/lobject.js b/src/lobject.js index 92dd560..739db50 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -110,6 +110,10 @@ class TValue { return this.ttisnil() || (this.ttisboolean() && this.value === false); } + jsstring() { + return this.ttisstring() ? String.fromCharCode(...this.value) : null; + } + } const nil = new TValue(CT.LUA_TNIL, null); @@ -133,6 +137,8 @@ class Table extends TValue { } else if ([CT.LUA_TSHRSTR, CT.LUA_TLNGSTR].indexOf(key.type) > -1) { key = key.value.map(e => `${e}|`).join(''); } + } else if (typeof key === "string") { // To avoid + key = lua.to_luastring(key).map(e => `${e}|`).join(''); } return key; -- cgit v1.2.3-54-g00ecf