vm

package
v0.0.0-...-084c4e9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2018 License: MPL-2.0, BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type VM

type VM struct {
	sync.Mutex
	// contains filtered or unexported fields
}

VM implements concurrency safe wrapper to otto's VM object.

func New

func New() *VM

New creates new instance of VM.

func (*VM) Call

func (vm *VM) Call(item string, this interface{}, args ...interface{}) (otto.Value, error)

Call attempts to call the internal call function for the giving response associated with the proper values.

func (*VM) Compile

func (vm *VM) Compile(filename string, src interface{}) (*otto.Script, error)

Compile parses given source and returns otto.Script.

func (*VM) CompileWithSourceMap

func (vm *VM) CompileWithSourceMap(filename string, src, sm interface{}) (*otto.Script, error)

CompileWithSourceMap parses given source with source map and returns otto.Script.

func (*VM) Get

func (vm *VM) Get(key string) (otto.Value, error)

Get returns the given key's otto.Value from the underlying otto vm.

func (*VM) GetObjectValue

func (vm *VM) GetObjectValue(v otto.Value, name string) (otto.Value, error)

GetObjectValue returns the given name's otto.Value from the given otto.Value v. Should only be needed in tests.

func (*VM) MakeCustomError

func (vm *VM) MakeCustomError(name, message string) otto.Value

MakeCustomError allows to create a new Error object.

func (*VM) Run

func (vm *VM) Run(src interface{}) (otto.Value, error)

Run evaluates JS source, which may be string or otto.Script variable.

func (*VM) Set

func (vm *VM) Set(key string, val interface{}) error

Set sets the value to be keyed by the provided keyname.

func (*VM) ToValue

func (vm *VM) ToValue(value interface{}) (otto.Value, error)

ToValue will convert an interface{} value to a value digestible by otto/JavaScript.

func (*VM) UnsafeVM

func (vm *VM) UnsafeVM() *otto.Otto

UnsafeVM returns a thread-unsafe JavaScript VM.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL