MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / wrapLines

Function wrapLines

apps/desktop/src/cli/help.ts:56–78  ·  view source on GitHub ↗
(text: string, width: number)

Source from the content-addressed store, hash-verified

54}
55
56function wrapLines(text: string, width: number): string[] {
57 // Soft-wrap a single descriptive paragraph at word boundaries. We
58 // only wrap plain text — the command name in the left column
59 // doesn't get wrapped.
60 if (text.length <= width) return [text]
61 const words = text.split(/\s+/)
62 const lines: string[] = []
63 let current = ''
64 for (const word of words) {
65 if (!current) {
66 current = word
67 continue
68 }
69 if ((current + ' ' + word).length > width) {
70 lines.push(current)
71 current = word
72 } else {
73 current += ' ' + word
74 }
75 }
76 if (current) lines.push(current)
77 return lines
78}
79
80interface CommandRow {
81 /** Left column, e.g. `list <flags>` or `read <path>`. */

Callers 2

headerFunction · 0.85
sectionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected