jsre

package
v0.0.0-...-b78b3a4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

包JSRE为JavaScript提供执行环境。

Index

Constants

This section is empty.

Variables

View Source
var (
	BigNumber_JS = deps.MustAsset("bignumber.js")
	Web3_JS      = deps.MustAsset("web3.js")
)
View Source
var (
	FunctionColor = color.New(color.FgMagenta).SprintfFunc()
	SpecialColor  = color.New(color.Bold).SprintfFunc()
	NumberColor   = color.New(color.FgRed).SprintfFunc()
	StringColor   = color.New(color.FgGreen).SprintfFunc()
	ErrorColor    = color.New(color.FgHiRed).SprintfFunc()
)

Functions

This section is empty.

Types

type JSRE

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

func New

func New(assetPath string, output io.Writer) *JSRE

运行时在使用后必须使用stop()停止,在停止后不能使用。

func (*JSRE) Bind

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

bind将值v赋给JS环境中的变量 此方法已弃用,请使用set。

func (*JSRE) Compile

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

编译然后运行一段JS代码。

func (*JSRE) CompleteKeywords

func (jsre *JSRE) CompleteKeywords(line string) []string

completekeywords返回给定行的潜在连续性。既然是 经过评估,调用方需要确保评估行没有副作用。

func (*JSRE) Do

func (re *JSRE) Do(fn func(*otto.Otto))

do在JS事件循环上执行给定的函数。

func (*JSRE) Evaluate

func (re *JSRE) Evaluate(code string, w io.Writer) error

evaluate执行代码并将结果漂亮地打印到指定的输出 溪流。

func (*JSRE) Exec

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

exec(文件)加载并运行文件的内容 如果给定了相对路径,则使用JSRE的assetpath

func (*JSRE) Get

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

get返回JS环境中变量的值。

func (*JSRE) Run

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

运行运行一段JS代码。

func (*JSRE) Set

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

set将值v赋给JS环境中的变量。

func (*JSRE) Stop

func (re *JSRE) Stop(waitForCallbacks bool)

在退出前停止事件循环,或者等待所有计时器过期

Directories

Path Synopsis
包deps包含控制台javascript依赖项go embedded。
包deps包含控制台javascript依赖项go embedded。

Jump to

Keyboard shortcuts

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