jego

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

README

JEGO

extendable JS runner for Golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

func New

func New() *Engine

func (*Engine) Script

func (e *Engine) Script(buff io.Reader) (Script, error)

func (*Engine) SetRegistery added in v0.3.0

func (e *Engine) SetRegistery(mr ModuleRegistery) *Engine

type FuncModule added in v0.2.0

type FuncModule func() (any, error)

func (FuncModule) Copy added in v0.2.0

func (fm FuncModule) Copy() Module

func (FuncModule) Require added in v0.2.0

func (fm FuncModule) Require() (any, error)

type JSObject

type JSObject = js.Object

type Module

type Module interface {
	Require() (any, error)
	Copy() Module
}

func JSModule added in v0.3.0

func JSModule(src io.Reader, registery ...ModuleRegistery) (Module, error)

func ValueModule added in v0.2.0

func ValueModule(v any) Module

type ModuleRegistery added in v0.2.0

type ModuleRegistery interface {
	Register(name string, mod Module)
	Copy() ModuleRegistery
	Require(name string) (any, error)
}

func NewRegistery added in v0.3.0

func NewRegistery(defaultRequire ...func(name string) (any, error)) ModuleRegistery

type Object added in v0.2.0

type Object = otto.Object

func GetObject added in v0.2.0

func GetObject(vm VM, field string, nesteds ...string) (*Object, error)

type Script

type Script interface {
	Run(ctx context.Context, arg any) (any, error)
	GetExport(name string) (any, error)
	GetValue(name string) (Value, error)
	GetObject(name string) (*Object, error)
}

type VM added in v0.2.0

type VM = *otto.Otto

type Value added in v0.2.0

type Value = otto.Value

func GetValue added in v0.2.0

func GetValue(vm VM, field string, nesteds ...string) (res Value, err error)

Directories

Path Synopsis
lib

Jump to

Keyboard shortcuts

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