« get me outta code hell

new parser progress so far (cur: 15k/sec) - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/upd8-util.js
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-04-15 12:32:17 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-04-15 12:48:04 -0300
commit7b1ad75b0e7f9adfb397dda1ad28941cf319bef8 (patch)
tree363811306dd181b0426bf2e4e1faf1af917aa0d6 /upd8-util.js
parent0d0d38ce51ca02b7c3bd91317b5fa0bbff1f06de (diff)
new parser progress so far (cur: 15k/sec)
not implemented into the site (so just process.exit()), includes a
couple examples and speedtest (not optimized at all yet)
Diffstat (limited to 'upd8-util.js')
-rw-r--r--upd8-util.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/upd8-util.js b/upd8-util.js
index abeed6c1..30260f8d 100644
--- a/upd8-util.js
+++ b/upd8-util.js
@@ -416,3 +416,14 @@ module.exports.promisifyProcess = function(proc, showLogging = true) {
 
 // Stolen from jq! Which pro8a8ly stole the concept from other places. Nice.
 module.exports.withEntries = (obj, fn) => Object.fromEntries(fn(Object.entries(obj)));
+
+// Stolen from here: https://stackoverflow.com/a/53925033
+// We changed the # to // though.
+module.exports.makeExtendedRegExp = (inputPatternStr, flags) => {
+    // Remove everything between the first unescaped `//` and the end of a line
+    // and then remove all unescaped whitespace
+    const cleanedPatternStr = inputPatternStr
+        .replace(/(^|[^\\])\/\/.*/g, '$1')
+        .replace(/(^|[^\\])\s+/g, '$1');
+    return new RegExp(cleanedPatternStr, flags);
+};