(text: string)
| 248 | } |
| 249 | |
| 250 | export function colorize(text: string) { |
| 251 | let m: RegExpExecArray | null; |
| 252 | let lastIndex = 0; |
| 253 | const fragments: string[] = []; |
| 254 | terminalEscapeSequences.lastIndex = 0; |
| 255 | while (m = terminalEscapeSequences.exec(text)) { |
| 256 | fragments.push(colorizePlainText(text.substring(lastIndex, m.index))); |
| 257 | fragments.push(m[0]); |
| 258 | lastIndex = terminalEscapeSequences.lastIndex; |
| 259 | } |
| 260 | fragments.push(colorizePlainText(text.substr(lastIndex))); |
| 261 | return fragments.join(''); |
| 262 | } |
| 263 | |
| 264 | function colorizePlainText(text: string) { |
| 265 | const num = /(?<=^|[^A-Za-z0-9_\-\.])[0-9]+(\.[0-9]+)*(?=$|[^A-Za-z0-9_\-\.])/g; |
no test coverage detected