Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mask.js.map 4.6KB

1
  1. {"version":3,"sources":["../../src/util/mask.ts"],"names":[],"mappings":";;;;;AAMO,IAAM,gDAAoB,qCAA1B;AAEA,IAAM,4CAAkB,SAAlB,eAAkB,CAAC,IAAD;AAAA,WAA2B,OAAO,kBAAkB,IAAlB,CAAuB,IAAvB,CAAP,GAAsC,KAAjE;AAAA,CAAxB;AAEP,IAAM,eAAqC;AACzC,SAAK;AACH,cAAM;AAAA,mBAAQ,SAAQ,IAAR,CAAa,IAAb;AAAR;AAAA;AADH,KADoC;AAIzC,SAAK;AACH,cAAM;AAAA,mBAAQ,UAAS,IAAT,CAAc,IAAd;AAAR;AAAA,SADH;AAEH,iBAAS;AAAA,mBAAQ,KAAK,WAAL,EAAR;AAAA;AAFN,KAJoC;AAQzC,SAAK;AACH,cAAM;AAAA,mBAAQ,UAAS,IAAT,CAAc,IAAd;AAAR;AAAA,SADH;AAEH,iBAAS;AAAA,mBAAQ,KAAK,WAAL,EAAR;AAAA;AAFN,KARoC;AAYzC,SAAK;AACH,cAAM;AAAA,mBAAQ,aAAY,IAAZ,CAAiB,IAAjB;AAAR;AAAA,SADH;AAEH,iBAAS;AAAA,mBAAQ,KAAK,WAAL,EAAR;AAAA;AAFN,KAZoC;AAgBzC,SAAK;AACH,cAAM;AAAA,mBAAQ,aAAY,IAAZ,CAAiB,IAAjB;AAAR;AAAA,SADH;AAEH,iBAAS;AAAA,mBAAQ,KAAK,WAAL,EAAR;AAAA;AAFN,KAhBoC;AAoBzC,SAAK;AACH,cAAM;AADH;AApBoC,CAA3C;AAyBA,IAAM,SAAS,SAAT,MAAS,CAAC,IAAD;AAAA,WAA2B,aAAa,cAAb,CAA4B,IAA5B,CAA3B;AAAA,CAAf;AAEA,IAAM,UAAU,SAAV,OAAU,CAAC,IAAD,EAAiB,IAAjB,EAAyC;AACvD,WAAO,aAAa,IAAb,E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CAAa,SAAb,UAAa,CAAC,IAAD,EAAyB;AACjD,WAAO,OAAO,OAAO,IAAP,EAAa,OAAb,CAAqB,IAAI,MAAJ,CAAW,iBAAX,EAA8B,GAA9B,CAArB,EAAyD,EAAzD,CAAP,GAAsE,IAA7E;AACD,CAFM","sourcesContent":["export interface MaskItem {\n test: (char: string) => boolean\n convert?: (char: string) => string\n}\nexport type MaskType = '#' | 'A' | 'a' | 'N' | 'n' | 'X'\n\nexport const defaultDelimiters = /[-!$%^&*()_+|~=`{}[\\]:\";'<>?,./\\\\ ]/\n\nexport const isMaskDelimiter = (char: string): boolean => char ? defaultDelimiters.test(char) : false\n\nconst allowedMasks: Dictionary<MaskItem> = {\n '#': {\n test: char => /[0-9]/.test(char)\n },\n 'A': {\n test: char => /[A-Z]/i.test(char),\n convert: char => char.toUpperCase()\n },\n 'a': {\n test: char => /[a-z]/i.test(char),\n convert: char => char.toLowerCase()\n },\n 'N': {\n test: char => /[0-9A-Z]/i.test(char),\n convert: char => char.toUpperCase()\n },\n 'n': {\n test: char => /[0-9a-z]/i.test(char),\n convert: char => char.toLowerCase()\n },\n 'X': {\n test: isMaskDelimiter\n }\n}\n\nconst isMask = (char: string): boolean => allowedMasks.hasOwnProperty(char)\n\nconst convert = (mask: MaskType, char: string): string => {\n return allowedMasks[mask].convert ? allowedMasks[mask].convert!(char) : char\n}\n\nconst maskValidates = (mask: MaskType, char: string): boolean => {\n if (char == null || !isMask(mask)) return false\n return allowedMasks[mask].test(char)\n}\n\nexport const maskText = (text: string | null | undefined, masked: string | string[], dontFillMaskBlanks: boolean): string => {\n if (text == null) return ''\n text = String(text)\n if (!masked.length || !text.length) return text\n if (!Array.isArray(masked)) masked = masked.split('')\n\n let textIndex = 0\n let maskIndex = 0\n let newText = ''\n\n while (maskIndex < masked.length) {\n const mask = masked[maskIndex]\n\n // Assign the next character\n const char = text[textIndex]\n\n // Check if mask is delimiter\n // and current char matches\n if (!isMask(mask) && char === mask) {\n newText += mask\n textIndex++\n // Check if not mask\n } else if (!isMask(mask) && !dontFillMaskBlanks) {\n newText += mask\n // Check if is mask and validates\n } else if (maskValidates(mask as MaskType, char)) {\n newText += convert(mask as MaskType, char)\n textIndex++\n } else {\n return newText\n }\n\n maskIndex++\n }\n\n return newText\n}\n\nexport const unmaskText = (text: string): string => {\n return text ? String(text).replace(new RegExp(defaultDelimiters, 'g'), '') : text\n}\n"],"sourceRoot":""}