It's possible to reset IJSEngine state?
coader opened this issue · 5 comments
coader commented
I have a script snippet, should be executed many times
so i precompile it at first, but every time execute, the engine still keep last state,
so get error: redeclared
code just like this:
'use strict'; const x=1+2+3+4; let y=2; function run( ){ return x*x; }
Taritsyn commented
It's impossible. Rewrite your code as a function with parameters and execute it once. Then call the function with different parameters.
Taritsyn commented
Although you can try manually removing a x
, y
and run
global variables.
coader commented
got it, tks
coader commented
sorry for this issue, still another question, as it execute many times, so it's threadsafe for compile and execute?
Taritsyn commented
Yes, these operations are threadsafe. There is even a test to check this.