Skip to content

Instantly share code, notes, and snippets.

@nickjacob
nickjacob / safe_eval.js
Created November 13, 2013 00:45
an idea for a safe eval function
function safe_eval(code, ctx) {
return (new Function (["window", "undefined"], "try { " + code + " } catch (e){ return e; }"))(ctx);
}
function restrict (base, perm) {
var out = {}, k = null,
READ = 'read',
WRITE = 'write',
RW = 'readwrite';