From 30cd76371d992df610b36d63b9c83074b4a87372 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sat, 6 Jan 2018 19:46:48 +1100 Subject: src/defs.js: Fallback for when Uint8Array.of doesn't exist --- src/defs.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3-70-g09d2