function sandbox(code) { code = "with (sandbox) {" + code + "}"; const fn = new Function("sandbox", code); return function (sandbox) { const sandboxProxy = new Proxy(sandbox, { has(target, key) { return true; }, get(target, key) { if (key === Symbol.unscopables) return undefined; return target[key]; }, }); return fn(sandboxProxy); }; }