reschedulable setTimeout for you node needs. This library is built for building a keep alive functionality across a large numbers of clients/sockets.
Rescheduling a 10000 functions 20 times with an interval of 50ms (see
bench.js), with 100 repetitions:
npm install retimer --save
var retimer =var timer =
retimer(callback, timeout, [...args])
Exactly like your beloved
Reschedule the timer, if the specified timeout comes after the original timeout.
Returns true if successful, false otherwise
Clear the timer, like your beloved
How it works
Timers are stored in a Linked List in node.js, if you create a lot of timers this Linked List becomes massive which makes removing a timer an expensive operation. Retimer let the old timer run at its time, and schedule a new one accordingly.