summaryrefslogtreecommitdiff
path: root/src/defs.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-03-30 16:39:41 +1100
committerdaurnimator <quae@daurnimator.com>2018-03-30 16:42:26 +1100
commitfb3b9c3b3f0ee1a04ec264d1b40bd1cccf24a999 (patch)
tree3166cfef0f1c8cde6b6662b46791dfb66f681e3d /src/defs.js
parent2f2bd7fad5342583f85e99ec67eea74fad5fafdd (diff)
parent1371afafae9144b30475262f06940c4057485d02 (diff)
downloadfengari-fb3b9c3b3f0ee1a04ec264d1b40bd1cccf24a999.tar.gz
fengari-fb3b9c3b3f0ee1a04ec264d1b40bd1cccf24a999.tar.bz2
fengari-fb3b9c3b3f0ee1a04ec264d1b40bd1cccf24a999.zip
Merge branch 'accept-jsstrings'
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;
};