Skip to main content

js

成员函数函数描述/介绍
js.ASTWalk
js.CallFunctionFromCode
js.FalseValue
js.GetSTType
js.NaNValueNaNValue will return a value representing NaN. It is equivalent to: ToValue(math.NaN())
js.Newcreate vm
js.NullValue
js.Parse
js.RunRun will allocate a new JavaScript runtime, run the given source on the allocated runtime, and return the runtime, resulting value, and error (if any)...
js.ToValueToValue will convert an interface{} value to a value digestible by otto/JavaScript This function will not work for advanced types (struct, map, slice...
js.TrueValue
js.UndefinedValue

函数定义#

ASTWalk#

详细描述#

定义#

ASTWalk(code string) (*ASTWalkerResult, error)

参数#

参数名参数类型参数解释
codestring

返回值#

返回值(顺序)返回值类型返回值解释
r1*ASTWalkerResult
r2error

CallFunctionFromCode#

详细描述#

定义#

CallFunctionFromCode(i any, funcName string, params ...any) (otto.Value, error)

参数#

参数名参数类型参数解释
iany
funcNamestring
params...any

返回值#

返回值(顺序)返回值类型返回值解释
r1otto.Value
r2error

FalseValue#

详细描述#

定义#

FalseValue() Value

返回值#

返回值(顺序)返回值类型返回值解释
r1Value

GetSTType#

详细描述#

定义#

GetSTType(st any) string

参数#

参数名参数类型参数解释
stany

返回值#

返回值(顺序)返回值类型返回值解释
r1string

NaNValue#

详细描述#

NaNValue will return a value representing NaN.

It is equivalent to:

ToValue(math.NaN())

定义#

NaNValue() Value

返回值#

返回值(顺序)返回值类型返回值解释
r1Value

New#

详细描述#

create vm

定义#

New() *otto.Otto

返回值#

返回值(顺序)返回值类型返回值解释
r1*otto.Otto

NullValue#

详细描述#

定义#

NullValue() valueNull}

返回值#

返回值(顺序)返回值类型返回值解释
r1valueNull}

Parse#

详细描述#

定义#

Parse(code string) (*ast.Program, error)

参数#

参数名参数类型参数解释
codestring

返回值#

返回值(顺序)返回值类型返回值解释
r1*ast.Program
r2error

Run#

详细描述#

Run will allocate a new JavaScript runtime, run the given source on the allocated runtime, and return the runtime, resulting value, and error (if any).

src may be a string, a byte slice, a bytes.Buffer, or an io.Reader, but it MUST always be in UTF-8.

src may also be a Script.

src may also be a Program, but if the AST has been modified, then runtime behavior is undefined.

定义#

Run(src any) (*Otto, Value, error)

参数#

参数名参数类型参数解释
srcany

返回值#

返回值(顺序)返回值类型返回值解释
r1*Otto
r2Value
r3error

ToValue#

详细描述#

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

This function will not work for advanced types (struct, map, slice/array, etc.) and you should use Otto.ToValue instead.

定义#

ToValue(value any) (Value, error)

参数#

参数名参数类型参数解释
valueany

返回值#

返回值(顺序)返回值类型返回值解释
r1Value
r2error

TrueValue#

详细描述#

定义#

TrueValue() Value

返回值#

返回值(顺序)返回值类型返回值解释
r1Value

UndefinedValue#

详细描述#

定义#

UndefinedValue() Value

返回值#

返回值(顺序)返回值类型返回值解释
r1Value