js

package
v0.0.0-...-b4bb62b Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type Runtime

type Runtime struct {
	*otto.Otto
	sync.Mutex
	// contains filtered or unexported fields
}

Runtime is a Skydive JavaScript runtime environment

func NewRuntime

func NewRuntime(assets assets.Assets) (*Runtime, error)

NewRuntime returns a new JavaScript runtime environment

func (*Runtime) CallFunction

func (r *Runtime) CallFunction(source string, params ...interface{}) (otto.Value, error)

CallFunction takes the source of a function and evaluate it with the specified parameters

func (*Runtime) CallPromise

func (r *Runtime) CallPromise(source string, params ...interface{}) (chan otto.Value, error)

CallPromise takes the source of a promise and evaluate it with the specified parameters

func (*Runtime) CompleteKeywords

func (r *Runtime) CompleteKeywords(line string) []string

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 (*Runtime) Do

func (r *Runtime) Do(fn func(*otto.Otto))

Do executes the `fn` in the event loop

func (*Runtime) Exec

func (r *Runtime) Exec(code string) (v otto.Value, err error)

Exec queues the execution of some JavaScript code

func (*Runtime) ExecFunction

func (r *Runtime) ExecFunction(source string, params ...interface{}) (v otto.Value, err error)

ExecFunction queues a CallFunction method

func (*Runtime) ExecPromise

func (r *Runtime) ExecPromise(source string, params ...interface{}) (v otto.Value, err error)

ExecPromise executes a promise and return its result

func (*Runtime) RegisterAPIClient

func (r *Runtime) RegisterAPIClient(client *shttp.CrudClient)

RegisterAPIClient exports Go function required by the API to run inside the client JS VM

func (*Runtime) RunScript

func (r *Runtime) RunScript(path string) otto.Value

RunScript executes the specified script

func (*Runtime) Start

func (r *Runtime) Start()

Start the runtime evaluation loop

func (*Runtime) Stop

func (r *Runtime) Stop()

Stop the runtime evaluation loop

Jump to

Keyboard shortcuts

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