@lazy-cjk/str-util-normalize
Version:
1 lines • 1.07 kB
Source Map (JSON)
{"version":3,"file":"index.esm.mjs","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,IAAa,EAEzB,oBACA,oBACA,oBAGA;;SAIeC,UAAUC,GAAeC,IAAoB;EAiB5D,OAfKA,EAAQC,eAEZF,IAAQA,EAAMG,QAAQ,SAAS,OAG3BF,EAAQG,cAEZJ,IAAQA,EAAMG,QAAQ,WAAW;EAGlCL,EAAWO,SAAQ,SAAUC;IAE5BN,IAAQA,EAAMG,QAAQG,GAAG;AAC1B,OAEON;AACR;;"}