code: function findBestPatternMatch(values, getPattern, candidate) {
          var matchedValue = undefined;
          // use length of prefix as betterness criteria
          var longestMatchPrefixLength = -1;
          for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
              var v = values_1[_i];
              var pattern = getPattern(v);
              if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) {
                  longestMatchPrefixLength = pattern.prefix.length;
                  matchedValue = v;
              }
          }
          return matchedValue;
      }
docs: Return the object corresponding to the best pattern to match `candidate`. /* @internal