From 514c6fbf956c81622de88f13876a112dd9fe0c71 Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Sat, 4 Dec 2021 11:49:28 +0100 Subject: [PATCH] Rewrite conditional as switch This is actually what the code tries to do, the conditional just makes it harder to read --- src/models/msg.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/models/msg.js b/src/models/msg.js index c6d87d13..ed2ce6e5 100644 --- a/src/models/msg.js +++ b/src/models/msg.js @@ -42,16 +42,19 @@ class Msg { return !!this.from.nick; } - return ( - this.type !== Msg.Type.MONOSPACE_BLOCK && - this.type !== Msg.Type.ERROR && - this.type !== Msg.Type.TOPIC_SET_BY && - this.type !== Msg.Type.MODE_CHANNEL && - this.type !== Msg.Type.MODE_USER && - this.type !== Msg.Type.RAW && - this.type !== Msg.Type.WHOIS && - this.type !== Msg.Type.PLUGIN - ); + switch (this.type) { + case Msg.Type.MONOSPACE_BLOCK: + case Msg.Type.ERROR: + case Msg.Type.TOPIC_SET_BY: + case Msg.Type.MODE_CHANNEL: + case Msg.Type.MODE_USER: + case Msg.Type.RAW: + case Msg.Type.WHOIS: + case Msg.Type.PLUGIN: + return false; + default: + return true; + } } }