MCPcopy Create free account
hub / github.com/ampproject/amphtml / determineTestTemplate

Function determineTestTemplate

third_party/inputmask/inputmask.js:815–828  ·  view source on GitHub ↗
(pos, tests)

Source from the content-addressed store, hash-verified

813 return locator;
814 }
815 function determineTestTemplate(pos, tests) {
816 pos = pos > 0 ? pos - 1 : 0;
817 var altTest = getTest(pos), targetLocator = getLocator(altTest), tstLocator, closest, bestMatch;
818 for (var ndx = 0; ndx < tests.length; ndx++) {
819 var tst = tests[ndx];
820 tstLocator = getLocator(tst, targetLocator.length);
821 var distance = Math.abs(tstLocator - targetLocator);
822 if (closest === undefined || tstLocator !== "" && distance < closest || bestMatch && !opts.greedy && bestMatch.match.optionality && bestMatch.match.newBlockMarker === "master" && (!tst.match.optionality || !tst.match.newBlockMarker) || bestMatch && bestMatch.match.optionalQuantifier && !tst.match.optionalQuantifier) {
823 closest = distance;
824 bestMatch = tst;
825 }
826 }
827 return bestMatch;
828 }
829 function getTestTemplate(pos, ndxIntlzr, tstPs) {
830 return getMaskSet().validPositions[pos] || determineTestTemplate(pos, getTests(pos, ndxIntlzr ? ndxIntlzr.slice() : ndxIntlzr, tstPs));
831 }

Callers 4

getMaskTemplateFunction · 0.85
getTestTemplateFunction · 0.85
mergeLocatorsFunction · 0.85
trackbackPositionsFunction · 0.85

Calls 2

getTestFunction · 0.85
getLocatorFunction · 0.85

Tested by

no test coverage detected