JSFiddle - React, Tailwind, and code Playground
by also
JavaScript
function evalScope() {
var _LOCALS = {
script: null,
scope: {_LOCALS: undefined},
gen: function* () {
while (true) yield eval('with(_LOCALS.scope){'+_LOCALS.script+'}');
}()
};
return function (s) {
_LOCALS.script = s;
return _LOCALS.gen.next().value;
};
}
var e = evalScope();
console.log(e('1+1'));
console.log(e('var test = "foo"'));
console.log(e('test + "bar"'));