stack

Home > @infiniteobjects/core-library-web > Strings > truncate

Strings.truncate() method

Truncates a string and adds an ellipsis if the string is longer than the specified length.

Signature:

static truncate(value: string, maxLength?: number, startLength?: number, endLength?: number): string;

Parameters

Parameter Type Description
value string The string to truncate.
maxLength number (Optional) The maximum length of the string.
startLength number (Optional) Quantity of characters to keep at the beginning of the string.
endLength number (Optional) Quantity of characters to keep at the end of the string.

Returns:

string