diff options
author | daurnimator <quae@daurnimator.com> | 2017-06-09 13:01:21 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-06-09 13:01:21 +1000 |
commit | 74dd47160960b3f0faa13dd1b61b64af69fde02e (patch) | |
tree | fee2730a670c4526c1c927230765be3dce49fc95 /src/defs.js | |
parent | 9b74a453e4a48f0c2028bc15b2c5bdaee6fcd5c7 (diff) | |
download | fengari-74dd47160960b3f0faa13dd1b61b64af69fde02e.tar.gz fengari-74dd47160960b3f0faa13dd1b61b64af69fde02e.tar.bz2 fengari-74dd47160960b3f0faa13dd1b61b64af69fde02e.zip |
Add is_luastring function instead of using Array.isArray directly
Diffstat (limited to 'src/defs.js')
-rw-r--r-- | src/defs.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/defs.js b/src/defs.js index 9e0fa5c..a125c34 100644 --- a/src/defs.js +++ b/src/defs.js @@ -132,8 +132,12 @@ class lua_Debug { } +const is_luastring = function(s) { + return Array.isArray(s); +}; + const to_jsstring = function(value, from, to) { - assert(Array.isArray(value), "jsstring expect a array of bytes"); + assert(is_luastring(value), "jsstring expect a array of bytes"); let u0, u1, u2, u3, u4, u5; let idx = 0; @@ -181,7 +185,7 @@ const to_luastring = function(str, cache) { if (cache) { let cached = to_luastring_cache[str]; - if (Array.isArray(cached)) return cached; + if (is_luastring(cached)) return cached; } let outU8Array = []; @@ -403,5 +407,6 @@ module.exports.constant_types = constant_types; module.exports.lua_Debug = lua_Debug; module.exports.lua_upvalueindex = lua_upvalueindex; module.exports.thread_status = thread_status; +module.exports.is_luastring = is_luastring; module.exports.to_jsstring = to_jsstring; module.exports.to_luastring = to_luastring; |