lastNChars
Import from @varavel/vdl-plugin-sdk/utils/strings.
Returns the last n characters from a string.
When truncation happens, an ellipsis is appended by default so generated labels and previews can communicate that the returned segment is partial.
Non-positive and non-finite lengths return an empty string.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
str |
string |
undefined |
Source string to shorten. |
n |
number |
undefined |
Maximum number of trailing characters to keep. |
ellipsis |
boolean |
true |
When true, appends ... if truncation occurs. |
Returns
string
The trailing character slice, optionally suffixed with an ellipsis.