MCPcopy Index your code
hub / github.com/marijnh/Eloquent-JavaScript / getSandbox

Function getSandbox

src/client/ejs.mjs:294–308  ·  view source on GitHub ↗
(name, forHTML)

Source from the content-addressed store, hash-verified

292
293 let sandboxes = {}
294 async function getSandbox(name, forHTML) {
295 name = name || "null"
296 if (sandboxes.hasOwnProperty(name)) return sandboxes[name]
297 let options = {loadFiles: window.page.load_files}, html
298 if (sandboxSnippets.hasOwnProperty(name)) {
299 let snippet = sandboxSnippets[name]
300 options.place = node => placeFrame(node, snippet)
301 if (!forHTML) html = snippet.textContent
302 }
303 let box = await Sandbox.create(options)
304 if (html != null)
305 box.win.document.documentElement.innerHTML = html
306 sandboxes[name] = box
307 return box
308 }
309
310 function resetSandbox(name) {
311 if (!sandboxes.hasOwnProperty(name)) return

Callers 1

runCodeFunction · 0.85

Calls 2

placeFrameFunction · 0.85
createMethod · 0.80

Tested by

no test coverage detected