//https://stackoverflow.com/a/5723274/4742580 export const truncateText = (fullStr: string, length: number, separator?: string) => { if (fullStr.length <= length) { return fullStr; } separator = separator || '...'; const sepLen = separator.length, charsToShow = length - sepLen, frontChars = Math.ceil(charsToShow / 2), backChars = Math.floor(charsToShow / 2); return fullStr.substr(0, frontChars) + separator + fullStr.substr(fullStr.length - backChars); };