expr

package
v2.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultJSTimeout = 250 * time.Millisecond

DefaultJSTimeout is the default per-evaluation timeout applied when callers don't specify their own. Exposed as a constant so the CLI and tests can share the value.

Variables

This section is empty.

Functions

func Compile added in v2.13.0

func Compile(source string) error

Compile checks that source is valid Javascript without running it. Evaluation swallows errors, so this is the only way to catch a broken expression before it syncs as nil.

func EvaluateArray

func EvaluateArray[ReturnType any](ctx context.Context, logger kitlog.Logger, source string, subject any, timeout time.Duration) ([]ReturnType, error)

func EvaluateJavascript

func EvaluateJavascript(ctx context.Context, logger kitlog.Logger, source string, subject any, timeout time.Duration) (result otto.Value, err error)

EvaluateJavascript can evaluate a source Javascript program having set the given subject into the `$` variable. Evaluation is bounded by timeout; if it elapses, the underlying Otto VM is interrupted and the call surfaces as a panic.

func EvaluateResultType

func EvaluateResultType[ReturnType any](ctx context.Context, logger kitlog.Logger, source string, result otto.Value) (*ReturnType, error)

func EvaluateSingleValue

func EvaluateSingleValue[ReturnType any](ctx context.Context, logger kitlog.Logger, source string, subject any, timeout time.Duration) (*ReturnType, error)

func SafelyGo

func SafelyGo(do func())

Types

This section is empty.

Jump to

Keyboard shortcuts

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