Chron
NodeJS task scheduler.
Install
npm install chron
Usage
var chron = "chron"; chron; // called every 10 secondschron; // called every 1.5 seconds { console;}
The advantage of the scheduler is it only has one timer, even if you have hundreds of tasks. It calculates when the next task needs to run and schedules a timer.
API
- chron.add(period, task)
- chron.remove(task)
- chron.clear()
- chron.pause()
- chron.resume()
A task
is a function that receives a parameter that you can use to control the task execution (the next calls).
{ $; // will stop executing, you need to store // a reference to $ to be able to resume $; // resume the previsouly paused task $; // completely remove the task - equal to chron.remove(task)}