process

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package process installs a Node-like `process` global on a gojs VM. It is a thin shim over the VM's capability providers — nothing here touches the host directly:

  • process.stdout.write / process.stderr.write route through the VM's PrintProvider (the same sink as console), so an embedder that redirects console output to a log or web app captures process output too. Writes are line-buffered (the PrintProvider is line-oriented); a trailing partial line is flushed on process.exit.
  • process.exit / cwd / env / platform / arch / pid come from the VM's OsProvider. Without one, those facilities are simply absent — a sandboxed VM cannot exit the host, read its environment, or learn what it runs on.
  • process.hrtime uses the TimeProvider; process.nextTick uses the microtask queue.

Only argv is supplied here (the invocation); everything else is a capability the host grants and can intercept.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*config)

Option configures the installed process object.

func WithArgs

func WithArgs(argv ...string) Option

WithArgs sets process.argv (the full vector, including argv[0]).

type Process

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

Process is a handle to an installed process global. It lets the embedder flush buffered stdout/stderr when the program finishes so a trailing write() with no newline is not lost.

func Install

func Install(vm *gojs.VM, opts ...Option) (*Process, error)

Install adds the process global to vm, backed by vm's providers, and returns a handle whose Flush emits any buffered trailing stdout/stderr output when the program finishes.

func (*Process) Flush

func (p *Process) Flush()

Flush emits any buffered trailing partial line on process.stdout/stderr. A standalone runner calls this once the program (and its event loop) has completed; process.exit flushes on its own path.

Jump to

Keyboard shortcuts

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