cron 1.8.1 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/examples/basic.js +1 -1
- package/lib/cron.js +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,9 +45,10 @@ Usage (basic cron usage):
|
|
|
45
45
|
|
|
46
46
|
```javascript
|
|
47
47
|
var CronJob = require('cron').CronJob;
|
|
48
|
-
new CronJob('* * * * * *', function() {
|
|
48
|
+
var job = new CronJob('* * * * * *', function() {
|
|
49
49
|
console.log('You will see this message every second');
|
|
50
50
|
}, null, true, 'America/Los_Angeles');
|
|
51
|
+
job.start();
|
|
51
52
|
```
|
|
52
53
|
|
|
53
54
|
Note - You need to explicitly start a job in order to make it run. This gives a
|
package/examples/basic.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const CronJob = require('../lib/cron.js').CronJob;
|
|
2
2
|
|
|
3
3
|
console.log('Before job instantiation');
|
|
4
|
-
const job = new CronJob('* *
|
|
4
|
+
const job = new CronJob('* * 7-23 * * *', function() {
|
|
5
5
|
const d = new Date();
|
|
6
6
|
console.log('Every second:', d);
|
|
7
7
|
});
|
package/lib/cron.js
CHANGED
|
@@ -454,11 +454,14 @@
|
|
|
454
454
|
for (var i = 0; i < allRanges.length; i++) {
|
|
455
455
|
if (allRanges[i].match(rangePattern)) {
|
|
456
456
|
allRanges[i].replace(rangePattern, function($0, lower, upper, step) {
|
|
457
|
-
|
|
457
|
+
lower = parseInt(lower, 10);
|
|
458
|
+
upper = parseInt(upper, 10) || undefined;
|
|
459
|
+
|
|
460
|
+
const wasStepDefined = !isNaN(parseInt(step, 10));
|
|
458
461
|
if (step === '0') {
|
|
459
462
|
throw new Error('Field (' + field + ') has a step of zero');
|
|
460
463
|
}
|
|
461
|
-
step = parseInt(step) || 1;
|
|
464
|
+
step = parseInt(step, 10) || 1;
|
|
462
465
|
|
|
463
466
|
if (upper && lower > upper) {
|
|
464
467
|
throw new Error('Field (' + field + ') has an invalid range');
|
package/package.json
CHANGED