(ranges: readonly DocRange[])
| 165 | } |
| 166 | |
| 167 | function normalizeRanges(ranges: readonly DocRange[]): DocRange[] { |
| 168 | if (!ranges.length) return []; |
| 169 | const sorted = [...ranges] |
| 170 | .map(({ from, to }) => { |
| 171 | const rangeFrom = Math.max(0, from); |
| 172 | return { from: rangeFrom, to: Math.max(rangeFrom, to) }; |
| 173 | }) |
| 174 | .sort((a, b) => a.from - b.from || a.to - b.to); |
| 175 | const merged: DocRange[] = []; |
| 176 | |
| 177 | for (const range of sorted) { |
| 178 | const last = merged[merged.length - 1]; |
| 179 | if (last && range.from <= last.to) { |
| 180 | last.to = Math.max(last.to, range.to); |
| 181 | continue; |
| 182 | } |
| 183 | merged.push(range); |
| 184 | } |
| 185 | |
| 186 | return merged; |
| 187 | } |
| 188 | |
| 189 | function mapRanges( |
| 190 | ranges: readonly DocRange[], |
no outgoing calls
no test coverage detected