tools

package
v0.3.31 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LEVEL_INFO  = "info"
	LEVEL_ERROR = "error"
	LEVEL_DEBUG = "debug"
	LEVEL_WARN  = "warning"
)
View Source
const TOOL_ARRAYS = "$arrays"
View Source
const TOOL_CONSOLE = "$console"
View Source
const TOOL_CONVERT = "$convert"
View Source
const TOOL_CSV = "$csv"
View Source
const TOOL_PATHS = "$paths"
View Source
const TOOL_REGEXPS = "$regexps"
View Source
const TOOL_STRINGS = "$strings"

Variables

This section is empty.

Functions

This section is empty.

Types

type ScriptingTool

type ScriptingTool interface {
	Init(params *ScriptingToolParams)
	SetContext(context interface{})
}

type ScriptingToolArrays

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

func NewToolArrays

func NewToolArrays(params *ScriptingToolParams) *ScriptingToolArrays

func (*ScriptingToolArrays) GetAt

func (tool *ScriptingToolArrays) GetAt(call goja.FunctionCall) goja.Value

Return a value contained in an array @param index @param array @return nil or value found at index

func (*ScriptingToolArrays) GetFirst

func (tool *ScriptingToolArrays) GetFirst(call goja.FunctionCall) goja.Value

Return first value contained in an array. If array is nil or empty returns an empty string @param array @return nil or value

func (*ScriptingToolArrays) GetLast

func (tool *ScriptingToolArrays) GetLast(call goja.FunctionCall) goja.Value

Return last value contained in an array. If array is nil or empty returns an empty string @param array @return nil or value

func (*ScriptingToolArrays) GetSub

func (tool *ScriptingToolArrays) GetSub(call goja.FunctionCall) goja.Value

Return range values contained in an array. If array is nil or empty returns an empty array @param array @return nil or sub-array

func (*ScriptingToolArrays) Init

func (tool *ScriptingToolArrays) Init(params *ScriptingToolParams)

func (*ScriptingToolArrays) SetContext

func (tool *ScriptingToolArrays) SetContext(context interface{})

type ScriptingToolCSV

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

func NewToolCSV

func NewToolCSV(params *ScriptingToolParams) *ScriptingToolCSV

func (*ScriptingToolCSV) Init

func (tool *ScriptingToolCSV) Init(params *ScriptingToolParams)

func (*ScriptingToolCSV) LoadFromFile

func (tool *ScriptingToolCSV) LoadFromFile(call goja.FunctionCall) goja.Value

Load csv file from file and return []map[string]string @param [string] filename @param [bool] headerOnFirstRow @return []map[string]string

func (*ScriptingToolCSV) SetContext

func (tool *ScriptingToolCSV) SetContext(context interface{})

type ScriptingToolConsole

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

func NewToolConsole

func NewToolConsole(params *ScriptingToolParams) *ScriptingToolConsole

func (*ScriptingToolConsole) Debug

func (tool *ScriptingToolConsole) Debug(call goja.FunctionCall) goja.Value

func (*ScriptingToolConsole) Error

func (tool *ScriptingToolConsole) Error(call goja.FunctionCall) goja.Value

func (*ScriptingToolConsole) Info

func (tool *ScriptingToolConsole) Info(call goja.FunctionCall) goja.Value

func (*ScriptingToolConsole) Init

func (tool *ScriptingToolConsole) Init(params *ScriptingToolParams)

func (*ScriptingToolConsole) Log

func (*ScriptingToolConsole) SetContext

func (tool *ScriptingToolConsole) SetContext(context interface{})

func (*ScriptingToolConsole) Warn

func (tool *ScriptingToolConsole) Warn(call goja.FunctionCall) goja.Value

type ScriptingToolConvert

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

func NewToolConvert

func NewToolConvert(params *ScriptingToolParams) *ScriptingToolConvert

func (*ScriptingToolConvert) Init

func (tool *ScriptingToolConvert) Init(params *ScriptingToolParams)

func (*ScriptingToolConvert) Num2Word

func (tool *ScriptingToolConvert) Num2Word(call goja.FunctionCall) goja.Value

Convert a number into word @param num int Number to convert into word @param lang string Language for conversion (ex: "it") @return string

func (*ScriptingToolConvert) SetContext

func (tool *ScriptingToolConvert) SetContext(context interface{})

type ScriptingToolParams

type ScriptingToolParams struct {
	Root    *string // pointer to external string (the gg_sms_engine Root)
	Name    *string // pointer to external string (the gg_sms_engine Name)
	Runtime *goja.Runtime
}

type ScriptingToolPaths

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

func NewToolPaths

func NewToolPaths(params *ScriptingToolParams) *ScriptingToolPaths

func (*ScriptingToolPaths) GetAbsolutePath

func (tool *ScriptingToolPaths) GetAbsolutePath(call goja.FunctionCall) goja.Value

Return absolute path @param [string] path @return string

func (*ScriptingToolPaths) GetWorkspacePath

func (tool *ScriptingToolPaths) GetWorkspacePath(call goja.FunctionCall) goja.Value

func (*ScriptingToolPaths) Init

func (tool *ScriptingToolPaths) Init(params *ScriptingToolParams)

func (*ScriptingToolPaths) SetContext

func (tool *ScriptingToolPaths) SetContext(context interface{})

type ScriptingToolRegExps

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

func NewToolRegExps

func NewToolRegExps(params *ScriptingToolParams) *ScriptingToolRegExps

func (*ScriptingToolRegExps) HasMatch

func (tool *ScriptingToolRegExps) HasMatch(call goja.FunctionCall) goja.Value

Return true if passed pattern match with text @param pattern string "hu?an*" @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return bool

func (*ScriptingToolRegExps) HasMatchExp

func (tool *ScriptingToolRegExps) HasMatchExp(call goja.FunctionCall) goja.Value

Return true if passed pattern match with text @param pattern string A standard regular expression @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return bool

func (*ScriptingToolRegExps) Index

func (tool *ScriptingToolRegExps) Index(call goja.FunctionCall) goja.Value

Return index array of matching expression in a text usage: $regexps.Index('hu?an*') @param pattern string "hu?an*" @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return []int

func (*ScriptingToolRegExps) IndexExp

func (tool *ScriptingToolRegExps) IndexExp(call goja.FunctionCall) goja.Value

Return index array of matching expression in a text usage: $regexps.Index('hu?an*') @param pattern string A standard regular expression @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return []int

func (*ScriptingToolRegExps) IndexFirst

func (tool *ScriptingToolRegExps) IndexFirst(call goja.FunctionCall) goja.Value

Return index of first matching expression in a text usage: $regexps.IndexFirst('hu?an*') @param pattern string "hu?an*" @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return int

func (*ScriptingToolRegExps) IndexFirstExp

func (tool *ScriptingToolRegExps) IndexFirstExp(call goja.FunctionCall) goja.Value

Return index of first matching expression in a text usage: $regexps.IndexFirst('hu?an*') @param pattern string "hu?an*" @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return int

func (*ScriptingToolRegExps) IndexLast

func (tool *ScriptingToolRegExps) IndexLast(call goja.FunctionCall) goja.Value

Return index of last matching expression in a text usage: $regexps.IndexLast('hu?an*') @param pattern string "hu?an*" @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return int

func (*ScriptingToolRegExps) IndexLastExp

func (tool *ScriptingToolRegExps) IndexLastExp(call goja.FunctionCall) goja.Value

Return index of last matching expression in a text usage: $regexps.IndexLast('hu?an*') @param pattern string A standard regular expression @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return int

func (*ScriptingToolRegExps) IndexLenPair

func (tool *ScriptingToolRegExps) IndexLenPair(call goja.FunctionCall) goja.Value

Return array of pair index:word_len of matching expression in a text usage: $regexps.IndexLenPair('hu?an*') @param pattern string "hu?an*" @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return [][]int ex: [[12,3], [22,4]]

func (*ScriptingToolRegExps) IndexLenPairExp

func (tool *ScriptingToolRegExps) IndexLenPairExp(call goja.FunctionCall) goja.Value

Return array of pair index:word_len of matching expression in a text usage: $regexps.IndexLenPair('hu?an*') @param pattern string A standard regular expression @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return [][]int ex: [[12,3], [22,4]]

func (*ScriptingToolRegExps) IndexLenPairLast

func (tool *ScriptingToolRegExps) IndexLenPairLast(call goja.FunctionCall) goja.Value

Return last array of pair index:word_len of matching expression in a text usage: $regexps.IndexLenPair('hu?an*') @param pattern string "hu?an*" @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return []int ex: [22,4]

func (*ScriptingToolRegExps) IndexLenPairLastExp

func (tool *ScriptingToolRegExps) IndexLenPairLastExp(call goja.FunctionCall) goja.Value

Return last array of pair index:word_len of matching expression in a text usage: $regexps.IndexLenPair('hu?an*') @param pattern string A standard regular expression @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return []int ex: [22,4]

func (*ScriptingToolRegExps) IndexStartAt

func (tool *ScriptingToolRegExps) IndexStartAt(call goja.FunctionCall) goja.Value

Return index array of matching expression in a text starting search from offset position usage: $regexps.IndexStartAt(30, 'hu?an*') @param offset int number of characters to exclude from search @param pattern string "hu?an*" @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return []int

func (*ScriptingToolRegExps) IndexStartAtExp

func (tool *ScriptingToolRegExps) IndexStartAtExp(call goja.FunctionCall) goja.Value

Return index array of matching expression in a text starting search from offset position usage: $regexps.IndexStartAt(30, 'hu?an*') @param offset int number of characters to exclude from search @param pattern string A standard regular expression @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return []int

func (*ScriptingToolRegExps) Init

func (tool *ScriptingToolRegExps) Init(params *ScriptingToolParams)

func (*ScriptingToolRegExps) MatchAll

func (tool *ScriptingToolRegExps) MatchAll(call goja.FunctionCall) goja.Value

Return all matched values with passed pattern match with text @param pattern string "hu?an*" @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return []string

func (*ScriptingToolRegExps) MatchAllExp

func (tool *ScriptingToolRegExps) MatchAllExp(call goja.FunctionCall) goja.Value

Return all matched values with passed pattern match with text @param pattern string A standard regular expression @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return []string

func (*ScriptingToolRegExps) MatchAt

func (tool *ScriptingToolRegExps) MatchAt(call goja.FunctionCall) goja.Value

Return string matched at index of matched array (works on array of all matched values) with passed pattern match with text If index passed is zero, response is same as $regexps.MatchFirst('hu?an*') usage: $regexps.MatchAt('hu?an*', 0) @param pattern string "hu?an*" @param index int @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return []string

func (*ScriptingToolRegExps) MatchAtExp

func (tool *ScriptingToolRegExps) MatchAtExp(call goja.FunctionCall) goja.Value

Return string matched at index of matched array (works on array of all matched values) with passed pattern match with text If index passed is zero, response is same as $regexps.MatchFirst('hu?an*') usage: $regexps.MatchAt('hu?an*', 0) @param pattern string A standard regular expression @param index int @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return []string

func (*ScriptingToolRegExps) MatchBetween

func (tool *ScriptingToolRegExps) MatchBetween(call goja.FunctionCall) goja.Value

Return an array of values detected between two expressions. @param offset int Index to start matching from. Pass 0 if you do not need any offset @param patternStart string @param patternEnd string @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return []string

func (*ScriptingToolRegExps) MatchBetweenExp

func (tool *ScriptingToolRegExps) MatchBetweenExp(call goja.FunctionCall) goja.Value

Return an array of values detected between two expressions. @param offset int Index to start matching from. Pass 0 if you do not need any offset @param patternStart string A standard regular expression @param patternEnd string A standard regular expression @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return []string

func (*ScriptingToolRegExps) MatchFirst

func (tool *ScriptingToolRegExps) MatchFirst(call goja.FunctionCall) goja.Value

Return first matched value with passed pattern match with text usage: $regexps.MatchFirst('hu?an*') @param pattern string "hu?an*" @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return string

func (*ScriptingToolRegExps) MatchFirstExp

func (tool *ScriptingToolRegExps) MatchFirstExp(call goja.FunctionCall) goja.Value

Return first matched value with passed pattern match with text usage: $regexps.MatchFirst('hu?an*') @param pattern string A standard regular expression @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return string

func (*ScriptingToolRegExps) MatchLast

func (tool *ScriptingToolRegExps) MatchLast(call goja.FunctionCall) goja.Value

Return last matched value with passed pattern match with text usage: $regexps.MatchLast('hu?an*') @param pattern string "hu?an*" @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return string

func (*ScriptingToolRegExps) MatchLastExp

func (tool *ScriptingToolRegExps) MatchLastExp(call goja.FunctionCall) goja.Value

Return last matched value with passed pattern match with text usage: $regexps.MatchLast('hu?an*') @param pattern string A standard regular expression @param text string (Optional) CONTEXT is used if not found. "hello humanity!!" @return string

func (*ScriptingToolRegExps) MatchNumbers

func (tool *ScriptingToolRegExps) MatchNumbers(call goja.FunctionCall) goja.Value

func (*ScriptingToolRegExps) MatchPrices

func (tool *ScriptingToolRegExps) MatchPrices(call goja.FunctionCall) goja.Value

func (*ScriptingToolRegExps) Score

func (tool *ScriptingToolRegExps) Score(call goja.FunctionCall) goja.Value

Calculate a matching score between a phrase and a check test using expressions. ALL expressions are evaluated. Score result is different if there's more than one expression (separated by "|" symbol). If mode equals "all": Failed expressions add negative score to result If mode equals "any": Failed expressions do not add negative score to result If mode equals "best": Failed expressions do not add negative score to result and best score is returned @param [string] phrase. "hello humanity!! I'm Mario rossi" @param [string] expressions. All expressions to match separated by | (pipe) hel??0 h* | I* * ros*" @param [string] mode. "all", "any", "best"

func (*ScriptingToolRegExps) SetContext

func (tool *ScriptingToolRegExps) SetContext(context interface{})

type ScriptingToolStrings

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

func NewToolStrings

func NewToolStrings(params *ScriptingToolParams) *ScriptingToolStrings

func (*ScriptingToolStrings) Init

func (tool *ScriptingToolStrings) Init(params *ScriptingToolParams)

func (*ScriptingToolStrings) SetContext

func (tool *ScriptingToolStrings) SetContext(context interface{})

func (*ScriptingToolStrings) Split

func (tool *ScriptingToolStrings) Split(call goja.FunctionCall) goja.Value

Split a string by sep. Support multiple separators @param sep string @param text string (Optional) CONTEXT is used if not found @return []string

func (*ScriptingToolStrings) SplitBySpaceWordAt

func (tool *ScriptingToolStrings) SplitBySpaceWordAt(call goja.FunctionCall) goja.Value

Split a string by spaces AND get a word at index @param index int @param text string (Optional) CONTEXT is used if not found @return bool

func (*ScriptingToolStrings) SplitWordAt

func (tool *ScriptingToolStrings) SplitWordAt(call goja.FunctionCall) goja.Value

Split a string by "sep" AND get a word at index @param index int @param sep string @param text string (Optional) CONTEXT is used if not found @return string

func (*ScriptingToolStrings) Sub

Get a substring @param start int Start index @param end int End index @param text string (Optional) CONTEXT is used if not found @return []string

Jump to

Keyboard shortcuts

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