(start, end, decreaseDepth = 1)
| 554 | }, []); |
| 555 | |
| 556 | function writeGroup(start, end, decreaseDepth = 1) { |
| 557 | let seq = ''; |
| 558 | i++; |
| 559 | // Only checking for the closing delimiter is a fast heuristic for regular |
| 560 | // expressions without the u or v flag. A safer check would verify that the |
| 561 | // read characters are all alphanumeric. |
| 562 | while (i < regexpString.length && regexpString[i] !== end) { |
| 563 | seq += regexpString[i++]; |
| 564 | } |
| 565 | if (i < regexpString.length) { |
| 566 | depth -= decreaseDepth; |
| 567 | write(start); |
| 568 | writeDepth(seq, 1, 1); |
| 569 | write(end); |
| 570 | depth += decreaseDepth; |
| 571 | } else { |
| 572 | // The group is not closed which would lead to mistakes in the output. |
| 573 | // This is a workaround to prevent output from being corrupted. |
| 574 | writeDepth(start, 1, -seq.length); |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | const write = (str) => { |
| 579 | const idx = depth % palette.length; |
no test coverage detected
searching dependent graphs…