docs: function combineRanges (ranges) {
    var ordered = ranges.map(mapWithIndex).sort(sortByRangeStart)
  
    for (var j = 0, i = 1; i < ordered.length; i++) {
      var range = ordered[i]
      var current = ordered[j]
  
      if (range.start > current.end + 1) {
        // next range
        ordered[++j] = range
      } else if (range.end > current.end) {
        // extend range
        current.end = range.end
        current.index = Math.min(current.index, range.index)
      }
    }
  
    // trim ordered array
    ordered.length = j + 1
  
    // generate combined range
    var combined = ordered.sort(sortByRangeIndex).map(mapWithoutIndex)
  
    // copy ranges type
    combined.type = ranges.type
  
    return combined
  }