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
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