14 lines
313 B
TypeScript
14 lines
313 B
TypeScript
const singleTagRegEx = /<[^>]+?>/g;
|
|
const whitespaceRegEx = /(\s)\s+/g;
|
|
|
|
function clean(text: string): string {
|
|
text = text.replaceAll(whitespaceRegEx, "$1");
|
|
text = text.replaceAll(singleTagRegEx, "");
|
|
|
|
return text;
|
|
}
|
|
|
|
onmessage = (e) => {
|
|
const result = clean(e.data);
|
|
postMessage(result);
|
|
} |