( text: string | null | undefined, maxLines: number, )
| 8 | * Returns the input unchanged if it's null/undefined/empty. |
| 9 | */ |
| 10 | export function truncateToLines( |
| 11 | text: string | null | undefined, |
| 12 | maxLines: number, |
| 13 | ): string | null | undefined { |
| 14 | if (!text) return text |
| 15 | const lines = text.split('\n') |
| 16 | if (lines.length <= maxLines) { |
| 17 | return text |
| 18 | } |
| 19 | return lines.slice(0, maxLines).join('\n').trimEnd() + '...' |
| 20 | } |
| 21 | |
| 22 | import { statSync } from 'fs' |
| 23 |
no outgoing calls
no test coverage detected