MCPcopy Index your code
hub / github.com/code-pushup/cli / truncateMultilineText

Function truncateMultilineText

packages/utils/src/lib/formatting.ts:132–151  ·  view source on GitHub ↗
(
  text: string,
  options?: { ellipsis?: string },
)

Source from the content-addressed store, hash-verified

130}
131
132export function truncateMultilineText(
133 text: string,
134 options?: { ellipsis?: string },
135): string {
136 const { ellipsis = `[${UNICODE_ELLIPSIS}]` } = options ?? {};
137
138 const crlfIndex = text.indexOf('\r\n');
139 const lfIndex = text.indexOf('\n');
140 const index = crlfIndex === -1 ? lfIndex : crlfIndex;
141
142 if (index < 0) {
143 return text;
144 }
145
146 const firstLine = text.slice(0, index);
147 if (text.slice(index).trim().length === 0) {
148 return firstLine;
149 }
150 return `${firstLine} ${ellipsis}`;
151}
152
153export function transformLines(
154 text: string,

Callers 2

truncateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected