MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / truncateToLines

Function truncateToLines

cli/src/utils/strings.ts:10–20  ·  view source on GitHub ↗
(
  text: string | null | undefined,
  maxLines: number,
)

Source from the content-addressed store, hash-verified

8 * Returns the input unchanged if it's null/undefined/empty.
9 */
10export 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
22import { statSync } from 'fs'
23

Callers 2

strings.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected