MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / wrapText

Function wrapText

packages/setupWizard/src/index.ts:43–59  ·  view source on GitHub ↗
(text: string, indent: string, width: number)

Source from the content-addressed store, hash-verified

41
42// Wrap `text` to `width` columns, prefixing every line with `indent`.
43function wrapText(text: string, indent: string, width: number): string[] {
44 const words = text.split(/\s+/);
45 const lines: string[] = [];
46 let current = '';
47 for (const word of words) {
48 if (current.length > 0 && (current.length + 1 + word.length) > width) {
49 lines.push(indent + current);
50 current = word;
51 } else {
52 current = current.length > 0 ? `${current} ${word}` : word;
53 }
54 }
55 if (current.length > 0) {
56 lines.push(indent + current);
57 }
58 return lines;
59}
60
61function openBrowser(url: string): void {
62 const cmd = process.platform === 'darwin' ? 'open'

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected