(value: string, width: number)
| 129 | } |
| 130 | |
| 131 | function wrapText(value: string, width: number) { |
| 132 | if (!value) return [""] |
| 133 | const words = value.split(" ") |
| 134 | const lines: string[] = [] |
| 135 | let current = "" |
| 136 | for (const word of words) { |
| 137 | const attempt = current ? `${current} ${word}` : word |
| 138 | if (stripAnsi(attempt).length <= width) { |
| 139 | current = attempt |
| 140 | continue |
| 141 | } |
| 142 | if (current) lines.push(current) |
| 143 | current = word |
| 144 | } |
| 145 | if (current) lines.push(current) |
| 146 | if (!lines.length) lines.push("") |
| 147 | return lines |
| 148 | } |
| 149 | |
| 150 | export async function input(prompt: string): Promise<string> { |
| 151 | const readline = require("readline") |
no test coverage detected