I just finished answering this question on StackOverflow and it got me thinking about the obvious: timers are not specified yet are central to a vast swath of JavaScript code. Timers in Node.js have a significantly higher resolution than what is found in browsers: `setTimeout(fn, 1)` will, in fact, execute in 1 millisecond (assuming the system isn't taxed to the point of being unresponsive). Browsers have collectively implemented a floor at around 15ms. Code that works fine in a browser can very well melt the computer if run in Node. For reference, here's the answer I wrote on StackOverflow;
It doesn't have a minimum delay and this is actually a compatibility issue between browsers and node. Timers are completely unspecified and node implements them simply due to how fundamental they've been in JavaScript's history and how irreplaceable they are otherwise. Node uses libuv which a cross-platform abstraction layer for lower level system things like file-system, networking stuff, etc. One of those things is timers, which Node provides a minimal wrapper around. At the libuv level, the timers used are the system-specific high precision timers. In Windows, for example, this is implemented using QueryPerformanceFrequency and FileTimeToSystemTime which provides resolution measured in nanoseconds. http://msdn.microsoft.com/en-us/library/windows/desktop/ms644905(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/windows/desktop/ms724280(v=vs.85).aspx
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

