MCPcopy Index your code
hub / github.com/nodejs/node / findBestPatternMatch

Function findBestPatternMatch

test/fixtures/snapshot/typescript.js:2401–2414  ·  view source on GitHub ↗

Return the object corresponding to the best pattern to match `candidate`.

(values, getPattern, candidate)

Source from the content-addressed store, hash-verified

2399 ts.matchedText = matchedText;
2400 /** Return the object corresponding to the best pattern to match `candidate`. */
2401 function findBestPatternMatch(values, getPattern, candidate) {
2402 var matchedValue;
2403 // use length of prefix as betterness criteria
2404 var longestMatchPrefixLength = -1;
2405 for (var _i = 0, values_2 = values; _i < values_2.length; _i++) {
2406 var v = values_2[_i];
2407 var pattern = getPattern(v);
2408 if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) {
2409 longestMatchPrefixLength = pattern.prefix.length;
2410 matchedValue = v;
2411 }
2412 }
2413 return matchedValue;
2414 }
2415 ts.findBestPatternMatch = findBestPatternMatch;
2416 function startsWith(str, prefix) {
2417 return str.lastIndexOf(prefix, 0) === 0;

Callers

nothing calls this directly

Calls 1

isPatternMatchFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…