The offset of the bracket that closes the one at `open` (`(`/`[`), or -1.
(text: string, open: number)
| 1490 | |
| 1491 | /** The offset of the bracket that closes the one at `open` (`(`/`[`), or -1. */ |
| 1492 | function closingBracket(text: string, open: number): number { |
| 1493 | let depth = 0; |
| 1494 | for (let i = open; i < text.length; i++) { |
| 1495 | const skip = triviaEnd(text, i); |
| 1496 | if (skip > i) { |
| 1497 | i = skip - 1; |
| 1498 | continue; |
| 1499 | } |
| 1500 | const c = text.charCodeAt(i); |
| 1501 | if (c === CH_LPAREN || c === CH_LBRACKET) depth++; |
| 1502 | else if ((c === CH_RPAREN || c === CH_RBRACKET) && --depth === 0) return i; |
| 1503 | } |
| 1504 | return -1; |
| 1505 | } |
| 1506 | |
| 1507 | /** The links of a `with` subject (see SubjectLink), or null for any other expression. */ |
| 1508 | function subjectLinks(text: string): SubjectLink[] | null { |
no test coverage detected