code: function mergeMatches (matches1, matches2) {
    let next
    const length1 = matches1.length
    const length2 = matches2.length
    let lastEndIndex = -1
    const output = []
  
    const state = {
      a1: matches1,
      i1: 0,
      a2: matches2,
      i2: 0
    }
  
    while (state.i1 < length1 || state.i2 < length2) {
      next = pickNext(state)
      if (next.startIndex >= lastEndIndex) {
        output.push(next)
      }
      lastEndIndex = next.endIndex
    }
  
    return output
  }
docs: Private Helpers ---------------