aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-29 01:33:12 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-29 01:33:12 +1100
commit618d00711d4fe7c602bad4fa9da1a2a3482142d3 (patch)
tree7393f7914dee7fbf2262f75ec47263a62e5a6a34
parent036bb181d59364d13207225bac25b419485a3df7 (diff)
downloadfengari-618d00711d4fe7c602bad4fa9da1a2a3482142d3.tar.gz
fengari-618d00711d4fe7c602bad4fa9da1a2a3482142d3.tar.bz2
fengari-618d00711d4fe7c602bad4fa9da1a2a3482142d3.zip
src/lbaselib.js: Buffer console output as JS strings rather than in Array of bytes
-rw-r--r--src/lbaselib.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lbaselib.js b/src/lbaselib.js
index 103a9ca..86ba6cc 100644
--- a/src/lbaselib.js
+++ b/src/lbaselib.js
@@ -6,13 +6,16 @@ const lauxlib = require('./lauxlib.js');
let lua_writestring;
let lua_writeline;
if (typeof process === "undefined") {
- let buff = [];
+ let buff = "";
+ let decoder = new TextDecoder("utf-8");
lua_writestring = function(s) {
- buff = buff.concat(Array.from(s));
+ buff += decoder.decode(s, {stream: true});
};
+ let empty = new Uint8Array(0);
lua_writeline = function() {
- console.log(new TextDecoder("utf-8").decode(Uint8Array.from(buff)));
- buff = [];
+ buff += decoder.decode(empty);
+ console.log(buff);
+ buff = "";
};
} else {
lua_writestring = function(s) {