4 ms·
IMO, I don't really like it as a switch or the if statements. My issue being the multiple booleans being passed to a single function. I could see it growing to
by drbojingle 7y ago
IMO, I don't really like it as a switch or the if statements. My issue being the multiple booleans being passed to a single function. I could see it growing to 3, 4, or greater too if more social options were added. I prefer enums.
SocialUrl = 'github' // or twitter or w/e
return socialConfig[SocialUrl] || defaultSocialConfig
or how about:
const getConfig = (key, default) => config[key] || default
Logic per key value isn't necessary.
edit: disregard. Misunderstood the code =)
- masklinn 7y agoThere are no multiple booleans passed to the function, there are actual github and twitter URLs being passed in, and likely integrated into the config objects before being checked for existence.
- drbojingle 7y agoahhhh ok, then I've misunderstood the code, thank you. Disregard :)