Node.js: Evaluating code in a private context

posted May 30th, 2010, no comments, tagged

While working on hosting Dojo within Node I arrived at a neat solution to isolate the Dojo code from Node itself: evaluate it in a new context. Here’s how it’s done. var sandbox = {}; process.binding("evals").Script.runInNewContext('this["-eval-"] = function(code){ eval(code); };', sandbox); runInNewContext evaluates the code in a separate JavaScript context, sandboxed within our sandbox object. We then define [...]

Continue reading on Supercollider.