MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / wrapText

Function wrapText

source code/utils/truncate.ts:162–181  ·  view source on GitHub ↗
(text: string, width: number)

Source from the content-addressed store, hash-verified

160}
161
162export function wrapText(text: string, width: number): string[] {
163 const lines: string[] = []
164 let currentLine = ''
165 let currentWidth = 0
166
167 for (const { segment } of getGraphemeSegmenter().segment(text)) {
168 const segWidth = stringWidth(segment)
169 if (currentWidth + segWidth <= width) {
170 currentLine += segment
171 currentWidth += segWidth
172 } else {
173 if (currentLine) lines.push(currentLine)
174 currentLine = segment
175 currentWidth = segWidth
176 }
177 }
178
179 if (currentLine) lines.push(currentLine)
180 return lines
181}

Callers

nothing calls this directly

Calls 2

getGraphemeSegmenterFunction · 0.85
segmentMethod · 0.80

Tested by

no test coverage detected