sked
Scheduler based in Javascript timers
Installation
$ node install --save sked
Usage
The constructor accepts 3 arguments: config
, callback
and context
.
Use https://github.com/guille/ms.js/ for times if you want.
var sked = ; var config = start: date string or ms period: ms or string ; var context = this; var scheduler = ;
if you don't pass a context, it will be the scheduler itself
;
There is a start method that can be accessed using sked as a constructor.
If you pass true to this method it will execute now
(synchronously) in case the
start time is not 0
or now
.
var Sked = ;var scheduler = config {};schedulerstarttrue; // will do now
Config options
You can skip the options and by default they will became:
period: '1d' start: 'now'
So this will work once a day from now:
var scheduler = ;
start:
start can be omitted and will became now
:
var config = period: '1d' ;// will becamevar config = start: 'now' period: '1d' ;// which is equivalent tovar config = '1d';
start can be a date:
var config = start: '2017-04-15T18:06:08-07:00' period:... ;
or a string:
// start one minute in the futurevar config = start: '1m' period:... ;
or milliseconds:
// start one minute in the futurevar config = start: 60000 period:... ;
period:
If period is omitted, will run only once, but for that purpose you better use just a setTimeout unless you are passing a Date instance
// execute once after a secondvar config = start: 1000 ;
A string or an integer instead of an object will be interpreted
// this worksvar config = '1m';// also thisvar config = 60000;
preRun:
Default false. It's equivalent to passing true to the start method skedInstance.start(true)
.