When you see yourself writing a bunch of `if` checks like this through your code, consider whether you should instead use the Strategy pattern, and have a single check at the start for `module`, then use the node Strategy, otherwise use the Browser strategy.  Each of these are objects that provide implementations of functions you need for the given environment with identical signatures (i.e., you can swap them).