formatToEllipsis function truncates a string to a specified maximum length and appends an ellipsis (...) if the original text exceeds that length.ts
import { formatToEllipsis } from "@arkyn/shared";
textstringmaxLengthnumberstring. If the input text is longer than maxLength, it returns the string truncated with an ellipsis. Otherwise, it returns the original string.javascript
import { formatToEllipsis } from "./formatToEllipsis";const text = "This is a very long string that needs to be truncated.";const result = formatToEllipsis(text, 20);console.log(result); // Output: "This is a very..."
javascript
import { formatToEllipsis } from "./formatToEllipsis";const text = "Short text.";const result = formatToEllipsis(text, 20);console.log(result); // Output: "Short text."