mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-21 20:18:06 +02:00
9 lines
276 B
TypeScript
9 lines
276 B
TypeScript
/**
|
|||
* Truncate a file path to maxLen characters, keeping the tail and prefixing with "...".
|
|||
*/
|
|||
export function truncPath(p: string | undefined | null, maxLen = 60): string {
|
|||
if (!p) return '';
|
|||
if (p.length <= maxLen) return p;
|
|||
return '...' + p.slice(-(maxLen - 3));
|
|||
}
|