trimEnd
Import from @varavel/vdl-plugin-sdk/utils/strings.
function trimEnd(str, chars?): string;
Removes matching characters from the end of a string.
By default, the function trims trailing whitespace using the platform's built-in whitespace semantics.
When chars is provided, only those characters are removed from the end.
A string value is interpreted as a set of individual characters, and an
array combines all characters from all entries.
Matching characters that appear earlier in the string are preserved.
Parameters
| Parameter | Type | Description |
|---|---|---|
str | string | String to trim. |
chars? | string | readonly string[] | Optional characters to remove instead of whitespace. |
Returns
string
A copy of str without the matching trailing characters.
Examples
trimEnd(" hello ")
// " hello"
trimEnd("__hello__", "_")
// "__hello"