MCPcopy Index your code
hub / github.com/codeaashu/claude-code / wrapText

Function wrapText

src/utils/truncate.ts:160–179  ·  view source on GitHub ↗
(text: string, width: number)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

getGraphemeSegmenterFunction · 0.85
segmentMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected