aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-01-06 19:46:48 +1100
committerdaurnimator <quae@daurnimator.com>2018-01-06 19:46:48 +1100
commit30cd76371d992df610b36d63b9c83074b4a87372 (patch)
tree19aa15096ecfa6eb0621bf90f9528fe909e560dc
parenta0fa83dc9c170542630dbc83d1732d3e7a6313e9 (diff)
downloadfengari-30cd76371d992df610b36d63b9c83074b4a87372.tar.gz
fengari-30cd76371d992df610b36d63b9c83074b4a87372.tar.bz2
fengari-30cd76371d992df610b36d63b9c83074b4a87372.zip
src/defs.js: Fallback for when Uint8Array.of doesn't exist
-rw-r--r--src/defs.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/defs.js b/src/defs.js
index 0d53c66..d162636 100644
--- a/src/defs.js
+++ b/src/defs.js
@@ -131,7 +131,18 @@ class lua_Debug {
}
-const luastring_of = Uint8Array.of.bind(Uint8Array);
+let luastring_of;
+if (typeof Uint8Array.of === "function") {
+ luastring_of = Uint8Array.of.bind(Uint8Array);
+} else {
+ luastring_of = function() {
+ let i = 0;
+ let len = arguments.length;
+ let r = new Uint8Array(len);
+ while (len > i) r[i] = arguments[i++];
+ return r;
+ };
+}
const is_luastring = function(s) {
return s instanceof Uint8Array;