A NodeJS VM utilities
- Method
call
: execute a JS code directly - Method
getCall
: create a JS function to execute a JS code - Method
run
: similar tocall
, but with code fromvmContext.__filename
- Method
getRun
: similar togetCall
, but with code fromvmContext.__filename
- Function
makeProcess
: helpVMContext
to build a fake process - Function
makeGlobal
: helpVMContext
to create some global variables
var VMContext = require('vm-utils/vm-context.js');
var vmContext = new VMContext({
console: global.console,
count: 0
});
var calc = vmContext.getCall('console.log(count++)');
for (let i = 10; i; --i) calc();