Skip to main content

truncate

Callable

  • truncate(str: null | string, length: number): null | string

  • Truncates a string to a specified length, adding ellipsis if necessary.

    @example
    // Truncate a string to a maximum length of 10 characters
    const truncatedString = truncate("Lorem ipsum dolor sit amet", 10);
    console.log(truncatedString); // Output: "Lorem ipsu..."