Help us shape the future of Go! Take the 2026 Go Developer Survey

yao

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

Pool JS contect pool

func NewPool

func NewPool(size int) *Pool

NewPool make a new pool

func (*Pool) Make

func (p *Pool) Make(makeContext func() *v8go.Context) (*v8go.Context, error)

Make get *v8go.Context from pool

func (*Pool) Pop

func (p *Pool) Pop() (*v8go.Context, error)

Pop get *v8go.Context from pool

func (*Pool) Prepare

func (p *Pool) Prepare(chunk int, makeContext func() *v8go.Context)

Prepare prepare *v8go.Context to pool

func (*Pool) Push

func (p *Pool) Push(ctx *v8go.Context)

Push add *v8go.Context to pool

func (*Pool) PushMulti

func (p *Pool) PushMulti(size int, makeContext func() *v8go.Context)

PushMulti 添加功能多

type Yao

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

Yao runtime engine ( base on v8)

func New

func New(numOfContexts int, fileRoot string) *Yao

New create a pure ES6 engine (v8)

func (*Yao) AddFunction

func (yao *Yao) AddFunction(name string, fn func(global map[string]interface{}, sid string, args ...interface{}) interface{}) error

AddFunction add a global function

func (*Yao) AddFunctionTemplates

func (yao *Yao) AddFunctionTemplates(tmpls map[string]*v8go.FunctionTemplate) error

AddFunctionTemplates add function templates to global

func (*Yao) AddObject

func (yao *Yao) AddObject(name string, methods map[string]func(global map[string]interface{}, sid string, args ...interface{}) interface{}) error

AddObject add a global object

func (*Yao) AddObjectTemplate

func (yao *Yao) AddObjectTemplate(name string, object *v8go.ObjectTemplate) error

AddObjectTemplate add a global object template

func (*Yao) AddRootFunction added in v0.10.2

func (yao *Yao) AddRootFunction(name string, fn func(global map[string]interface{}, sid string, args ...interface{}) interface{}) error

AddRootFunction add a global function ( root only)

func (*Yao) Call

func (yao *Yao) Call(data map[string]interface{}, name string, method string, args ...interface{}) (interface{}, error)

Call cal javascript function

func (*Yao) Has

func (yao *Yao) Has(name string) bool

Has check the given name of the script is load

func (*Yao) Init

func (yao *Yao) Init() error

Init initialize (for next version )

func (*Yao) Load

func (yao *Yao) Load(filename string, name string) error

Load load and compile script

func (*Yao) LoadReader

func (yao *Yao) LoadReader(reader io.Reader, name string, filename ...string) error

LoadReader load and compile script

func (*Yao) RootCall added in v0.10.2

func (yao *Yao) RootCall(data map[string]interface{}, name string, method string, args ...interface{}) (interface{}, error)

RootCall cal javascript function

func (*Yao) RootLoad added in v0.10.2

func (yao *Yao) RootLoad(filename string, name string) error

RootLoad load and compile script

func (*Yao) RootLoadReader added in v0.10.2

func (yao *Yao) RootLoadReader(reader io.Reader, name string, filename ...string) error

RootLoadReader load and compile script

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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