From 7b81adb41b049ca968217de349f6ed0814ba0b27 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 2 Apr 2018 13:43:53 +1000 Subject: src/lauxlib.js: Use a Buffer in luaL_loadfilex for node 6 compat --- src/lauxlib.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/lauxlib.js b/src/lauxlib.js index 74e83e8..d575e99 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -810,17 +810,17 @@ const skipcomment = function(lf) { let luaL_loadfilex; -class LoadF { - constructor() { - this.n = NaN; /* number of pre-read characters */ - this.f = null; /* file being read */ - this.buff = new Uint8Array(1024); /* area for reading file */ - this.pos = 0; /* current position in file */ - this.err = void 0; +if (typeof process === "undefined") { + class LoadF { + constructor() { + this.n = NaN; /* number of pre-read characters */ + this.f = null; /* file being read */ + this.buff = new Uint8Array(1024); /* area for reading file */ + this.pos = 0; /* current position in file */ + this.err = void 0; + } } -} -if (typeof process === "undefined") { const getF = function(L, ud) { let lf = ud; @@ -889,6 +889,16 @@ if (typeof process === "undefined") { } else { const fs = require('fs'); + class LoadF { + constructor() { + this.n = NaN; /* number of pre-read characters */ + this.f = null; /* file being read */ + this.buff = Buffer.alloc(1024); /* area for reading file */ + this.pos = 0; /* current position in file */ + this.err = void 0; + } + } + const getF = function(L, ud) { let lf = ud; let bytes = 0; -- cgit v1.2.3-70-g09d2