patriksimek/vm2

Extract declared variables name and values from vm

dorbenzvi opened this issue · 1 comments

Hi, First of all, this package is awesome, thanks!

I need a way to extract all the declared variables in the global scope of the evalulated code.
The is a way to extract the variable names and values outside from the vm?

for exmaple:
const hello = 'world' const array = [1,2,3,4] for(const obj of array){ const temp = 1 }

If I ran this code in the VM I want to be able to get hello and array with their values
And since temp declared inside the loop (another scope) I don't want it.

Thanks in advance!

I do not know of a way to do this without code transformation.