0.0.3 • Published 10 years ago
vm-utils v0.0.3
vm-utils
A NodeJS VM utilities
Features
Class VMContext
- 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
Other
- Function
makeProcess
: helpVMContext
to build a fake process - Function
makeGlobal
: helpVMContext
to create some global variables
Examples
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();