Some methods guard against invalid arguments (formatRelativeNumber() checks that its argument is a number), others don't (hex2bg() assumes that its argument is a string). Some parts use null-checks (event.message?.StarSystem), others don't (event.message.Name).
Make it make more sense.
-
Pro: you'll never know. better to check argument types and requirements, throw or return sensible values in case of error. ?., typeof and === undefined should be cheap. Is branch prediction still a thing after Spectre?
-
Con: we don't need no safety checks, they only waste cycles. The gateway already validates the data, doesn't it? event.header.uploaderID should always be a string, never a number or undefined. And if it were, exceptions would be thrown and logged by MessageRouter, as intended.
Some methods guard against invalid arguments (
formatRelativeNumber()checks that its argument is a number), others don't (hex2bg()assumes that its argument is a string). Some parts use null-checks (event.message?.StarSystem), others don't (event.message.Name).Make it make more sense.
Pro: you'll never know. better to check argument types and requirements, throw or return sensible values in case of error.
?.,typeofand=== undefinedshould be cheap. Is branch prediction still a thing after Spectre?Con: we don't need no safety checks, they only waste cycles. The gateway already validates the data, doesn't it?
event.header.uploaderIDshould always be a string, never a number or undefined. And if it were, exceptions would be thrown and logged byMessageRouter, as intended.