« get me outta code hell

simple replaceKey/Value syntax (cur: 110k/sec) - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-04-15 16:00:46 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-04-15 16:00:46 -0300
commitd3311d056ccae94001ae5af083572f2111b61b77 (patch)
tree2bfb50381e73012358165663f34099b3f082f6bf
parent3c87ee4888f936181ac1e74392e44ce02c499e00 (diff)
simple replaceKey/Value syntax (cur: 110k/sec)
Not actually a speed-up, 8ut this is easier to read. Learn it from me:
with no other 8enefits, prefer what's legi8le, not what's cool!

At least in projects where the whole point isn't 8eing cool, anyway.
-rwxr-xr-xupd8.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/upd8.js b/upd8.js
index 7ec6b55..8d22f64 100755
--- a/upd8.js
+++ b/upd8.js
@@ -1097,13 +1097,19 @@ const replacerSpec = {
 
                 // Assign first & second to replacer key/value
 
+                let replacerKey,
+                    replacerValue;
+
                 // Value is an array of nodes, 8ut key is just one (or null).
                 // So if we use replacerFirst as the value, we need to stick
                 // it in an array (on its own).
-                const [ replacerKey, replacerValue ] =
-                    (replacerSecond
-                        ? [replacerFirst, replacerSecond]
-                        : [null, [replacerFirst]]);
+                if (replacerSecond) {
+                    replacerKey = replacerFirst;
+                    replacerValue = replacerSecond;
+                } else {
+                    replacerKey = null;
+                    replacerValue = [replacerFirst];
+                }
 
                 // Arguments