Skip to content

Instantly share code, notes, and snippets.

@gramki
Created May 22, 2012 19:46
Show Gist options
  • Select an option

  • Save gramki/2771186 to your computer and use it in GitHub Desktop.

Select an option

Save gramki/2771186 to your computer and use it in GitHub Desktop.
Timers are fired even if the descriptors are ready for read
var fs = require('fs');
var readCount = 0;
var read_stream = fs.createReadStream('/dev/zero', {encoding: 'ascii'});
read_stream.on("data", function(data) {
console.log("Read " + (readCount++) + " times");
});
setInterval(function(){
console.log("Timer: " + (new Date()).valueOf() % 10000);
}, 100);
/*
$ node a.js | grep Timer
Timer: 6536
Timer: 6637
Timer: 6738
Timer: 6837
Timer: 6940
Timer: 7038
Timer: 7138
Timer: 7237
Timer: 7337
Timer: 7437
Timer: 7539
Timer: 7640
Timer: 7738
Timer: 7838
Timer: 7937
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment