The value to truncate. This is coerced to a string and must not be null or undefined.
The maximum length of the returned value.
Optionalsuffix: stringAn optional suffix to append when truncation occurs. When provided, it is coerced to a
string; if null or undefined, it is treated as an empty string.
A truncated string that does not exceed maxLength.
Truncate the provided value to the requested maximum length and optionally append a suffix.
When the value is already within
maxLength, the original string is returned unchanged. When a suffix is supplied, the result length remains capped atmaxLength, so the original value is shortened further as needed to make room for the suffix.Both
valueandsuffixare coerced to strings via asString before processing. Passingnullorundefinedforvaluewill cause this function to throw, while anull/undefinedsuffixis treated as an empty string (no suffix is appended).