engine

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenOSFilesystem

func OpenOSFilesystem(base string) afero.Fs

Types

type E

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

E contains the engine used to run all javascript code

func New

func New() (*E, error)

New returns an empty engine with the bare minimum global objects required to run any workload

func (*E) AddBuiltin

func (e *E) AddBuiltin(name string, sensitive bool, module moduleDefiner) error

AddBuiltin module, if the module is marked as sensitve, the module will be marked as dangerous and restrict (users need to call Unrestrict to enable the module for local/trusted scripts).

If senstive is false, the module will be available for local/trusted scripts right after this function returns.

To add a module for remote use, call AddRemoteBuiltin.

func (*E) AddRemoteBuiltin

func (e *E) AddRemoteBuiltin(name string, module moduleDefiner) error

AddRemoteBuiltin adds the given module and exposes it to all scripts (local/trusted/remote)

Be careful with which types of modules are defined for remote scripts as there won't be any restrictions on what functions a remote script can make.

func (*E) AnchorModules

func (e *E) AnchorModules(path string) error

func (*E) Close

func (e *E) Close() error

func (*E) ConnectStdio

func (e *E) ConnectStdio(in io.Reader, out, err io.Writer)

ConnectStdio changes the std in/out/err streams from the default descard ones to ones that connect to the given ones.

If an entry is nil, the one already configured in the engine is kept

func (*E) InteractiveEval

func (e *E) InteractiveEval(code string) (interface{}, error)

func (*E) IsRestrictedModule

func (e *E) IsRestrictedModule(err error) (error, bool)

func (*E) SetStderr

func (e *E) SetStderr(buf io.Writer) error

func (*E) Unrestrict

func (e *E) Unrestrict(name string)

Unrestrict the given module and allows access to it from local sources or other trusted sources.

Jump to

Keyboard shortcuts

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