Documentation ¶
Index ¶
- Variables
- func CharPosOfErr(err error) int
- type CallInfo
- type Context
- type Extender
- type Op
- type OpInfo
- type RefInfo
- type Value
- func Array(values []Value) 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(o interface{}) Value
- func String(s string) Value
- func Uint64(x uint64) Value
- func (a Value) Array() []Value
- func (a Value) At(i int) Value
- func (a Value) Bool() bool
- func (a Value) Float64() float64
- func (a Value) Int64() int64
- func (a Value) IsArray() bool
- func (a Value) IsNull() bool
- func (a Value) IsUndefined() bool
- func (a Value) Len() int
- func (a Value) Number() float64
- func (a Value) Object() any
- func (a Value) String() string
- func (a Value) TypeOf() string
- func (a Value) Uint64() uint64
- func (a Value) Value() any
Constants ¶
This section is empty.
Variables ¶
var ( Undefined = Value{/* contains filtered or unexported fields */} Null = Value{/* contains filtered or unexported fields */} )
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 Context ¶
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 ¶
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.
func (Value) At ¶
At returns a value from an array at index. Returns 'undefined' if the value is not an array or the index is outside of the bounds.
func (Value) IsUndefined ¶
IsUndefined returns true if the value is 'undefined'