Constructor
new module:caplin/core/StringUtility()
This is a static class that never needs to be instantiated.
Utility class that provides methods for string manipulation.
Methods
-
(static) buildString(source, separator, includeName) → {String}
-
Concatenates the string fields of an object into a single string, each field being separated from the next by 'separator'. If includeName is set to true, then the field name will also be included in the string.
Parameters:
Name Type Description source
Object The object whose fields will be concatenated into a single string. separator
String The string to use as the separator between each field in the returned string. includeName
boolean If true, the names of the object's fields will be included in the returned string. Returns:
A single string representing all the string fields of an object.- Type
- String
-
(static) isNullUndefinedOrEmpty(source, trimopt)
-
Determines if the string is
null
,undefined
or an empty string.Parameters:
Name Type Attributes Description source
String The string to be tested trim
Boolean <optional>
Defaults to false
. Iftrue
any whitespace will be trimmed before performing the empty string comparison. -
(static) splitAndTrim(source, separator) → {Array}
-
Splits up the specified input string, based on the specified separator, and
trims
each of the output strings. For example, the string"one, two, three"
split with a comma separator will produce an array output of["one","two","three"]
.Parameters:
Name Type Description source
String The string to be split up. separator
String The separator which will be used to split the string up. Returns:
An array containing the split string, with each of the contents of the array trimmed.- Type
- Array