jsrt

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package jsrt provides a goja-based JavaScript implementation of script.Runtime.

Index

Constants

This section is empty.

Variables

View Source
var ErrVMPoolExhausted = errdefs.NotAvailable(errors.New("jsrt: VM pool exhausted, context cancelled while waiting"))

ErrVMPoolExhausted is returned when all VMs are in use and the context is cancelled before one becomes available.

Functions

This section is empty.

Types

type Option

type Option func(*Runtime)

Option configures a Runtime.

func WithPoolSize

func WithPoolSize(n int) Option

WithPoolSize sets the VM pool size.

type Runtime

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

Runtime manages a pool of goja VMs for JS script execution. It implements script.Runtime.

func New

func New(opts ...Option) *Runtime

New creates a new JS runtime with a VM pool.

func (*Runtime) Exec

func (r *Runtime) Exec(ctx context.Context, name, source string, env *script.Env) (*script.Signal, error)

Exec implements script.Runtime. It runs a JS script in a pooled VM with the given environment (config + bindings) injected as globals. A built-in "signal" global is always injected, providing interrupt/error/done control flow back to the host.

Jump to

Keyboard shortcuts

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