Script

external class Script(source)

Instances of the vm.Script class contain precompiled scripts that can be executed in specific contexts.

Since

v0.3.1

Constructors

Link copied to clipboard
constructor(code: String)
constructor(code: String, options: ScriptOptions = definedExternally)
constructor(code: String, options: String = definedExternally)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

When cachedData is supplied to create the vm.Script, this value will be set to either true or false depending on acceptance of the data by V8. Otherwise the value is undefined.

Link copied to clipboard

When the script is compiled from a source that contains a source map magic comment, this property will be set to the URL of the source map.

Functions

Link copied to clipboard

Creates a code cache that can be used with the Script constructor's cachedData option. Returns a Buffer. This method may be called at any time and any number of times.

Link copied to clipboard
fun runInContext(contextifiedObject: Context, options: RunningScriptOptions = definedExternally): Any?

Runs the compiled code contained by the vm.Script object within the given contextifiedObject and returns the result. Running code does not have access to local scope.

Link copied to clipboard
fun runInNewContext(contextObject: Context = definedExternally, options: RunningScriptInNewContextOptions = definedExternally): Any?

First contextifies the given contextObject, runs the compiled code contained by the vm.Script object within the created context, and returns the result. Running code does not have access to local scope.

Link copied to clipboard
fun runInThisContext(options: RunningScriptOptions = definedExternally): Any?

Runs the compiled code contained by the vm.Script within the context of the current global object. Running code does not have access to local scope, but does have access to the current global object.