new String()
- Since:
-
- 1.0.0
Methods
-
<static> format(string, values)
-
Allows you to define a tokenised string and pass an arbitrary number of arguments to replace the tokens. Each token must be unique, and must increment in the format
{0},{1}, etc.Example usage:
var str1 = "Hello"; var str2 = "World"; var str3 = mindsmine.String.format("Let us combine {0} and {1} together.", str1, str2); // str3 now contains the string: "Let us combine Hello and World together."Parameters:
Name Type Argument Description stringString The tokenised string to be formatted.
valuesString <repeatable>
The values to replace tokens
{0},{1}, etc. in order.- Since:
-
- 1.0.0
Returns:
The formatted string
- Type
- String
-
<static> getNullSafe(str)
-
Returns a non-null string, even if the object being passed is a null string.
If the passed-in object is a non-null string, then it is returned as-is.
Example usage:
var str1 = "Hello"; var str2 = null; var str3 = mindsmine.String.getNullSafe(str1); var str4 = mindsmine.String.getNullSafe(str2); // str3 now contains the string: "Hello" // str4 now contains the string: ""Parameters:
Name Type Description strString The string to safeguard against
null.- Since:
-
- 1.0.0
Returns:
If str is
nullthen""(empty string).- Type
- String
-
<static> htmlDecode(str)
-
Convert certain characters (&, <, >, ' and ") from their HTML character equivalents.
Parameters:
Name Type Description strString The string to decode.
- Since:
-
- 1.0.0
Returns:
The decoded text.
- Type
- String
-
<static> htmlEncode(str)
-
Convert certain characters (&, <, >, ' and ") to their HTML character equivalents for literal display in web pages.
Parameters:
Name Type Description strString The string to encode.
- Since:
-
- 1.0.0
Returns:
The encoded text.
- Type
- String
-
<static> isEmpty(str)
-
Returns
trueif the passed value is an empty string, false otherwise.The value is deemed to be an empty string if it is either:
nullundefined- not a string
- a zero-length string
Parameters:
Name Type Description strObject The value to test.
- Since:
-
- 1.0.0
Returns:
- Type
- Boolean
-
<static> urlAppend(url, query)
-
Appends content to the query string of a URL, handling logic for whether to place a question mark or ampersand.
Parameters:
Name Type Description urlString The URL to append to.
queryString The content to append to the URL.
- Since:
-
- 1.0.0
Returns:
The resulting URL
- Type
- String