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

Function isSubsetOf

third_party/inputmask/inputmask.js:885–903  ·  view source on GitHub ↗
(source, target)

Source from the content-addressed store, hash-verified

883 }
884 }
885 function isSubsetOf(source, target) {
886 function expand(pattern) {
887 var expanded = [], start, end;
888 for (var i = 0, l = pattern.length; i < l; i++) {
889 if (pattern.charAt(i) === "-") {
890 end = pattern.charCodeAt(i + 1);
891 while (++start < end) expanded.push(String.fromCharCode(start));
892 } else {
893 start = pattern.charCodeAt(i);
894 expanded.push(pattern.charAt(i));
895 }
896 }
897 return expanded.join("");
898 }
899 if (opts.regex && source.match.fn !== null && target.match.fn !== null) {
900 return expand(target.match.def.replace(/[\[\]]/g, "")).indexOf(expand(source.match.def.replace(/[\[\]]/g, ""))) !== -1;
901 }
902 return source.match.def === target.match.nativeDef;
903 }
904 function staticCanMatchDefinition(source, target) {
905 var sloc = source.locator.slice(source.alternation).join(""), tloc = target.locator.slice(target.alternation).join(""), canMatch = sloc == tloc;
906 canMatch = canMatch && source.match.fn === null && target.match.fn !== null ? target.match.fn.test(source.match.def, getMaskSet(), pos, false, opts, false) : false;

Callers 1

handleMatchFunction · 0.85

Calls 2

expandFunction · 0.85
replaceMethod · 0.45

Tested by

no test coverage detected