@ -34,17 +34,11 @@ Script.prototype.runInContext = function(contextifiedSandbox, options) {
} ;
Script . prototype . runInNewContext = function ( sandbox , options ) {
var context = exports . createContext ( sandbox ) ;
var context = createContext ( sandbox ) ;
return this . runInContext ( context , options ) ;
} ;
exports . Script = Script ;
exports . createScript = function ( code , options ) {
return new Script ( code , options ) ;
} ;
exports . createContext = function ( sandbox ) {
function createContext ( sandbox ) {
if ( sandbox === undefined ) {
sandbox = { } ;
} else if ( binding . isContext ( sandbox ) ) {
@ -53,28 +47,11 @@ exports.createContext = function(sandbox) {
binding . makeContext ( sandbox ) ;
return sandbox ;
} ;
exports . runInDebugContext = function ( code ) {
return binding . runInDebugContext ( code ) ;
} ;
exports . runInContext = function ( code , contextifiedSandbox , options ) {
var script = new Script ( code , options ) ;
return script . runInContext ( contextifiedSandbox , options ) ;
} ;
exports . runInNewContext = function ( code , sandbox , options ) {
var script = new Script ( code , options ) ;
return script . runInNewContext ( sandbox , options ) ;
} ;
exports . runInThisContext = function ( code , options ) {
var script = new Script ( code , options ) ;
return script . runInThisContext ( options ) ;
} ;
}
exports . isContext = binding . isContext ;
function createScript ( code , options ) {
return new Script ( code , options ) ;
}
// Remove all SIGINT listeners and re-attach them after the wrapped function
// has executed, so that caught SIGINT are handled by the listeners again.
@ -100,3 +77,31 @@ function sigintHandlersWrap(fn, thisArg, argsArray) {
}
}
}
function runInDebugContext ( code ) {
return binding . runInDebugContext ( code ) ;
}
function runInContext ( code , contextifiedSandbox , options ) {
return createScript ( code , options )
. runInContext ( contextifiedSandbox , options ) ;
}
function runInNewContext ( code , sandbox , options ) {
return createScript ( code , options ) . runInNewContext ( sandbox , options ) ;
}
function runInThisContext ( code , options ) {
return createScript ( code , options ) . runInThisContext ( options ) ;
}
module . exports = {
Script ,
createContext ,
createScript ,
runInDebugContext ,
runInContext ,
runInNewContext ,
runInThisContext ,
isContext : binding . isContext
} ;