The text to bound.
Maximum length to keep.
The original text, or a truncated copy with a marker.
truncate("a".repeat(10), 4); // => "aaaa\nā¦[truncated ā full log copied to clipboard]"
export function truncate(text: string, limit: number): string {
if (text.length <= limit) return text;
return `${text.slice(0, limit)}\nā¦[truncated ā full log copied to clipboard]`;
}
Truncates text to a character budget, appending a marker (and a note that the full detail is on the clipboard) when it has to cut.