node

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Dir is the working directory for the VM. Default is the same working
	// directory and currently running Go process.
	Dir string
	// Flags are the additional startup flags that are provided to the "node"
	// process.
	Flags []string
	// sort is the port to run the websocket server on. This defaults to 6543.
	Port int
	// Stdout is the output writer for the VM. Default is os.Stdout.
	Stdout io.Writer
	// Stderr is the error writer for the VM. Default is os.Stderr.
	Stderr io.Writer
	// Env is the environment variables to be set for the VM.
	Env []string
	// NodeProcesses is the number of node processes to run. Default is 5.
	NodeProcesses int
	// Logger is the logger to be used for the VM.
	Logger *slog.Logger
}

Options for VM

type VM

type VM interface {
	Run(javascript string) (any, error)
	Close() error
}

VM is a Javascript Virtual Machine running on Node.js

func MustNewNodeJS

func MustNewNodeJS(options ...Options) VM

func NewNodeJS

func NewNodeJS(options ...Options) (VM, error)

Returns a Javascript Virtual Machine running an isolated process of Node.js.

Jump to

Keyboard shortcuts

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