Blank a control statement whose keyword starts at `at`; returns where it ends.
(s: string, out: string[], at: number, limit: number)
| 138 | |
| 139 | /** Blank a control statement whose keyword starts at `at`; returns where it ends. */ |
| 140 | function blankControl(s: string, out: string[], at: number, limit: number): number { |
| 141 | let i = at; |
| 142 | for (;;) { |
| 143 | // The header: everything up to the block's `{`, brackets balanced. |
| 144 | while (i < limit && s[i] !== '{') { |
| 145 | if (s[i] === '(') { |
| 146 | const end = pastBracket(s, i); |
| 147 | if (end < 0) { |
| 148 | i = limit; |
| 149 | break; |
| 150 | } |
| 151 | i = end; |
| 152 | } else i++; |
| 153 | } |
| 154 | if (i >= limit) { |
| 155 | blank(out, at, limit); |
| 156 | return limit; |
| 157 | } |
| 158 | const end = pastBracket(s, i); |
| 159 | if (end < 0 || end > limit) { |
| 160 | blank(out, at, limit); |
| 161 | return limit; |
| 162 | } |
| 163 | blank(out, at, i + 1); |
| 164 | keepEmittedScript(s, out, i + 1, end - 1); |
| 165 | blank(out, end - 1, end); |
| 166 | const rest = CONTINUATION.exec(s.slice(end, end + 32)); |
| 167 | if (!rest) return end; |
| 168 | at = end; |
| 169 | i = end; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | function blankRazor(s: string, out: string[], from: number, to: number): void { |
| 174 | let i = from; |
no test coverage detected