String and locale related functions.
- Source:
Methods
(static) getLocale() → {string}
Get the locale/language string.
- If
navigator.language
exists it will be used. - If
Intl
exists it will be used. - If neither of those exist, uses
'en-US'
as a default.
- Source:
Returns:
- The locale/language string.
- Type
- string
(static) isReplacement(v) → {boolean}
Is the passed in value a valid String.replace
replacement value.
Only strings and functions are valid.
Parameters:
Name | Type | Description |
---|---|---|
v |
* | Value to check. |
- Source:
Returns:
- Type
- boolean
(static) isSearch(v) → {boolean}
Is the passed in value a valid String.replace
search value.
Only strings and RegExp
objects are valid.
Parameters:
Name | Type | Description |
---|---|---|
v |
* | Value to check. |
- Source:
Returns:
- Type
- boolean
(static) replaceItems(string, replacements, useAllopt) → {string}
Apply multiple replacement rules to a string.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
string |
string | The input string. |
|
replacements |
object | Replacement rules. If this is an
If this is any other kind of |
|
useAll |
boolean |
<optional> |
Which replacement method will be used.
If |
- Source:
Returns:
The output string with all replacements performed.
- Type
- string
(static) ucfirst(string, lcrestopt, localeopt) → {string}
Make the first character of a string uppercase.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
string |
string | The input string. |
||
lcrest |
boolean |
<optional> |
false | Make the rest of the string lowercase? |
locale |
string |
<optional> |
getLocale() | The locale/language of the string. |
- Source:
Returns:
- The output string.
- Type
- string
(static) ucwords(string, unicodeopt, lcrestopt, localeopt) → {string}
Make the first character of each word in a string uppercase.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
string |
string | The input string. |
||
unicode |
boolean |
<optional> |
false | Use Unicode words?
Only uses simple PCRE-style words ( |
lcrest |
boolean |
<optional> |
false | Make the rest of each word lowercase? |
locale |
string |
<optional> |
getLocale() | The locale/language of the string. |
- Source:
Returns:
- The output string.
- Type
- string
(async, inner) replaceAsync(string, regexp, replacerFunction) → {string}
Replace values in a string via an async function.
Parameters:
Name | Type | Description |
---|---|---|
string |
string | The input string. |
regexp |
RegExp | string | The pattern to find. If this is a |
replacerFunction |
function | An See |
- Source:
Returns:
- Type
- string