(intervals)
| 435 | } |
| 436 | |
| 437 | function dedupeRealRanges(intervals) { |
| 438 | // Fuses elements of intervals if they overlap, yielding discontiguous intervals, results.length <= intervals.length |
| 439 | // Currently uses closed intervals, ie. dedupeRealRanges([[400, 800], [300, 400]]) -> [300, 800] |
| 440 | var queue = intervals.slice(); |
| 441 | var result = []; |
| 442 | var currentInterval; |
| 443 | var current = queue.shift(); |
| 444 | while(current) { // [].shift === undefined, so we don't descend into an empty array |
| 445 | currentInterval = current.slice(); |
| 446 | while((current = queue.shift()) && current[0] <= /* right-open interval would need `<` */ currentInterval[1]) { |
| 447 | currentInterval[1] = Math.max(currentInterval[1], current[1]); |
| 448 | } |
| 449 | result.push(currentInterval); |
| 450 | } |
| 451 | |
| 452 | if( |
| 453 | result.length === 1 && |
| 454 | result[0][0] > result[0][1] |
| 455 | ) { |
| 456 | // discard result |
| 457 | result = []; |
| 458 | } |
| 459 | |
| 460 | return result; |
| 461 | } |
| 462 | |
| 463 | function makeFilter() { |
| 464 | var filter = []; |
no outgoing calls
no test coverage detected
searching dependent graphs…