`text` with spaces over each of `ranges`, which may overlap and may run past its end.
(text: string, ranges: Ranges)
| 170 | |
| 171 | /** `text` with spaces over each of `ranges`, which may overlap and may run past its end. */ |
| 172 | function blankRanges(text: string, ranges: Ranges): string { |
| 173 | ranges.sort((a, b) => a[0] - b[0]); |
| 174 | let out = ''; |
| 175 | let at = 0; |
| 176 | for (const [start, end] of ranges) { |
| 177 | const from = Math.max(start, at); |
| 178 | const to = Math.min(end, text.length); |
| 179 | if (from >= to) continue; |
| 180 | out += text.slice(at, from) + ' '.repeat(to - from); |
| 181 | at = to; |
| 182 | } |
| 183 | return out + text.slice(at); |
| 184 | } |
no outgoing calls
no test coverage detected