gojs

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 19 Imported by: 6

README

gojs

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportForDev added in v0.1.0

func ExportForDev() string

func FindPath added in v0.1.0

func FindPath(vm *goja.Runtime, filename string) string

func GetFunc added in v0.1.0

func GetFunc(v goja.Value) goja.Callable

func GetLogger added in v0.1.0

func GetLogger(vm *goja.Runtime) *log.Logger

func Register added in v0.1.0

func Register(name string, mod Module)

func Run

func Run(code string, refFile string, args ...any) (any, error)

func RunFile

func RunFile(file string, args ...any) (any, error)

func RunProgram added in v0.1.3

func RunProgram(plg *Program, args ...any) (any, error)

Types

type Args added in v0.1.0

type Args struct {
	This      goja.Value
	Arguments []goja.Value
	VM        *goja.Runtime
	Logger    *log.Logger
}

func MakeArgs added in v0.1.0

func MakeArgs(args *goja.FunctionCall, vm *goja.Runtime) *Args

func (*Args) Any added in v0.1.0

func (args *Args) Any(index int) any

func (*Args) Arr added in v0.1.0

func (args *Args) Arr(startIndex int) []any

func (*Args) Bool added in v0.1.0

func (args *Args) Bool(index int) bool

func (*Args) Bytes added in v0.1.0

func (args *Args) Bytes(index int) []byte

func (*Args) Check added in v0.1.0

func (args *Args) Check(num int) *Args

func (*Args) Func added in v0.1.0

func (args *Args) Func(index int) goja.Callable

func (*Args) Int added in v0.1.0

func (args *Args) Int(index int) int

func (*Args) Int64 added in v0.1.0

func (args *Args) Int64(index int) int64

func (*Args) Map added in v0.1.0

func (args *Args) Map(index int) map[string]any

func (*Args) Map2Arr added in v0.1.0

func (args *Args) Map2Arr(index int) []any

func (*Args) Map2StrArr added in v0.1.0

func (args *Args) Map2StrArr(index int) []string

func (*Args) Obj added in v0.1.0

func (args *Args) Obj(index int) *Obj

func (*Args) Object added in v0.1.3

func (args *Args) Object(index int) *goja.Object

func (*Args) Path added in v0.1.0

func (args *Args) Path(index int) string

func (*Args) Str added in v0.1.0

func (args *Args) Str(index int) string

func (*Args) StrArr added in v0.1.0

func (args *Args) StrArr(startIndex int) []string

type LB added in v0.1.3

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

func NewLB added in v0.1.3

func NewLB(plg *Program, opt LBConfig, logger *log.Logger) *LB

func NewLBByCode added in v0.1.3

func NewLBByCode(code, refFile string, opt LBConfig, logger *log.Logger) *LB

func NewLBByFile added in v0.1.3

func NewLBByFile(file string, opt LBConfig, logger *log.Logger) *LB

func (*LB) Get added in v0.1.3

func (p *LB) Get() *Runtime

type LBConfig added in v0.1.3

type LBConfig struct {
	Num   uint
	Args  []any
	Debug bool
}

type Map added in v0.1.0

type Map = map[string]any

func MakeLogger added in v0.1.3

func MakeLogger(logger *log.Logger) Map

func MakeMap added in v0.1.3

func MakeMap(structObj any) Map

type Module added in v0.1.0

type Module struct {
	Object      Map
	ObjectMaker func(vm *goja.Runtime) Map
	TsCode      string
	Desc        string
	Example     string
}

type Obj added in v0.1.3

type Obj struct {
	This   goja.Value
	VM     *goja.Runtime
	Logger *log.Logger
	O      *goja.Object
}

func (*Obj) Any added in v0.1.3

func (obj *Obj) Any(name string) any

func (*Obj) Arr added in v0.1.3

func (obj *Obj) Arr(name string) []any

func (*Obj) Bool added in v0.1.3

func (obj *Obj) Bool(name string) bool

func (*Obj) Bytes added in v0.1.3

func (obj *Obj) Bytes(name string) []byte

func (*Obj) Func added in v0.1.3

func (obj *Obj) Func(name string) goja.Callable

func (*Obj) Get added in v0.1.3

func (obj *Obj) Get(name string) goja.Value

func (*Obj) Int added in v0.1.3

func (obj *Obj) Int(name string) int

func (*Obj) Int64 added in v0.1.3

func (obj *Obj) Int64(name string) int64

func (*Obj) Map added in v0.1.3

func (obj *Obj) Map(name string) map[string]any

func (*Obj) Object added in v0.1.3

func (obj *Obj) Object(name string) *goja.Object

func (*Obj) Path added in v0.1.3

func (obj *Obj) Path(name string) string

func (*Obj) Str added in v0.1.3

func (obj *Obj) Str(name string) string

type Pool added in v0.1.3

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

func NewPool added in v0.1.3

func NewPool(plg *Program, opt PoolConfig, logger *log.Logger) *Pool

func NewPoolByCode added in v0.1.3

func NewPoolByCode(code, refFile string, opt PoolConfig, logger *log.Logger) *Pool

func NewPoolByFile added in v0.1.3

func NewPoolByFile(file string, opt PoolConfig, logger *log.Logger) *Pool

func (*Pool) Count added in v0.1.3

func (p *Pool) Count() (total, maxTotal, maxWaiting, createTimes uint)

func (*Pool) Get added in v0.1.3

func (p *Pool) Get() *Runtime

func (*Pool) Put added in v0.1.3

func (p *Pool) Put(rt *Runtime)

type PoolConfig added in v0.1.3

type PoolConfig struct {
	Min, Idle, Max uint
	Args           []any
	Debug          bool
}

type Program added in v0.1.3

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

func CompileCode added in v0.1.3

func CompileCode(code string, refFile string) (*Program, error)

func CompileFile added in v0.1.3

func CompileFile(file string) (*Program, error)

func CompileMain added in v0.1.3

func CompileMain(code string, refFile string) (*Program, error)

type Runtime added in v0.1.0

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

func New

func New() *Runtime

func (*Runtime) GetCallStack added in v0.1.0

func (rt *Runtime) GetCallStack() []string

func (*Runtime) GetGoData added in v0.1.0

func (rt *Runtime) GetGoData(name string) any

func (*Runtime) RunCode added in v0.1.0

func (rt *Runtime) RunCode(code string) (any, error)

func (*Runtime) RunFile added in v0.1.3

func (rt *Runtime) RunFile(file string) (any, error)

func (*Runtime) RunMain added in v0.1.0

func (rt *Runtime) RunMain(args ...any) (any, error)

func (*Runtime) RunProgram added in v0.1.3

func (rt *Runtime) RunProgram(prg *Program) (any, error)

func (*Runtime) RunVM added in v0.1.3

func (rt *Runtime) RunVM(callback func(vm *goja.Runtime) (any, error)) (any, error)

func (*Runtime) Set added in v0.1.0

func (rt *Runtime) Set(name string, value any) error

func (*Runtime) SetGlobal added in v0.1.0

func (rt *Runtime) SetGlobal(global Map) error

func (*Runtime) SetGoData added in v0.1.0

func (rt *Runtime) SetGoData(name string, value any)

func (*Runtime) SetModuleLoader added in v0.1.0

func (rt *Runtime) SetModuleLoader(fn func(filename string) string)

func (*Runtime) StartFromCode added in v0.1.0

func (rt *Runtime) StartFromCode(code, refFile string) error

func (*Runtime) StartFromFile added in v0.1.0

func (rt *Runtime) StartFromFile(file string) error

func (*Runtime) StartFromProgram added in v0.1.3

func (rt *Runtime) StartFromProgram(plg *Program) error

type WatchRunner added in v0.1.0

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

func WatchRun added in v0.1.0

func WatchRun(file string, extDirs, extTypes []string, args ...any) (*WatchRunner, error)

func (*WatchRunner) Stop added in v0.1.0

func (wr *WatchRunner) Stop()

func (*WatchRunner) WaitForKill added in v0.1.0

func (wr *WatchRunner) WaitForKill()

Directories

Path Synopsis
dop251
base64dec
Package base64dec contains a universal base64 decoder that works on both the standard and url-safe variants, padded and raw.
Package base64dec contains a universal base64 decoder that works on both the standard and url-safe variants, padded and raw.
goja/ast
Package ast declares types representing a JavaScript AST.
Package ast declares types representing a JavaScript AST.
goja/file
Package file encapsulates the file abstractions used by the ast & parser.
Package file encapsulates the file abstractions used by the ast & parser.
goja/ftoa
Package ftoa provides ECMAScript-compliant floating point number conversion to string.
Package ftoa provides ECMAScript-compliant floating point number conversion to string.
goja/ftoa/internal/fast
Package fast contains code ported from V8 (https://github.com/v8/v8/blob/master/src/numbers/fast-dtoa.cc)
Package fast contains code ported from V8 (https://github.com/v8/v8/blob/master/src/numbers/fast-dtoa.cc)
goja/parser
Package parser implements a parser for JavaScript.
Package parser implements a parser for JavaScript.
goja/token
Package token defines constants representing the lexical tokens of JavaScript (ECMA5).
Package token defines constants representing the lexical tokens of JavaScript (ECMA5).
goja/unistring
Package unistring contains an implementation of a hybrid ASCII/UTF-16 string.
Package unistring contains an implementation of a hybrid ASCII/UTF-16 string.
db
log

Jump to

Keyboard shortcuts

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