script

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallFunc

func CallFunc(vm *otto.Otto, method string, timeout time.Duration, params ...interface{}) (value otto.Value, err error)

func Execute

func Execute(vm *otto.Otto, script string, timeout time.Duration) (value otto.Value, err error)

func LoadScript

func LoadScript(vm *otto.Otto, script string, timeout time.Duration) (err error)

Types

type Callback

type Callback func(name string, params ...ParamStruct) any

type Function

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

func (*Function) GetParam

func (f *Function) GetParam(i int) *ParamStruct

type JsEngine

type JsEngine interface {
	Invoke(method string, params ...interface{}) (otto.Value, error)
	Inject(name string, callback func(call otto.FunctionCall) otto.Value)
	InjectFunc(name string, callback Callback, paramType ...ParamType)
	SetValue(name string, value interface{}) error
}

func Create

func Create(javascript string) (engine JsEngine, err error)

func CreateWithTimeout

func CreateWithTimeout(javascript string, timeout time.Duration) (engine JsEngine, err error)

type ParamStruct

type ParamStruct struct {
	Type ParamType
	// contains filtered or unexported fields
}

func (*ParamStruct) Value

func (p *ParamStruct) Value(ptr any)

type ParamType

type ParamType string
const (
	String  ParamType = "string"  // 字符串/[]byte
	Float   ParamType = "float"   // float64
	Integer ParamType = "integer" // int64
	Boolean ParamType = "boolean" // bool
)

Jump to

Keyboard shortcuts

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