(longLine: string)
| 133 | const LINE_WIDTH = 95; |
| 134 | |
| 135 | function breakLongLine(longLine: string): string[] { |
| 136 | if (longLine.length < LINE_WIDTH) return [longLine]; |
| 137 | const output: string[] = []; |
| 138 | while (longLine) { |
| 139 | if (longLine.length < LINE_WIDTH) { |
| 140 | output.push(longLine); |
| 141 | break; |
| 142 | } |
| 143 | let index = 0; |
| 144 | let lastWhitespace = index; |
| 145 | while (index < longLine.length && index < LINE_WIDTH) { |
| 146 | if (longLine[index++].match(/\s/)) { |
| 147 | lastWhitespace = index; |
| 148 | } |
| 149 | } |
| 150 | if (lastWhitespace == 0) { |
| 151 | output.push(longLine); |
| 152 | break; |
| 153 | } |
| 154 | output.push(longLine.slice(0, lastWhitespace - 1)); |
| 155 | longLine = longLine.slice(lastWhitespace).trim(); |
| 156 | } |
| 157 | return output; |
| 158 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…