var seconds = 300;
var hb = setTimeout(heartbeat, seconds*1000);
//process stuff here
//isPulse can be whatever you want.
//It just needs to be something that will stop the recursive loop--an error condition, perhaps.
//Having a condition to stop this is a good idea, otherwise it will start acting like a memory leak.
//You could change the condition to be an amount of time, number of loops, or some other condition.
//function call is here
var hb = setTimeout(heartbeat, seconds*1000); //beat every 5 minutes