jsre

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2016 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package jsre provides execution environment for JavaScript.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSRE

type JSRE struct {
	// contains filtered or unexported fields
}

JSRE is a 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

func New(assetPath string) *JSRE

runtime must be stopped with Stop() after use and cannot be used after stopping

func (*JSRE) Bind

func (self *JSRE) Bind(name string, v interface{}) error

Bind assigns value v to a variable in the JS environment This method is deprecated, use Set.

func (*JSRE) Compile

func (self *JSRE) Compile(filename string, src interface{}) (err error)

Compile compiles and then runs a piece of JS code.

func (*JSRE) EvalAndPrettyPrint added in v1.1.0

func (self *JSRE) EvalAndPrettyPrint(code string) (err error)

EvalAndPrettyPrint evaluates code and pretty prints the result to standard output.

func (*JSRE) Exec

func (self *JSRE) Exec(file string) error

Exec(file) loads and runs the contents of a file if a relative path is given, the jsre's assetPath is used

func (*JSRE) Get

func (self *JSRE) Get(ns string) (v otto.Value, err error)

Get returns the value of a variable in the JS environment.

func (*JSRE) Run

func (self *JSRE) Run(code string) (v otto.Value, err error)

Run runs a piece of JS code.

func (*JSRE) Set

func (self *JSRE) Set(ns string, v interface{}) (err error)

Set assigns value v to a variable in the JS environment.

func (*JSRE) Stop

func (self *JSRE) Stop(waitForCallbacks bool)

stops the event loop before exit, optionally waits for all timers to expire

Jump to

Keyboard shortcuts

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