summaryrefslogtreecommitdiff
path: root/src/defs.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/defs.js')
-rw-r--r--src/defs.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/defs.js b/src/defs.js
index 856a854..98269ea 100644
--- a/src/defs.js
+++ b/src/defs.js
@@ -224,7 +224,13 @@ const to_luastring = function(str, cache) {
};
const from_userstring = function(str) {
- if (!is_luastring(str)) throw new TypeError("expects an array of bytes");
+ if (!is_luastring(str)) {
+ if (typeof str === "string") {
+ str = to_luastring(str);
+ } else {
+ throw new TypeError("expects an array of bytes or javascript string");
+ }
+ }
return str;
};