Documentation ¶
Index ¶
- Variables
- func CharPosOfErr(err error) int
- type Args
- type CallInfo
- type ComputedArgs
- type Context
- type Extender
- type Op
- type OpInfo
- type RefInfo
- type Value
- func Bool(t bool) Value
- func Eval(expr string, ctx *Context) (Value, error)
- func EvalForEach(expr string, iter func(value Value) error, ctx *Context) (Value, error)
- func Float64(x float64) Value
- func Function(name string) Value
- func Int64(x int64) Value
- func Number(x float64) Value
- func Object(v interface{}) Value
- func String(s string) Value
- func Uint64(x uint64) Value
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Undefined = Value{/* contains filtered or unexported fields */} Null = Value{/* contains filtered or unexported fields */} )
View Source
var ErrStop = errors.New("stop")
ErrStop is used to stop the EvalForEach and ForEachValue
Functions ¶
func CharPosOfErr ¶
CharPosOfErr returns the character position of where the error occured in the Eval function, or -1 if unknown
Types ¶
type Args ¶ added in v0.7.0
type Args struct {
// contains filtered or unexported fields
}
func (*Args) Compute ¶ added in v0.7.0
func (args *Args) Compute() (ComputedArgs, error)
type ComputedArgs ¶ added in v0.7.0
type ComputedArgs struct {
// contains filtered or unexported fields
}
func (*ComputedArgs) Get ¶ added in v0.7.0
func (args *ComputedArgs) Get(index int) Value
func (*ComputedArgs) Len ¶ added in v0.7.0
func (args *ComputedArgs) Len() int
type Context ¶ added in v0.6.0
type Context struct { UserData any Extender Extender NoCase bool // Disable case insensitive string comparisons }
Context for Eval
type Extender ¶
type Extender interface { // ref allows for custom evaluation of an property or variable. Ref(info RefInfo, ctx *Context) (Value, error) // Op allows for custom opererators on values. Op(info OpInfo, ctx *Context) (Value, error) // Call allows for function call for custom values. Call(info CallInfo, ctx *Context) (Value, error) }
func NewExtender ¶
func NewExtender( ref func(info RefInfo, ctx *Context) (Value, error), call func(info CallInfo, ctx *Context) (Value, error), op func(info OpInfo, ctx *Context) (Value, error), ) Extender
NewExtender is a convenience function for creating a simple extender using the provided eval and op functions.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value represents is the return value of Eval.
func EvalForEach ¶ added in v0.6.0
EvalForEach iterates over a series of comma delimited expressions. The last value in the series is returned. Returning ErrStop will stop the iteration early and return the last known value and nil as an error. Returning any other error from iter will stop the iteration and return the same error.
Click to show internal directories.
Click to hide internal directories.