diff options
author | daurnimator <quae@daurnimator.com> | 2018-01-07 03:28:43 +1100 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2018-01-07 03:35:03 +1100 |
commit | ef0784b2982e65af05982d8e1e18ef1d45ea96ad (patch) | |
tree | 0cc5a7aff5c54c7dae8f2fa84dc4f32a131e47bf /src/lobject.js | |
parent | a63de72aa0bf0b1b3bd91ed0c23c4d03bcbf4cd5 (diff) | |
download | fengari-ef0784b2982e65af05982d8e1e18ef1d45ea96ad.tar.gz fengari-ef0784b2982e65af05982d8e1e18ef1d45ea96ad.tar.bz2 fengari-ef0784b2982e65af05982d8e1e18ef1d45ea96ad.zip |
Avoid Uint8Array.slice (IE compat)
Diffstat (limited to 'src/lobject.js')
-rw-r--r-- | src/lobject.js | 17 |
1 files changed, 10 insertions, 7 deletions
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; |