MCPcopy
hub / github.com/ampproject/amphtml / generateMaskSet

Function generateMaskSet

third_party/inputmask/inputmask.js:655–732  ·  view source on GitHub ↗
(opts, nocache)

Source from the content-addressed store, hash-verified

653 return false;
654 }
655 function generateMaskSet(opts, nocache) {
656 function generateMask(mask, metadata, opts) {
657 var regexMask = false;
658 if (mask === null || mask === "") {
659 regexMask = opts.regex !== null;
660 if (regexMask) {
661 mask = opts.regex;
662 mask = mask.replace(/^(\^)(.*)(\$)$/, "$2");
663 } else {
664 regexMask = true;
665 mask = ".*";
666 }
667 }
668 if (mask.length === 1 && opts.greedy === false && opts.repeat !== 0) {
669 opts.placeholder = "";
670 }
671 if (opts.repeat > 0 || opts.repeat === "*" || opts.repeat === "+") {
672 var repeatStart = opts.repeat === "*" ? 0 : opts.repeat === "+" ? 1 : opts.repeat;
673 mask = opts.groupmarker[0] + mask + opts.groupmarker[1] + opts.quantifiermarker[0] + repeatStart + "," + opts.repeat + opts.quantifiermarker[1];
674 }
675 var masksetDefinition, maskdefKey = regexMask ? "regex_" + opts.regex : opts.numericInput ? mask.split("").reverse().join("") : mask;
676 if (Inputmask.prototype.masksCache[maskdefKey] === undefined || nocache === true) {
677 masksetDefinition = {
678 mask: mask,
679 maskToken: Inputmask.prototype.analyseMask(mask, regexMask, opts),
680 validPositions: {},
681 _buffer: undefined,
682 buffer: undefined,
683 tests: {},
684 excludes: {},
685 metadata: metadata,
686 maskLength: undefined,
687 jitOffset: {}
688 };
689 if (nocache !== true) {
690 Inputmask.prototype.masksCache[maskdefKey] = masksetDefinition;
691 masksetDefinition = $.extend(true, {}, Inputmask.prototype.masksCache[maskdefKey]);
692 }
693 } else masksetDefinition = $.extend(true, {}, Inputmask.prototype.masksCache[maskdefKey]);
694 return masksetDefinition;
695 }
696 var ms;
697 if ($.isFunction(opts.mask)) {
698 opts.mask = opts.mask(opts);
699 }
700 if ($.isArray(opts.mask)) {
701 if (opts.mask.length > 1) {
702 if (opts.keepStatic === null) {
703 opts.keepStatic = "auto";
704 for (var i = 0; i < opts.mask.length; i++) {
705 if (opts.mask[i].charAt(0) !== opts.mask[0].charAt(0)) {
706 opts.keepStatic = true;
707 break;
708 }
709 }
710 }
711 var altMask = opts.groupmarker[0];
712 $.each(opts.isRTL ? opts.mask.reverse() : opts.mask, function(ndx, msk) {

Callers 1

factoryFunction · 0.85

Calls 4

generateMaskFunction · 0.85
maskMethod · 0.45
reverseMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected