function textDiff (oldText, newText) {
  const len = newText.length
  let start = 0
  let oldEnd = oldText.length
  let newEnd = newText.length

  while (newText.charAt(start) === oldText.charAt(start) &&
  start < len) {
    start++
  }

  while (newText.charAt(newEnd - 1) === oldText.charAt(oldEnd - 1) &&
  newEnd > start && oldEnd > 0) {
    newEnd--
    oldEnd--
  }

  return { start, end: newEnd }
}
Determines the difference between two texts.
Can only detect one removed or inserted block of characters.
@param {string} oldText
@param {string} newText
@return {{start: number, end: number}} Returns the start and end
                                       of the changed part in newText.