Closed Matt-Esch closed 10 years ago
Alright. I'll merge this - but could you explain your last statement, about easier inspection?
Hey, thanks for merging this. By easier inspection I mean if you require globals instead of just using them inline, you can see clearly which globals your code depends on, as all dependencies are listed as a set of require statements at the top of the function. It also means we can do some nice things where we can provide different resources through require (like in browserify) instead of trying to punch the environment when we go to run the code outside of a standard node environment, such as the browser or test environment.
I ran into a production issue where timers were being redefined for test purposes. The timer redefinition did not emulate node timers, and so
unref
was therefore undefined. While I admit that redefining globals is a bad idea and shouldn't have been done in the first place, in general I think it's good practice to depend on the timers module. Not only does this guard against the global redefinition but it also allows easier inspection, i.e. we can see which timers are being used upfront.