UNPKG

@redocly/theme

Version:

Shared UI components lib

8 lines (7 loc) 271 B
export function trimText(text: string | string[], maxLength: number = 150): string | string[] { if (typeof text === 'string') { if (text.length <= maxLength) { return text; } else return `${text.slice(0, maxLength).trimEnd()}...`; } else return text; }