* Checks if a character at a given index is escaped (preceded by odd number of backslashes).
(str: string, index: number)
| 13 | * Checks if a character at a given index is escaped (preceded by odd number of backslashes). |
| 14 | */ |
| 15 | function isEscaped(str: string, index: number): boolean { |
| 16 | let backslashCount = 0 |
| 17 | let j = index - 1 |
| 18 | while (j >= 0 && str[j] === '\\') { |
| 19 | backslashCount++ |
| 20 | j-- |
| 21 | } |
| 22 | return backslashCount % 2 !== 0 |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Counts unescaped occurrences of a character in a string. |
no outgoing calls
no test coverage detected