MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / wrapText

Function wrapText

ui/src/lib/export-svg.ts:222–237  ·  view source on GitHub ↗
(text: string, chars: number)

Source from the content-addressed store, hash-verified

220 * a `min-height` box grow, an image cannot.
221 */
222export function wrapText(text: string, chars: number): string[] {
223 const words = text.split(/\s+/).filter(Boolean);
224 if (words.length === 0) return [''];
225 const lines: string[] = [];
226 let line = '';
227 for (const word of words) {
228 if (line.length === 0) line = word;
229 else if (line.length + 1 + word.length <= chars) line = `${line} ${word}`;
230 else {
231 lines.push(line);
232 line = word;
233 }
234 }
235 lines.push(line);
236 return lines;
237}
238
239/* ------------------------------------------------------------- the frame -- */
240

Callers 2

pushFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected