commons

package
v0.3.33 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: BSD-3-Clause Imports: 4 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// reserved js variables
	ObjClosable = "_closable"

	// errors
	ErrorMissingParam = "missing_param"
)

Variables

This section is empty.

Functions

func AddClosableObject

func AddClosableObject(runtime *goja.Runtime, object *goja.Object)

func AsExport

func AsExport(value goja.Value) interface{}

func AsObject

func AsObject(value goja.Value) *goja.Object

func CloseObjects

func CloseObjects(runtime *goja.Runtime)

func GetArgsIntStringString

func GetArgsIntStringString(context interface{}, args []goja.Value) (int, string, string)

func GetArgsString

func GetArgsString(context interface{}, args []goja.Value) string

func GetArgsStringString

func GetArgsStringString(context interface{}, args []goja.Value) (string, string)

func GetArgsStringStringString

func GetArgsStringStringString(context interface{}, args []goja.Value) (string, string, string)

func GetArray

func GetArray(call goja.FunctionCall, index int) []interface{}

func GetArrayOfString

func GetArrayOfString(call goja.FunctionCall, index int) []string

func GetBool

func GetBool(call goja.FunctionCall, index int) bool

func GetCallbackIfAny

func GetCallbackIfAny(call goja.FunctionCall) goja.Callable

func GetExport

func GetExport(call goja.FunctionCall, index int) interface{}

func GetInt

func GetInt(call goja.FunctionCall, index int) int64

func GetMap

func GetMap(call goja.FunctionCall, index int) map[string]interface{}

func GetObject

func GetObject(obj interface{}, name string) *goja.Object

func GetRtDeepExport

func GetRtDeepExport(runtime *goja.Runtime, name string) interface{}

func GetRtDeepObject

func GetRtDeepObject(runtime *goja.Runtime, name string) *goja.Object

func GetRtDeepValue

func GetRtDeepValue(runtime *goja.Runtime, name string) goja.Value

func GetRtObject

func GetRtObject(runtime *goja.Runtime, name string) interface{}

func GetRtRoot

func GetRtRoot(runtime *goja.Runtime) string

func GetString

func GetString(call goja.FunctionCall, index int) string

func SetRtRoot

func SetRtRoot(runtime *goja.Runtime, value string)

func ToArray

func ToArray(v interface{}) []interface{}

func ToArrayOfMap

func ToArrayOfMap(val interface{}) []map[string]interface{}

Types

type EventLoop

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

func NewEventLoop

func NewEventLoop(vm *goja.Runtime) *EventLoop

func (*EventLoop) Run

func (loop *EventLoop) Run(fn func(*goja.Runtime))

Run calls the specified function, starts the event loop and waits until there are no more delayed jobs to run after which it stops the loop and returns. The instance of goja.Runtime that is passed to the function and any Values derived from it must not be used outside of the function.

func (*EventLoop) RunOnLoop

func (loop *EventLoop) RunOnLoop(fn func(*goja.Runtime))

RunOnLoop schedules to run the specified function in the context of the loop as soon as possible. The order of the runs is preserved (i.e. the functions will be called in the same order as calls to RunOnLoop()) The instance of goja.Runtime that is passed to the function and any Values derived from it must not be used outside of the function.

func (*EventLoop) Start

func (loop *EventLoop) Start()

Start the event loop in the background. The loop continues to run until Stop() is called.

func (*EventLoop) Stop

func (loop *EventLoop) Stop()

Stop the loop that was started with Start(). After this function returns there will be no more jobs executed by the loop. It is possible to call Start() or Run() again after this to resume the execution.

type ModuleInfo

type ModuleInfo struct {
	Context *RuntimeContext
	Loader  ModuleLoader
}

type ModuleLoader

type ModuleLoader func(*goja.Runtime, *goja.Object, ...interface{})

type RuntimeContext

type RuntimeContext struct {
	Uid       *string
	Workspace string
	Runtime   *goja.Runtime
	Arguments []interface{}
}

Jump to

Keyboard shortcuts

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