Function truncate

  • Namespace

    StringUtils

    Truncate a string to a specified maximum length and append an ellipsis if needed.

    Parameters

    • str: string

      The input string.

    • maxLength: number

      The maximum length of the truncated string.

    Returns string

    The truncated string.

    Example

    const originalString = "hello, world!";
    const truncatedString = StringUtils.truncateString(originalString, 5);
    console.log(truncatedString); // Output: "hello..."

Generated using TypeDoc