javascript

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultRuleTimeout = 5 * time.Second

DefaultRuleTimeout is the default timeout for JavaScript rule execution

Variables

This section is empty.

Functions

func BuildVM added in v0.14.2

func BuildVM() *goja.Runtime

BuildVM returns a new goja runtime, a VM if you will.

Types

type CoreFunction

type CoreFunction func(input any, context model.RuleFunctionContext) []model.RuleFunctionResult

type JSEnabledRuleFunction

type JSEnabledRuleFunction interface {
	RunRule(nodes []*yaml.Node, context model.RuleFunctionContext) []model.RuleFunctionResult
	GetSchema() model.RuleFunctionSchema
	CheckScript() error
	RunScript() error
	RegisterCoreFunction(name string, function CoreFunction)
	GetCategory() string
}

func NewJSRuleFunction

func NewJSRuleFunction(ruleName, script string) JSEnabledRuleFunction

type JSRuleFunction

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

func (*JSRuleFunction) CheckScript

func (j *JSRuleFunction) CheckScript() error

func (*JSRuleFunction) GetCategory added in v0.10.0

func (j *JSRuleFunction) GetCategory() string

func (*JSRuleFunction) GetSchema

func (j *JSRuleFunction) GetSchema() model.RuleFunctionSchema

func (*JSRuleFunction) GetSchemaWithError added in v0.34.0

func (j *JSRuleFunction) GetSchemaWithError() (model.RuleFunctionSchema, error)

GetSchemaWithError evaluates bounded metadata without hiding script failures. Strict execution uses this method; GetSchema preserves its legacy fallback.

func (*JSRuleFunction) RegisterCoreFunction

func (j *JSRuleFunction) RegisterCoreFunction(name string, function CoreFunction)

func (*JSRuleFunction) RunRule

func (j *JSRuleFunction) RunRule(nodes []*yaml.Node, ruleContext model.RuleFunctionContext) []model.RuleFunctionResult

func (*JSRuleFunction) RunScript

func (j *JSRuleFunction) RunScript() error

func (*JSRuleFunction) SetTimeout added in v0.22.0

func (j *JSRuleFunction) SetTimeout(timeout time.Duration)

SetTimeout sets the timeout for async rule execution. If not set, DefaultRuleTimeout (5 seconds) is used.

Directories

Path Synopsis
Package eventloop provides an event loop implementation for running asynchronous JavaScript code with Goja.
Package eventloop provides an event loop implementation for running asynchronous JavaScript code with Goja.
fetch
Package fetch provides a Web Fetch API compliant implementation for use with Goja JavaScript runtime and the vacuum event loop.
Package fetch provides a Web Fetch API compliant implementation for use with Goja JavaScript runtime and the vacuum event loop.

Jump to

Keyboard shortcuts

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