1export const truncate = (str: string, length: number) => { 2 return str.length > length ? str.slice(0, Math.max(0, length)) + "…" : str; 3};