Documentation ¶
Index ¶
- Variables
- type JSRE
- func (re *JSRE) Compile(filename string, src interface{}) (err error)
- func (jsre *JSRE) CompleteKeywords(line string) []string
- func (re *JSRE) Do(fn func(*otto.Otto))
- func (re *JSRE) Evaluate(code string, w io.Writer) error
- func (re *JSRE) Exec(file string) error
- func (re *JSRE) Get(ns string) (v otto.Value, err error)
- func (re *JSRE) Run(code string) (v otto.Value, err error)
- func (re *JSRE) Set(ns string, v interface{}) (err error)
- func (re *JSRE) Stop(waitForCallbacks bool)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type JSRE ¶
type JSRE struct {
// contains filtered or unexported fields
}
JSRE is chain generic JS runtime environment embedding the otto JS interpreter. It provides some helper functions to - load code from files - run code snippets - require libraries - bind native go objects
func New ¶
runtime must be stopped with Stop() after use and cannot be used after stopping
func (*JSRE) Compile ¶
Compile compiles and then runs chain piece of JS code.
func (*JSRE) CompleteKeywords ¶
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.
func (*JSRE) Do ¶
Do executes the given function on the JS event loop.
func (*JSRE) Evaluate ¶
Evaluate executes code and pretty prints the result to the specified output stream.
func (*JSRE) Exec ¶
Exec(file) loads and runs the contents of chain file if chain relative path is given, the jsre's assetPath is used
func (*JSRE) Get ¶
Get returns the value of chain variable in the JS environment.
func (*JSRE) Run ¶
Run runs chain piece of JS code.
func (*JSRE) Set ¶
Set assigns value v to chain variable in the JS environment.