engine

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine interface {
	// SetState sets the given state s
	// to the global state of the runtime.
	SetState(s State)

	// Set sets the given value by the given
	// name to the global context of the runtime.
	Set(name string, v any) error

	// Run executes the given script in the
	// runtime.
	Run(script string) error

	// State returns a map of all set
	// variables in the global state
	// which are not of the type 'function'.
	State() State
}

Engine defines a service which can run scripts.

func NewGoja

func NewGoja() Engine

NewGoja initializes the Goja engine runtime and sets builtin functions to the global scope.

type Exception added in v0.7.0

type Exception struct {
	errs.InnerError

	Msg string
}

Exception wraps an engine execution error and holds a simple message concluding the error.

func (Exception) Error added in v0.7.0

func (t Exception) Error() string

type Goja

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

Goja is the Engine implementation using ECMAScript 5.

func (*Goja) Run

func (t *Goja) Run(script string) error

func (*Goja) Set added in v0.7.0

func (t *Goja) Set(name string, v any) error

func (*Goja) SetState

func (t *Goja) SetState(s State)

func (*Goja) State

func (t *Goja) State() State

type State

type State map[string]any

State holds a key-value definition of globally availabe variables in a runtime.

func (State) Merge

func (t State) Merge(with State)

Merge applies the entries from with to the current state. Already set keys will be overwritten.

func (State) String added in v0.4.0

func (t State) String() string

Jump to

Keyboard shortcuts

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