gojs

package
v3.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: MIT Imports: 5 Imported by: 52

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidFuncOpts = errorutil.NewWithFmt("invalid function options: %v")
	ErrNilRuntime      = errorutil.New("runtime is nil")
)

Functions

func GetClassConstructor added in v3.2.0

func GetClassConstructor[T any](instance *T) func(call goja.ConstructorCall, runtime *goja.Runtime) *goja.Object

GetClassConstructor returns a constructor for any given go struct type for goja runtime

func RegisterFuncWithSignature

func RegisterFuncWithSignature(runtime *goja.Runtime, opts FuncOpts) error

RegisterFunc registers a function with given name, signatures and description

Types

type FuncOpts

type FuncOpts struct {
	Name        string
	Signatures  []string
	Description string
	FuncDecl    interface{}
}

type GojaModule

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

func (*GojaModule) Enable

func (p *GojaModule) Enable(runtime Runtime)

func (*GojaModule) Name

func (p *GojaModule) Name() string

func (*GojaModule) Register

func (p *GojaModule) Register() Module

func (*GojaModule) Require

func (p *GojaModule) Require(runtime *goja.Runtime, module *goja.Object)

func (*GojaModule) Set

func (p *GojaModule) Set(objects Objects) Module

func (*GojaModule) String

func (p *GojaModule) String() string

type Module

type Module interface {
	Name() string
	Set(objects Objects) Module
	Enable(Runtime)
	Register() Module
}

func NewGojaModule

func NewGojaModule(name string) Module

type Object

type Object interface {
	Set(string, interface{})
	Get(string) interface{}
}

type Objects

type Objects map[string]interface{}

type Runtime

type Runtime interface {
	Set(string, interface{}) error
}

Jump to

Keyboard shortcuts

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