import "github.com/ethereum/go-ethereum/internal/jsre"
Package jsre provides execution environment for JavaScript.
completion.go jsre.go pretty.go
var ( FunctionColor = color.New(color.FgMagenta).SprintfFunc() SpecialColor = color.New(color.Bold).SprintfFunc() NumberColor = color.New(color.FgRed).SprintfFunc() StringColor = color.New(color.FgGreen).SprintfFunc() ErrorColor = color.New(color.FgHiRed).SprintfFunc() )
MakeCallback turns the given function into a function that's callable by JS.
SafeGet attempt to get the value associated to `key`, and catches the panic that goja creates if an error occurs in key.
type Call struct { goja.FunctionCall VM *goja.Runtime }
Call is the argument type of Go functions which are callable from JS.
type JSRE struct {
// contains filtered or unexported fields
}
JSRE is a JS runtime environment embedding the goja interpreter. It provides helper functions to load code from files, run code snippets and bind native go objects to JS.
The runtime runs all code on a dedicated event loop and does not expose the underlying goja runtime directly. To use the runtime, call JSRE.Do. When binding a Go function, use the Call type to gain access to the runtime.
runtime must be stopped with Stop() after use and cannot be used after stopping
Compile compiles and then runs a piece of JS code.
CompleteKeywords returns potential continuations for the given line. Since line is evaluated, callers need to make sure that evaluating line does not have side effects.
Do executes the given function on the JS event loop.
Evaluate executes code and pretty prints the result to the specified output stream.
Exec(file) loads and runs the contents of a file if a relative path is given, the jsre's assetPath is used
Run runs a piece of JS code.
Set assigns value v to a variable in the JS environment.
stops the event loop before exit, optionally waits for all timers to expire
Path | Synopsis |
---|---|
deps | Package deps Code generated by go-bindata. |
Package jsre imports 14 packages (graph) and is imported by 185 packages. Updated 2020-05-31. Refresh now. Tools for package owners.