Documentation ¶
Index ¶
- Variables
- func Initialize(m *plugin.Manager) (plugin.Plugin, error)
- type AsyncResult
- type Module
- type PrependRuntimeInitHandler
- type Registry
- type Result
- type RuntimeInitHandler
- type VM
- func (vm *VM) Compile(name, in string) (*goja.Program, error)
- func (vm *VM) Do(fn func(*goja.Runtime))
- func (vm *VM) OnRuntimeInit(h func(*goja.Runtime))
- func (vm *VM) PrependRuntimeInit(h func(*goja.Runtime))
- func (vm *VM) RunProgram(p *goja.Program) *AsyncResult
- func (vm *VM) RunScript(name, in string) *AsyncResult
- func (vm *VM) RunString(in string) *AsyncResult
- func (vm *VM) SetModule(module *Module)
- func (vm *VM) SetTransformer(fn func(in string) (string, error))
- func (vm *VM) Shutdown() error
- func (vm *VM) Start() error
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrExecutionCancelled = errors.New("execution cancelled")
Functions ¶
Types ¶
type AsyncResult ¶
type AsyncResult struct { // Closed when the result is ready. Read from this channel to detect when // the result has been populated and is safe to inspect. Ready chan struct{} // Error associated with the result, if any. Only read from this after // the result is ready. Error error // Value associated with the result if there is no error. Only read from // this after the result is ready. Value goja.Value // contains filtered or unexported fields }
AsyncResult handles invocations of asynchronous code that returns promises. An AsyncResult accepts any goja.Value; non-promises are supported so this is safe (if maybe a bit inefficient) to wrap all results produced by using one of the Run* methods on a VM.
type Module ¶
type Module struct { Name string Path string Main string Body string // contains filtered or unexported fields }
A Module is a javascript module identified by a name and full path.
type PrependRuntimeInitHandler ¶
type PrependRuntimeInitHandler interface {
PrependRuntimeInitHandler() bool
}
type Registry ¶
type Registry struct { Transform func(in string) (string, error) // contains filtered or unexported fields }
func NewRegistry ¶
type Result ¶
type Result struct { // Closed when the result is ready. Read from this channel to detect when // the result has been populated and is safe to inspect. Ready chan struct{} // Error associated with the result, if any. Only read from this after // the result is ready. Error error // Value associated with the result if there is no error. Only read from // this after the result is ready. Value goja.Value // contains filtered or unexported fields }
A Result is the output from executing synchronous code on a VM.
type RuntimeInitHandler ¶
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
func (*VM) OnRuntimeInit ¶
func (*VM) PrependRuntimeInit ¶
func (*VM) RunProgram ¶
func (vm *VM) RunProgram(p *goja.Program) *AsyncResult
func (*VM) RunScript ¶
func (vm *VM) RunScript(name, in string) *AsyncResult
func (*VM) RunString ¶
func (vm *VM) RunString(in string) *AsyncResult
Click to show internal directories.
Click to hide internal directories.