vm-agent
The library is vm module wrapper, it is supposed to be used for testing inner variables or hacking scripts. It is not for production.
It supports executing scripts, functions by filepath or functions. Also, it will be able to access inner variables.
Usage
$ npm i -D vm-agent
If you want to run a script using vm, you need to set a filepath and call run
. The context is resolved automatically.
const Agent = ;const agent = <filepath>;// orconst exec = ;const agent = ;
If the script is an async function, you need to call runAsync
function.
const agent = <filepath>;
After that, if you wanna get inner variables, you need to call getInnerVariable
or getValue
.
const innerVariables = agent;// orconst innerVariables = agent;
Examples
Inner functions
{ console; { console; }} ;
Async/Await
{ const util = ; const delay = util; await ; console; { await ; console; }} { const agent = await func1; const func2 = agent; await func2 agent;} ;