@lazy-cjk/str-util-normalize
Version:
1 lines • 1.39 kB
Source Map (JSON)
{"version":3,"file":"index.cjs.development.cjs","sources":["../src/index.ts"],"sourcesContent":["\nexport const StripTable = [\n\n\t/[\\u2000-\\u200F]/g,\n\t/[\\u2028-\\u202F]/g,\n\t/[\\u205F-\\u206F]/g,\n\n\t// ZERO WIDTH NO-BREAK SPACE\n\t/\\uFEFF/g,\n\n] as readonly RegExp[];\n\nexport function normalize(input: string, options: IOptions = {}): string\n{\n\tif (!options.allow_nbsp)\n\t{\n\t\tinput = input.replace(/\\xA0/g, ' ');\n\t}\n\n\tif (!options.allow_bom)\n\t{\n\t\tinput = input.replace(/\\uFEFF/g, '');\n\t}\n\n\tStripTable.forEach(function (r)\n\t{\n\t\tinput = input.replace(r, '');\n\t});\n\n\treturn input;\n}\n\nexport type IOptions = {\n\tallow_nbsp?: boolean,\n\tallow_bom?: boolean,\n}\n\nexport default normalize;\n"],"names":["StripTable","normalize","input","options","allow_nbsp","replace","allow_bom","forEach","r"],"mappings":";;;;AACO,MAAMA,UAAU,GAAG,CAEzB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAGlB,SAAS,EAEY;SAENC,SAASA,CAACC,KAAa,EAAEC,UAAoB,EAAE,EAAA;AAE9D,EAAA,IAAI,CAACA,OAAO,CAACC,UAAU,EACvB;IACCF,KAAK,GAAGA,KAAK,CAACG,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;AACpC,GAAA;AAEA,EAAA,IAAI,CAACF,OAAO,CAACG,SAAS,EACtB;IACCJ,KAAK,GAAGA,KAAK,CAACG,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;AACrC,GAAA;AAEAL,EAAAA,UAAU,CAACO,OAAO,CAAC,UAAUC,CAAC,EAAA;IAE7BN,KAAK,GAAGA,KAAK,CAACG,OAAO,CAACG,CAAC,EAAE,EAAE,CAAC,CAAA;AAC7B,GAAC,CAAC,CAAA;AAEF,EAAA,OAAON,KAAK,CAAA;AACb;;;;;;"}