/* DATA CHUNK CHECK */ var repl = require("repl"); var rrepl = repl.start({ prompt: "$ " }); var context = rrepl.context; // Configure what’s available in the REPL var fs = require("fs"); var vm = require('vm'); var $lib = {}; var sandbox = { console: console, require: require, PATH: process.env.PWD, "$lib": $lib, setTimeout: setTimeout }; vm.createContext(sandbox); // Contextify the sandbox. var loadfil = process.argv.pop() ; loadfil = loadfil.indexOf("self.js") >-1 ? './tta.js' : loadfil; function reload(){ var code = fs.readFileSync(loadfil,"utf8"); // x and y are global variables in the sandboxed environment. // Initially, x has the value 2 because that is the value of sandbox.x. vm.runInContext(code, sandbox); } context.reload = reload context.$lib = $lib; reload();