run functions at the right time with the right frequency or know why it didn't work out.
var run = require('run-schedule');
var readable = run([
{
id: 'optional. for logging otherwise [0]'
duration: 1000
data: {hi: 1} // is passed as the argument to the job function
}
],{
repeat:true // optional. just keep going through this schedule forever.
},function(job, cb){
console.log(job.data) // logs "{hi: 1}"
cb() // callback must be called
})
export is the run function
schedule - an array of "job" objects that define intervals. Each job has these keys..
options - optional options object.
step(job,cb) - required. this is the function that processes each job when it's time.
RETURN readable - this is an object stream of events related to the progress and result of jobs.
{state:"start",job:job id,start:time in ms,end:time in ms, error: if state is error this is the message,data: the data from the step callback }
cb(false,"tacp") this will be "taco"