code: function stringDistanceCapped(strA, strB, cap) {
    if (Math.abs(strA.length - strB.length) >= cap) {
      return cap;
    }
  
    var memo = [];
    // `memo` is a two-dimensional array containing distances.
    // memo[i][j] is the distance between strA.slice(0, i) and
    // strB.slice(0, j).
    for (var i = 0; i <= strA.length; i++) {
      memo[i] = Array(strB.length + 1).fill(0);
      memo[i][0] = i;
    }
    for (var j = 0; j < strB.length; j++) {
      memo[0][j] = j;
    }
  
    for (var i = 1; i <= strA.length; i++) {
      var ch = strA.charCodeAt(i - 1);
      for (var j = 1; j <= strB.length; j++) {
        if (Math.abs(i - j) >= cap) {
          memo[i][j] = cap;
          continue;
        }
        memo[i][j] = Math.min(
          memo[i - 1][j] + 1,
          memo[i][j - 1] + 1,
          memo[i - 1][j - 1] +
            (ch === strB.charCodeAt(j - 1) ? 0 : 1)
        );
      }
    }
  
    return memo[strA.length][strB.length];
  }
docs: # stringDistanceCapped(strA, strB, cap)
  Return the Levenshtein distance between two strings, but no more than cap.
  @param {string} strA
  @param {string} strB
  @param {number} number
  @return {number} min(string distance between strA and strB, cap)
  @api private