Unminify boolean expressions
Closed this issue · 2 comments
j4k0xb commented
Many obfuscators/minifiers convert if statements to these sorts of boolean expression chains which makes it hard to read:
c.classes[t] && e.classIndex != t && (e.classIndex = t, e.updateItems(c, l, !0));
// -->
if (c.classes[t] && e.classIndex != t)
e.classIndex = t, e.updateItems(c, l, true);
(and similar for ||
)
Is it ok if I PR this one for now? 🙂
The goal is to combine it later with a few other modules (sequence to statements, DeMorgan's law, yoda conditions):
!o || c.oldGameTimer || 'skip' == c.gameTimer || 0 < c.endTimer || 'inf' == c.endTimer || (c.oldGameTimer = c.gameTimer,
c.gameTimer = 0);
// -->
if (o && !c.oldGameTimer && c.gameTimer != 'skip' && c.endTimer <= 0 && c.endTimer != 'inf') {
c.oldGameTimer = c.gameTimer;
c.gameTimer = 0;
}
ctrl-escp commented
Sounds good to me!
PR away! :D
ctrl-escp commented
Sequence to statement sounds like a good next step to me as well, but will have to be careful with return statements that use sequences as their argument since all will execute but only the last value will be returned.