code: function calcEditDistances(current, currentStart, currentEnd,
                                old, oldStart, oldEnd) {
      var this$1 = this;
  
      // "Deletion" columns
      var rowCount = oldEnd - oldStart + 1;
      var columnCount = currentEnd - currentStart + 1;
      var distances = new Array(rowCount);
  
      // "Addition" rows. Initialize null column.
      for (var i = 0; i < rowCount; i++) {
        distances[i] = new Array(columnCount);
        distances[i][0] = i;
      }
  
      // Initialize null row
      for (var j = 0; j < columnCount; j++)
        distances[0][j] = j;
  
      for (var i$1 = 1; i$1 < rowCount; i$1++) {
        for (var j$1 = 1; j$1 < columnCount; j$1++) {
          if (this$1.equals(current[currentStart + j$1 - 1], old[oldStart + i$1 - 1]))
            distances[i$1][j$1] = distances[i$1 - 1][j$1 - 1];
          else {
            var north = distances[i$1 - 1][j$1] + 1;
            var west = distances[i$1][j$1 - 1] + 1;
            distances[i$1][j$1] = north < west ? north : west;
          }
        }
      }
  
      return distances;
    }
docs: Note: This function is *based* on the computation of the Levenshtein "edit" distance. The one change is that "updates" are treated as two edits - not one. With Array splices, an update is really a delete followed by an add. By retaining this, we optimize for "keeping" the maximum array items in the original array. For example:  'xxxx123' -> '123yyyy'  With 1-edit updates, the shortest path would be just to update all seven characters. With 2-edit updates, we delete 4, leave 3, and add 4. This leaves the substring '123' intact.