Documentation
¶
Overview ¶
Package script runs TypeScript/JavaScript numerical design scripts inside the process — no Node.js install required.
Pipeline: TS/JS source → esbuild (transpile only) → goja VM. Host APIs are injected as the global `gnd`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HostAPI ¶
type HostAPI interface {
// Curve evaluates a growth curve. kind: linear|exponential|logarithmic|power|sigmoid|quadratic|piecewise-log
Curve(kind string, x float64, params map[string]float64) (float64, error)
// Damage expected damage.
Damage(in map[string]float64, typ string) (float64, error)
// SimBattle runs n 1v1 fights, returns map with win_rate, avg_turns, ...
SimBattle(attacker, defender map[string]any, n int, seed int64) (map[string]any, error)
// LoadTable reads csv/tsv/json/yaml/xlsx into {headers, rows}.
LoadTable(path string, sheet string) (map[string]any, error)
// ReadJSON reads a JSON file into a JS value.
ReadJSON(path string) (any, error)
// WriteJSON writes a value as pretty JSON.
WriteJSON(path string, v any) error
// Log prints to CLI stdout.
Log(args ...any)
}
HostAPI is implemented by the CLI to expose numerical tools to scripts.
type Options ¶
type Options struct {
// TimeoutMS for the whole script (0 = default 30s).
TimeoutMS int
// WorkingDir for relative file access inside host APIs.
WorkingDir string
// Globals extra key→value injected before run (JSON-serializable).
Globals map[string]any
// Host injects native functions onto the `gnd` object.
Host HostAPI
}
Options tune execution.
Click to show internal directories.
Click to hide internal directories.