src/notevil/index.js
function FunctionFactory(parentContext){
  var context = Object.create(parentContext || {})
  return function Function() {
    // normalize arguments array
    var args = Array.prototype.slice.call(arguments)
    var src = args.slice(-1)[0]
    args = args.slice(0,-1)
    if (typeof src === 'string'){
      //HACK: esprima doesn't like returns outside functions
      src = parse('function a(){ ' + src + '}').body[0].body
    }
    var tree = prepareAst(src)
    return getFunction(tree, args, context)
  }
}
function FunctionFactory(parentContext){
  var context = Object.create(parentContext || {})
  return function Function() {
    // normalize arguments array
    var args = Array.prototype.slice.call(arguments)
    var src = args.slice(-1)[0]
    args = args.slice(0,-1)
    if (typeof src === 'string'){
      //HACK: esprima doesn't like returns outside functions
      src = parse('function a(){ ' + src + '}').body[0].body
    }
    var tree = prepareAst(src)
    return getFunction(tree, args, context)
  }
}
function FunctionFactory ( parentContext ) { var context = Object . create ( parentContext || { } ) return function Function ( ) { // normalize arguments array var args = Array . prototype . slice . call ( arguments ) var src = args . slice ( - 1 ) [ 0 ] args = args . slice ( 0 , - 1 ) if ( typeof src === 'string' ) { //HACK: esprima doesn't like returns outside functions src = parse ( 'function a(){ ' + src + '}' ) . body [ 0 ] . body } var tree = prepareAst ( src ) return getFunction ( tree , args , context ) } }
create a 'Function' constructor for a controlled environment
create a Function constructor for a controlled environment