rooibos/common
- Source:
Methods
(static) arrayContains(array, value, compareAttributeopt) → {boolean}
- Description:
check if array contains specified value
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
array |
Dynamic | array to search in |
||
value |
Dynamic | value to check |
||
compareAttribute |
Dynamic |
<optional> |
invalid
|
attribute to compare on |
Returns:
true if array contains a value, else return false
- Type
- boolean
(static) asArray(value) → {object}
- Description:
if type of value equals array return value, else return array with one element [value]
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
converted array
- Type
- object
(static) asBoolean(value) → {boolean}
- Description:
convert value to Boolean if this possible, else return False
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
converted boolean
- Type
- boolean
(static) asDouble(value) → {double}
- Description:
convert value to Double if this possible, else return 0.0
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
converted Double
- Type
- double
(static) asFloat(value) → {float}
- Description:
convert value to Float if this possible, else return 0.0
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
converted Float
- Type
- float
(static) asInteger(value) → {integer}
- Description:
convert value to Integer if this possible, else return 0
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
converted Integer
- Type
- integer
(static) asLongInteger(value) → {longinteger}
- Description:
convert value to LongInteger if this possible, else return 0
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
converted LongInteger
- Type
- longinteger
(static) asMultilineString(value, includeTypeopt, indentionopt) → {string}
- Description:
convert value to multiline String if this possible, else return empty string
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
value |
Dynamic | value to check |
||
includeType |
boolean |
<optional> |
false
|
|
indention |
integer |
<optional> |
0
|
Returns:
converted string
- Type
- string
(static) asString(value, includeTypeopt) → {string}
- Description:
convert value to String if this possible, else return empty string
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
value |
Dynamic | value to check |
||
includeType |
boolean |
<optional> |
false
|
Returns:
converted string
- Type
- string
(static) canSafelyIterateAAKey(aa, key) → {boolean}
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
aa |
roAssociativeArray | |
key |
string |
Returns:
- Type
- boolean
(static) eqArray(Value1, Value2, fuzzyopt, callCountopt) → {dynamic}
- Description:
Compare to roArray objects for equality.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
Value1 |
Dynamic | first array |
||
Value2 |
Dynamic | second array |
||
fuzzy |
boolean |
<optional> |
false
|
|
callCount |
integer |
<optional> |
0
|
Returns:
True if arrays are equal or False in other case.
- Type
- dynamic
(static) eqAssocArray(Value1, Value2, fuzzyopt, callCountopt) → {dynamic}
- Description:
Compare to roAssociativeArray objects for equality.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
Value1 |
Dynamic | first associative array |
||
Value2 |
Dynamic | second associative array |
||
fuzzy |
boolean |
<optional> |
false
|
|
callCount |
integer |
<optional> |
0
|
Returns:
True if arrays are equal or False in other case.
- Type
- dynamic
(static) eqTypes(Value1, Value2) → {dynamic}
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
Value1 |
dynamic | |
Value2 |
dynamic |
Returns:
- Type
- dynamic
(static) eqValues(Value1, Value2, fuzzyopt, callCountopt) → {dynamic}
- Description:
Compare two arbitrary values to each-other.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
Value1 |
Dynamic | first item to compare |
||
Value2 |
Dynamic | second item to compare |
||
fuzzy |
boolean |
<optional> |
false
|
|
callCount |
integer |
<optional> |
0
|
Returns:
True if values are equal or False in other case.
- Type
- dynamic
(static) fillText(text, fillCharopt, numCharsopt) → {string}
- Description:
Fills text with count of fillChars
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
text |
String | text to fill |
||
fillChar |
String |
<optional> |
" "
|
char to fill with |
numChars |
Integer |
<optional> |
40
|
target length |
Returns:
filled string
- Type
- string
(static) findElementIndexInArray(array, value, compareAttributeopt, caseSensitiveopt, callCountopt) → {integer}
- Description:
find an element index in array
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
array |
Dynamic | array to search |
||
value |
Dynamic | value to check |
||
compareAttribute |
Dynamic |
<optional> |
invalid
|
attribute to use for comparisons |
caseSensitive |
Boolean |
<optional> |
false
|
indicates if comparisons are case sensitive |
callCount |
integer |
<optional> |
0
|
Returns:
element index if array contains a value, else return -1
- Type
- integer
(static) findElementIndexInNode(node, value) → {integer}
- Description:
find an element index in node
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
node |
Dynamic | node to search in |
value |
Dynamic | child to search for |
Returns:
element index if node contains a value, else return -1
- Type
- integer
(static) getFunction(filename, functionName) → {object}
- Description:
looks up the function by name, for the function map
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
filename |
String | name of the file where the function was found |
functionName |
String | name of the function to locate |
Returns:
function pointer or invalid
- Type
- object
(static) getFunctionBruteForce(functionName) → {object}
- Description:
looks up the function by name, from any function map in future
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
functionName |
String | name of the function to locate |
Returns:
function pointer or invalid
- Type
- object
(static) getSafeType(v) → {dynamic}
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
v |
dynamic |
Returns:
- Type
- dynamic
(static) getTypeWithComponentWrapper(value, includeSubtypeopt) → {string}
- Description:
Takes a value and if the value is not a primitive it will wrap the type in a Component: tag like the debugger does
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
value |
Dynamic | value to check the type of |
||
includeSubtype |
Boolean |
<optional> |
false
|
If true and the value is a node the result will include the node subtype |
Returns:
Formatted result. Examples: 'String', 'Integer', '<Component: roDateTime>', '<Component: roSGNode:Node>'
- Type
- string
(static) isArray(value) → {boolean}
- Description:
check if value contains Array interface
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value contains Array interface, else return false
- Type
- boolean
(static) isAssociativeArray(value) → {boolean}
- Description:
check if value contains AssociativeArray interface
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value contains AssociativeArray interface, else return false
- Type
- boolean
(static) isBoolean(value) → {boolean}
- Description:
check if value contains Boolean interface
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value contains Boolean interface, else return false
- Type
- boolean
(static) isDateTime(value) → {boolean}
- Description:
check if value contains DateTime interface
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value contains DateTime interface, else return false
- Type
- boolean
(static) isDouble(value) → {boolean}
- Description:
check if value contains Double interface
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value contains Double interface, else return false
- Type
- boolean
(static) isFloat(value) → {boolean}
- Description:
check if value contains Float interface
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value contains Float interface, else return false
- Type
- boolean
(static) isFunction(value) → {boolean}
- Description:
check if value contains Function interface
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value contains Function interface, else return false
- Type
- boolean
(static) isInteger(value) → {boolean}
- Description:
check if value type equals Integer
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value type equals Integer, else return false
- Type
- boolean
(static) isList(value) → {boolean}
- Description:
check if value contains List interface
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value contains List interface, else return false
- Type
- boolean
(static) isLongInteger(value) → {boolean}
- Description:
check if value contains LongInteger interface
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value contains LongInteger interface, else return false
- Type
- boolean
(static) isNotEmptyString(value) → {boolean}
- Description:
check if value contains String interface and length more 0
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value contains String interface and length more 0, else return false
- Type
- boolean
(static) isNullOrEmpty(value) → {boolean}
- Description:
check if value is invalid or empty
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value is null or empty string, else return false
- Type
- boolean
(static) isNumber(value) → {boolean}
- Description:
check if value contains LongInteger or Integer or Double or Float interface
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value is number, else return false
- Type
- boolean
(static) isSGNode(value) → {boolean}
- Description:
check if value contains SGNodeChildren interface
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value contains SGNodeChildren interface, else return false
- Type
- boolean
(static) isString(value) → {boolean}
- Description:
check if value contains String interface
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value contains String interface, else return false
- Type
- boolean
(static) isUndefined(value) → {boolean}
- Description:
check if value uninitialized or empty string
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value is uninitialized or "", else return false
- Type
- boolean
(static) isValid(value) → {boolean}
- Description:
check if value initialized and not equal invalid
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value initialized and not equal invalid, else return false
- Type
- boolean
(static) isXmlElement(value) → {boolean}
- Description:
check if value contains XMLElement interface
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
true if value contains XMLElement interface, else return false
- Type
- boolean
(static) makePathStubbable(content, path) → {dynamic}
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
content |
dynamic | |
path |
string |
Returns:
- Type
- dynamic
(static) nodeContains(node, value) → {boolean}
- Description:
check if node contains specified child
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
node |
Dynamic | the node to check on |
value |
Dynamic | child to look for |
Returns:
true if node contains a value, else return false
- Type
- boolean
(static) truncateString(maxLength, value, lengthopt, collapseNewlinesopt) → {string}
- Description:
Takes a string and formats and truncates a string for more compact printing.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
maxLength |
Integer | the max length of the resulting string |
||
value |
Dynamic | string to format |
||
length |
integer |
<optional> |
38
|
|
collapseNewlines |
Boolean |
<optional> |
true
|
Will convert newlines and spaces into a single space |
Returns:
Formatted result
- Type
- string
(static) validStr(value) → {string}
- Description:
return value if his contains String interface else return empty string
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Dynamic | value to check |
Returns:
value if his contains String interface else return empty string
- Type
- string