script

package
v0.0.0-...-6d0822f Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exception

func Exception(msg string) goja.Value

func Run

func Run(code string, variables VariableSource) (interface{}, error)

Run executes the given code with the provided variable context. The resulting value and a potential error is returned.

func RunContained

func RunContained(code string, variables VariableSource) (interface{}, error)

RunContainer executes the given code in a separate runtime with the provided variable context. It behaves like Run but it supports multi threading by using it's own separate runtime for each call.

func Setup

func Setup()

Types

type Script

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

func NewScript

func NewScript(name string, src string) (Script, error)

func (*Script) Call

func (s *Script) Call(variables VariableSource, arguments ...interface{}) (interface{}, error)

Call executes the script in the assumption that it defines a function. It will then call this function using the provided arguments. The value returned by that function will in turn be returned by this method.

func (*Script) Run

func (s *Script) Run(variables VariableSource) (interface{}, error)

type Variable

type Variable interface {
	GetValue() interface{}
	SetValue(interface{}) error
}

type VariableBridge

type VariableBridge struct {
	Source VariableSource
}

func (*VariableBridge) Delete

func (b *VariableBridge) Delete(key string) bool

func (*VariableBridge) Get

func (b *VariableBridge) Get(key string) goja.Value

func (*VariableBridge) Has

func (b *VariableBridge) Has(key string) bool

func (*VariableBridge) Keys

func (b *VariableBridge) Keys() []string

func (*VariableBridge) Set

func (b *VariableBridge) Set(key string, value goja.Value) bool

type VariableSource

type VariableSource interface {
	ResolveVariable(string) (interface{}, bool)
}

Jump to

Keyboard shortcuts

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