I want to clear an interval by using its intervalId which I intend to store in a local file.
I was under the impression that assigning setInterval returns its intervalId but I seem to be getting [object Timer] instead.
var fs = require("fs");
var id = setInterval(function(){
console.log("tick");
}, 1000);
console.log(id);
var stream = fs.createWriteStream("id");
stream.once('open', function(fd) {
stream.write(id);
});
I am using node v4.9
It is a timer object, but clears the way you would expect it to:
$ node ./test.js
Outputs the following for 5 seconds, and clears as expected:
More info: http://nodejs.org/docs/v0.5.10/api/timers.html