From ef0784b2982e65af05982d8e1e18ef1d45ea96ad Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 7 Jan 2018 03:28:43 +1100 Subject: Avoid Uint8Array.slice (IE compat) --- src/lobject.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/lobject.js') diff --git a/src/lobject.js b/src/lobject.js index 384facd..824fc88 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -302,15 +302,18 @@ const luaO_chunkid = function(source, bufflen) { let l = source.length; let out; if (source[0] === char['=']) { /* 'literal' source */ - if (l < bufflen) /* small enough? */ - out = source.slice(1); - else { /* truncate it */ - out = source.slice(1, bufflen+1); + if (l < bufflen) { /* small enough? */ + out = new Uint8Array(l-1); + out.set(source.subarray(1)); + } else { /* truncate it */ + out = new Uint8Array(bufflen); + out.set(source.subarray(1, bufflen+1)); } } else if (source[0] === char['@']) { /* file name */ - if (l <= bufflen) /* small enough? */ - out = source.slice(1); - else { /* add '...' before rest of name */ + if (l <= bufflen) { /* small enough? */ + out = new Uint8Array(l-1); + out.set(source.subarray(1)); + } else { /* add '...' before rest of name */ out = new Uint8Array(bufflen); out.set(RETS); bufflen -= RETS.length; -- cgit v1.2.3-54-g00ecf