iterative-eval
Iteratively evaluate code in a single context as you would in a repl. You can do this using vm.createContext
and vm.runInContext
but bugs in vm
's implementation make this pretty leaky.
Installation
With your favorite package manager:
then in your app:
var Evaluator =
API
Evaluator(path)
Creates a new evaluation context. If you pass a path
all code evaluated by it the Evaluator will be run as if it was being run from that file system location. So require
, __filename
etc.. can all work as expected.
var ctx = __filename
ctx#eval(js)
Execute js
and return the result
ctx // => undefinedctx // => 1ctx // => Evaluatorctx // => __dirname