Miscellaneous string functions
- Source:
Methods
(static) endsWith(str, suffix) → {Boolean}
True if string ends with suffix
Parameters:
Name | Type | Description |
---|---|---|
str |
String | string to check for start |
suffix |
String | start value |
- Source:
Returns:
true if str starts with suffix
- Type
- Boolean
(static) fromCodePoint(codePoint) → {string}
Make a string from unicode code points
Parameters:
Name | Type | Description |
---|---|---|
codePoint |
Number | one or more code points |
- Source:
Returns:
unicode string. Note a single code point can return a string with length > 1.
- Type
- string
(static) padLeft(str, len, padChar) → {string}
Pad string on left
Parameters:
Name | Type | Description |
---|---|---|
str |
string | string to pad |
len |
number | number of characters to pad to |
padChar |
string | character to pad with |
- Source:
Returns:
padded string.
- Type
- string
(static) padRight(str, len, padChar) → {string}
Pad string on right
Parameters:
Name | Type | Description |
---|---|---|
str |
string | string to pad |
len |
number | number of characters to pad to |
padChar |
string | character to pad with |
- Source:
Returns:
padded string.
- Type
- string
(static) replaceParams(str, params) → {string}
Replace %(id)s in strings with values in objects(s)
Given a string like "Hello %(name)s from $(user.country)s"
and an object like {name:"Joe",user:{country:"USA"}}
would
return "Hello Joe from USA"
.
Parameters:
Name | Type | Description |
---|---|---|
str |
string | string to do replacements in |
params |
Object | Array.<Object> | one or more objects. |
- Source:
Returns:
string with replaced parts
- Type
- string
(static) startsWith(str, prefix) → {Boolean}
True if string starts with prefix
Parameters:
Name | Type | Description |
---|---|---|
str |
String | string to check for start |
prefix |
String | start value |
- Source:
Returns:
true if str starts with prefix
- Type
- Boolean