defunctzombie / node-process

process information for node.js and browsers
MIT License
122 stars 62 forks source link

Mention `process.browser` in README.md #47

Closed zenflow closed 9 years ago

zenflow commented 9 years ago

This turned out to be a very important feature to me.

For isomorphic apps, we frequently need to refer to whether our js is running in node or the browser. Knowing the shortest way to reference this has become a point for me.

My first solution was to put var on_client = typeof window=='object'; around the top of all the modules that needed it, with the dependencies, but this seemed like an anti-pattern.

I actually went to the extent of publishing an on-client package for determining the environment, which i've now deprecated.

I also considered depending on lodash.support.dom and lodash.support.dom (also undocumented!)

And (since I'm using browserify) process.browser was there all along! lol

defunctzombie commented 9 years ago

swash commits please