Documentation ¶
Index ¶
- Variables
- func AllModuleNames() []string
- func FuncAFFRF(fn func(float64, float64) float64) tengo.CallableFunc
- func FuncAFIRB(fn func(float64, int) bool) tengo.CallableFunc
- func FuncAFIRF(fn func(float64, int) float64) tengo.CallableFunc
- func FuncAFRB(fn func(float64) bool) tengo.CallableFunc
- func FuncAFRF(fn func(float64) float64) tengo.CallableFunc
- func FuncAFRI(fn func(float64) int) tengo.CallableFunc
- func FuncAI64R(fn func(int64)) tengo.CallableFunc
- func FuncAI64RI64(fn func(int64) int64) tengo.CallableFunc
- func FuncAIFRF(fn func(int, float64) float64) tengo.CallableFunc
- func FuncAIIRE(fn func(int, int) error) tengo.CallableFunc
- func FuncAIR(fn func(int)) tengo.CallableFunc
- func FuncAIRF(fn func(int) float64) tengo.CallableFunc
- func FuncAIRIs(fn func(int) []int) tengo.CallableFunc
- func FuncAIRS(fn func(int) string) tengo.CallableFunc
- func FuncAIRSsE(fn func(int) ([]string, error)) tengo.CallableFunc
- func FuncAR(fn func()) tengo.CallableFunc
- func FuncARB(fn func() bool) tengo.CallableFunc
- func FuncARE(fn func() error) tengo.CallableFunc
- func FuncARF(fn func() float64) tengo.CallableFunc
- func FuncARI(fn func() int) tengo.CallableFunc
- func FuncARI64(fn func() int64) tengo.CallableFunc
- func FuncARIsE(fn func() ([]int, error)) tengo.CallableFunc
- func FuncARS(fn func() string) tengo.CallableFunc
- func FuncARSE(fn func() (string, error)) tengo.CallableFunc
- func FuncARSs(fn func() []string) tengo.CallableFunc
- func FuncARYE(fn func() ([]byte, error)) tengo.CallableFunc
- func FuncASI64RE(fn func(string, int64) error) tengo.CallableFunc
- func FuncASIIRE(fn func(string, int, int) error) tengo.CallableFunc
- func FuncASIRS(fn func(string, int) string) tengo.CallableFunc
- func FuncASRE(fn func(string) error) tengo.CallableFunc
- func FuncASRIE(fn func(string) (int, error)) tengo.CallableFunc
- func FuncASRS(fn func(string) string) tengo.CallableFunc
- func FuncASRSE(fn func(string) (string, error)) tengo.CallableFunc
- func FuncASRSs(fn func(string) []string) tengo.CallableFunc
- func FuncASRYE(fn func(string) ([]byte, error)) tengo.CallableFunc
- func FuncASSIRSs(fn func(string, string, int) []string) tengo.CallableFunc
- func FuncASSRB(fn func(string, string) bool) tengo.CallableFunc
- func FuncASSRE(fn func(string, string) error) tengo.CallableFunc
- func FuncASSRI(fn func(string, string) int) tengo.CallableFunc
- func FuncASSRS(fn func(string, string) string) tengo.CallableFunc
- func FuncASSRSs(fn func(string, string) []string) tengo.CallableFunc
- func FuncASsSRS(fn func([]string, string) string) tengo.CallableFunc
- func FuncAYRIE(fn func([]byte) (int, error)) tengo.CallableFunc
- func FuncAYRS(fn func([]byte) string) tengo.CallableFunc
- func GetModuleMap(names ...string) *tengo.ModuleMap
Constants ¶
This section is empty.
Variables ¶
var BuiltinModules = map[string]map[string]tengo.Object{
"math": mathModule,
"text": textModule,
"times": timesModule,
"rand": randModule,
"fmt": fmtModule,
"json": jsonModule,
"base64": base64Module,
"hex": hexModule,
}
BuiltinModules are builtin type standard library modules.
var SourceModules = map[string]string{
"enum": "is_enumerable := func(x) {\n return is_array(x) || is_map(x) || is_immutable_array(x) || is_immutable_map(x)\n}\n\nis_array_like := func(x) {\n return is_array(x) || is_immutable_array(x)\n}\n\nexport {\n // all returns true if the given function `fn` evaluates to a truthy value on\n // all of the items in `x`. It returns undefined if `x` is not enumerable.\n all: func(x, fn) {\n if !is_enumerable(x) { return undefined }\n\n for k, v in x {\n if !fn(k, v) { return false }\n }\n\n return true\n },\n // any returns true if the given function `fn` evaluates to a truthy value on\n // any of the items in `x`. It returns undefined if `x` is not enumerable.\n any: func(x, fn) {\n if !is_enumerable(x) { return undefined }\n\n for k, v in x {\n if fn(k, v) { return true }\n }\n\n return false\n },\n // chunk returns an array of elements split into groups the length of size.\n // If `x` can't be split evenly, the final chunk will be the remaining elements.\n // It returns undefined if `x` is not array.\n chunk: func(x, size) {\n if !is_array_like(x) || !size { return undefined }\n\n numElements := len(x)\n if !numElements { return [] }\n\n res := []\n idx := 0\n for idx < numElements {\n res = append(res, x[idx:idx+size])\n idx += size\n }\n\n return res\n },\n // at returns an element at the given index (if `x` is array) or\n // key (if `x` is map). It returns undefined if `x` is not enumerable.\n at: func(x, key) {\n if !is_enumerable(x) { return undefined }\n\n if is_array_like(x) {\n if !is_int(key) { return undefined }\n } else {\n if !is_string(key) { return undefined }\n }\n\n return x[key]\n },\n // each iterates over elements of `x` and invokes `fn` for each element. `fn` is\n // invoked with two arguments: `key` and `value`. `key` is an int index\n // if `x` is array. `key` is a string key if `x` is map. It does not iterate\n // and returns undefined if `x` is not enumerable.\n each: func(x, fn) {\n if !is_enumerable(x) { return undefined }\n\n for k, v in x {\n fn(k, v)\n }\n },\n // filter iterates over elements of `x`, returning an array of all elements `fn`\n // returns truthy for. `fn` is invoked with two arguments: `key` and `value`.\n // `key` is an int index if `x` is array. It returns undefined if `x` is not array.\n filter: func(x, fn) {\n if !is_array_like(x) { return undefined }\n\n dst := []\n for k, v in x {\n if fn(k, v) { dst = append(dst, v) }\n }\n\n return dst\n },\n // find iterates over elements of `x`, returning value of the first element `fn`\n // returns truthy for. `fn` is invoked with two arguments: `key` and `value`.\n // `key` is an int index if `x` is array. `key` is a string key if `x` is map.\n // It returns undefined if `x` is not enumerable.\n find: func(x, fn) {\n if !is_enumerable(x) { return undefined }\n\n for k, v in x {\n if fn(k, v) { return v }\n }\n },\n // find_key iterates over elements of `x`, returning key or index of the first\n // element `fn` returns truthy for. `fn` is invoked with two arguments: `key`\n // and `value`. `key` is an int index if `x` is array. `key` is a string key if\n // `x` is map. It returns undefined if `x` is not enumerable.\n find_key: func(x, fn) {\n if !is_enumerable(x) { return undefined }\n\n for k, v in x {\n if fn(k, v) { return k }\n }\n },\n // map creates an array of values by running each element in `x` through `fn`.\n // `fn` is invoked with two arguments: `key` and `value`. `key` is an int index\n // if `x` is array. `key` is a string key if `x` is map. It returns undefined\n // if `x` is not enumerable.\n map: func(x, fn) {\n if !is_enumerable(x) { return undefined }\n\n dst := []\n for k, v in x {\n dst = append(dst, fn(k, v))\n }\n\n return dst\n },\n // key returns the first argument.\n key: func(k, _) { return k },\n // value returns the second argument.\n value: func(_, v) { return v }\n}\n",
}
SourceModules are source type standard library modules.
Functions ¶
func AllModuleNames ¶
func AllModuleNames() []string
AllModuleNames returns a list of all default module names.
func FuncAFFRF ¶
FuncAFFRF transform a function of 'func(float64, float64) float64' signature into CallableFunc type.
func FuncAFIRB ¶
FuncAFIRB transform a function of 'func(float64, int) bool' signature into CallableFunc type.
func FuncAFIRF ¶
FuncAFIRF transform a function of 'func(float64, int) float64' signature into CallableFunc type.
func FuncAFRB ¶
FuncAFRB transform a function of 'func(float64) bool' signature into CallableFunc type.
func FuncAFRF ¶
FuncAFRF transform a function of 'func(float64) float64' signature into CallableFunc type.
func FuncAFRI ¶
FuncAFRI transform a function of 'func(float64) int' signature into CallableFunc type.
func FuncAI64R ¶
func FuncAI64R(fn func(int64)) tengo.CallableFunc
FuncAI64R transform a function of 'func(int64)' signature into CallableFunc type.
func FuncAI64RI64 ¶
FuncAI64RI64 transform a function of 'func(int64) int64' signature into CallableFunc type.
func FuncAIFRF ¶
FuncAIFRF transform a function of 'func(int, float64) float64' signature into CallableFunc type.
func FuncAIIRE ¶
FuncAIIRE transform a function of 'func(int, int) error' signature into CallableFunc type.
func FuncAIR ¶
func FuncAIR(fn func(int)) tengo.CallableFunc
FuncAIR transform a function of 'func(int)' signature into CallableFunc type.
func FuncAIRF ¶
FuncAIRF transform a function of 'func(int) float64' signature into CallableFunc type.
func FuncAIRIs ¶
FuncAIRIs transform a function of 'func(int) []int' signature into CallableFunc type.
func FuncAIRS ¶
FuncAIRS transform a function of 'func(int) string' signature into CallableFunc type.
func FuncAIRSsE ¶
FuncAIRSsE transform a function of 'func(int) ([]string, error)' signature into CallableFunc type.
func FuncAR ¶
func FuncAR(fn func()) tengo.CallableFunc
FuncAR transform a function of 'func()' signature into CallableFunc type.
func FuncARB ¶
func FuncARB(fn func() bool) tengo.CallableFunc
FuncARB transform a function of 'func() bool' signature into CallableFunc type.
func FuncARE ¶
func FuncARE(fn func() error) tengo.CallableFunc
FuncARE transform a function of 'func() error' signature into CallableFunc type.
func FuncARF ¶
func FuncARF(fn func() float64) tengo.CallableFunc
FuncARF transform a function of 'func() float64' signature into CallableFunc type.
func FuncARI ¶
func FuncARI(fn func() int) tengo.CallableFunc
FuncARI transform a function of 'func() int' signature into CallableFunc type.
func FuncARI64 ¶
func FuncARI64(fn func() int64) tengo.CallableFunc
FuncARI64 transform a function of 'func() int64' signature into CallableFunc type.
func FuncARIsE ¶
FuncARIsE transform a function of 'func() ([]int, error)' signature into CallableFunc type.
func FuncARS ¶
func FuncARS(fn func() string) tengo.CallableFunc
FuncARS transform a function of 'func() string' signature into CallableFunc type.
func FuncARSE ¶
FuncARSE transform a function of 'func() (string, error)' signature into CallableFunc type.
func FuncARSs ¶
func FuncARSs(fn func() []string) tengo.CallableFunc
FuncARSs transform a function of 'func() []string' signature into CallableFunc type.
func FuncARYE ¶
FuncARYE transform a function of 'func() ([]byte, error)' signature into CallableFunc type.
func FuncASI64RE ¶
FuncASI64RE transform a function of 'func(string, int64) error' signature into CallableFunc type.
func FuncASIIRE ¶
FuncASIIRE transform a function of 'func(string, int, int) error' signature into CallableFunc type.
func FuncASIRS ¶
FuncASIRS transform a function of 'func(string, int) string' signature into CallableFunc type.
func FuncASRE ¶
FuncASRE transform a function of 'func(string) error' signature into CallableFunc type. User function will return 'true' if underlying native function returns nil.
func FuncASRIE ¶
FuncASRIE transform a function of 'func(string) (int, error)' signature into CallableFunc type.
func FuncASRS ¶
FuncASRS transform a function of 'func(string) string' signature into CallableFunc type. User function will return 'true' if underlying native function returns nil.
func FuncASRSE ¶
FuncASRSE transform a function of 'func(string) (string, error)' signature into CallableFunc type. User function will return 'true' if underlying native function returns nil.
func FuncASRSs ¶
FuncASRSs transform a function of 'func(string) []string' signature into CallableFunc type.
func FuncASRYE ¶
FuncASRYE transform a function of 'func(string) ([]byte, error)' signature into CallableFunc type.
func FuncASSIRSs ¶
FuncASSIRSs transform a function of 'func(string, string, int) []string' signature into CallableFunc type.
func FuncASSRB ¶
FuncASSRB transform a function of 'func(string, string) bool' signature into CallableFunc type.
func FuncASSRE ¶
FuncASSRE transform a function of 'func(string, string) error' signature into CallableFunc type. User function will return 'true' if underlying native function returns nil.
func FuncASSRI ¶
FuncASSRI transform a function of 'func(string, string) int' signature into CallableFunc type.
func FuncASSRS ¶
FuncASSRS transform a function of 'func(string, string) string' signature into CallableFunc type.
func FuncASSRSs ¶
FuncASSRSs transform a function of 'func(string, string) []string' signature into CallableFunc type.
func FuncASsSRS ¶
FuncASsSRS transform a function of 'func([]string, string) string' signature into CallableFunc type.
func FuncAYRIE ¶
FuncAYRIE transform a function of 'func([]byte) (int, error)' signature into CallableFunc type.
func FuncAYRS ¶
FuncAYRS transform a function of 'func([]byte) string' signature into CallableFunc type.
func GetModuleMap ¶
func GetModuleMap(names ...string) *tengo.ModuleMap
GetModuleMap returns the module map that includes all modules for the given module names.
Types ¶
This section is empty.