Module providing string utility functions.
- Source:
Methods
byteLength(str) → {number}static
#
charAt(string, offset, [backwards]) → {string}static
#
Like String.charAt(), but return the pair of UTF-16 surrogates for characters outside of BMP.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
string |
string | ||
offset |
number | Offset to extract the character |
|
backwards |
boolean |
optional |
Use backwards direction to detect UTF-16 surrogates, defaults to false |
- Source:
Returns:
- Type
- string
Like String.charAt(), but return the pair of UTF-16 surrogates for characters outside of BMP.
codePointLength(str) → {number}static
#
lcFirst(string) → {string}static
#
trimByteLength(safeVal, newVal, byteLimit, [filterFunction]) → {module:mediawiki.String~StringTrimmed}static
#
Utility function to trim down a string, based on byteLimit and given a safe start position. It supports insertion anywhere in the string, so "foo" to "fobaro" if limit is 4 will result in "fobo", not "foba". Basically emulating the native maxlength by reconstructing where the insertion occurred.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
safeVal |
string | Known value that was previously returned by this function, if none, pass empty string. |
|
newVal |
string | New value that may have to be trimmed down. |
|
byteLimit |
number | Number of bytes the value may be in size. |
|
filterFunction |
function |
optional |
Function to call on the string before assessing the length. |
- Source:
Returns:
Utility function to trim down a string, based on byteLimit and given a safe start position.
trimCodePointLength(safeVal, newVal, codePointLimit, [filterFunction]) → {module:mediawiki.String~StringTrimmed}static
#
Utility function to trim down a string, based on codePointLimit and given a safe start position. It supports insertion anywhere in the string, so "foo" to "fobaro" if limit is 4 will result in "fobo", not "foba". Basically emulating the native maxlength by reconstructing where the insertion occurred.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
safeVal |
string | Known value that was previously returned by this function, if none, pass empty string. |
|
newVal |
string | New value that may have to be trimmed down. |
|
codePointLimit |
number | Number of characters the value may be in size. |
|
filterFunction |
function |
optional |
Function to call on the string before assessing the length. |
- Source:
Returns:
Utility function to trim down a string, based on codePointLimit and given a safe start position.