aboutsummaryrefslogtreecommitdiff
path: root/src/defs.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-11-12 16:01:51 +1100
committerdaurnimator <quae@daurnimator.com>2017-11-12 16:22:28 +1100
commit5812c42e7bb680592e60454b003f228dfe95869a (patch)
treeb9aecff7655d6089a77bfabd45f81b2b9dc1c528 /src/defs.js
parent542c431989bff3fc3a6687f182a8c61a7861efd9 (diff)
downloadfengari-5812c42e7bb680592e60454b003f228dfe95869a.tar.gz
fengari-5812c42e7bb680592e60454b003f228dfe95869a.tar.bz2
fengari-5812c42e7bb680592e60454b003f228dfe95869a.zip
Add internal function defs.luastring_cmp for string equality checks
Diffstat (limited to 'src/defs.js')
-rw-r--r--src/defs.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/defs.js b/src/defs.js
index 0802376..315364a 100644
--- a/src/defs.js
+++ b/src/defs.js
@@ -135,6 +135,11 @@ const is_luastring = function(s) {
return Array.isArray(s);
};
+/* test two lua strings for equality */
+const luastring_cmp = function(a, b) {
+ return a === b || (a.length === b.length && a.join() === b.join());
+};
+
const to_jsstring = function(value, from, to) {
assert(is_luastring(value), "jsstring expects an array of bytes");
@@ -397,5 +402,6 @@ 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.luastring_cmp = luastring_cmp;
module.exports.to_jsstring = to_jsstring;
module.exports.to_luastring = to_luastring;