Updated node optimization

Abstracted into a utility function.
This commit is contained in:
Angelos Chalaris
2018-02-04 20:03:00 +02:00
parent 5255ed1a3d
commit 25b97819b1
2 changed files with 48 additions and 32 deletions

View File

@ -48,4 +48,16 @@ const readTags = () => {
}
return tagDbData;
}
module.exports = {readSnippets, readTags};
const optimizeNodes = (data, regexp, replacer) => {
let count = 0;
let output = data;
do {
output = output.replace(regexp, replacer);
count = 0;
while (regexp.exec(output) !== null) {
++count;
}
} while (count > 0);
return output;
}
module.exports = {readSnippets, readTags, optimizeNodes};