croner 9.0.0-dev.2 → 9.0.0-dev.4
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/dist/croner.cjs +21 -12
- package/dist/croner.d.cts +10 -6
- package/dist/croner.d.ts +10 -6
- package/dist/croner.js +21 -12
- package/dist/croner.umd.js +21 -12
- package/package.json +1 -1
package/dist/croner.cjs
CHANGED
|
@@ -145,7 +145,7 @@ var CronPattern = class {
|
|
|
145
145
|
* @private
|
|
146
146
|
*/
|
|
147
147
|
parse() {
|
|
148
|
-
if (!(typeof this.pattern === "string")) {
|
|
148
|
+
if (!(typeof this.pattern === "string" || this.pattern instanceof String)) {
|
|
149
149
|
throw new TypeError("CronPattern: Pattern has to be of type string.");
|
|
150
150
|
}
|
|
151
151
|
if (this.pattern.indexOf("@") >= 0) this.pattern = this.handleNicknames(this.pattern).trim();
|
|
@@ -371,6 +371,9 @@ var CronPattern = class {
|
|
|
371
371
|
if (split.length !== 2) {
|
|
372
372
|
throw new TypeError("CronPattern: Syntax error, illegal stepping: '" + conf + "'");
|
|
373
373
|
}
|
|
374
|
+
if (split[0] === "") {
|
|
375
|
+
split[0] = "*";
|
|
376
|
+
}
|
|
374
377
|
let start = 0;
|
|
375
378
|
if (split[0] !== "*") {
|
|
376
379
|
start = parseInt(split[0], 10) + valueIndexOffset;
|
|
@@ -439,13 +442,13 @@ var CronPattern = class {
|
|
|
439
442
|
setNthWeekdayOfMonth(index, nthWeekday) {
|
|
440
443
|
if (typeof nthWeekday !== "number" && nthWeekday === "L") {
|
|
441
444
|
this["dayOfWeek"][index] = this["dayOfWeek"][index] | LAST_OCCURRENCE;
|
|
442
|
-
} else if (
|
|
443
|
-
this["dayOfWeek"][index] = this["dayOfWeek"][index] | OCCURRENCE_BITMASKS[nthWeekday - 1];
|
|
444
|
-
} else if (typeof nthWeekday === "number" && nthWeekday === ANY_OCCURRENCE) {
|
|
445
|
+
} else if (nthWeekday === ANY_OCCURRENCE) {
|
|
445
446
|
this["dayOfWeek"][index] = ANY_OCCURRENCE;
|
|
447
|
+
} else if (nthWeekday < 6 && nthWeekday > 0) {
|
|
448
|
+
this["dayOfWeek"][index] = this["dayOfWeek"][index] | OCCURRENCE_BITMASKS[nthWeekday - 1];
|
|
446
449
|
} else {
|
|
447
450
|
throw new TypeError(
|
|
448
|
-
`CronPattern: nth weekday
|
|
451
|
+
`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${nthWeekday}, Type: ${typeof nthWeekday}`
|
|
449
452
|
);
|
|
450
453
|
}
|
|
451
454
|
}
|
|
@@ -625,7 +628,7 @@ var CronDate = class _CronDate {
|
|
|
625
628
|
*/
|
|
626
629
|
fromString(str) {
|
|
627
630
|
if (typeof this.tz === "number") {
|
|
628
|
-
const inDate = minitz.fromTZISO(str
|
|
631
|
+
const inDate = minitz.fromTZISO(str);
|
|
629
632
|
this.ms = inDate.getUTCMilliseconds();
|
|
630
633
|
this.second = inDate.getUTCSeconds();
|
|
631
634
|
this.minute = inDate.getUTCMinutes();
|
|
@@ -634,8 +637,8 @@ var CronDate = class _CronDate {
|
|
|
634
637
|
this.month = inDate.getUTCMonth();
|
|
635
638
|
this.year = inDate.getUTCFullYear();
|
|
636
639
|
this.apply();
|
|
637
|
-
} else
|
|
638
|
-
return this.fromDate(minitz.fromTZISO(str, this.tz
|
|
640
|
+
} else {
|
|
641
|
+
return this.fromDate(minitz.fromTZISO(str, this.tz));
|
|
639
642
|
}
|
|
640
643
|
}
|
|
641
644
|
/**
|
|
@@ -987,7 +990,7 @@ var Cron = class {
|
|
|
987
990
|
prev = prev || /* @__PURE__ */ new Date();
|
|
988
991
|
const next = this._next(prev);
|
|
989
992
|
if (next) {
|
|
990
|
-
if (prev instanceof CronDate) {
|
|
993
|
+
if (prev instanceof CronDate || prev instanceof Date) {
|
|
991
994
|
return next.getTime() - prev.getTime();
|
|
992
995
|
} else {
|
|
993
996
|
return next.getTime() - new CronDate(prev).getTime();
|
|
@@ -1092,6 +1095,12 @@ var Cron = class {
|
|
|
1092
1095
|
async trigger() {
|
|
1093
1096
|
await this._trigger();
|
|
1094
1097
|
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Returns number of runs left, undefined = unlimited
|
|
1100
|
+
*/
|
|
1101
|
+
runsLeft() {
|
|
1102
|
+
return this._states.maxRuns;
|
|
1103
|
+
}
|
|
1095
1104
|
/**
|
|
1096
1105
|
* Called when it's time to trigger.
|
|
1097
1106
|
* Checks if all conditions are currently met,
|
|
@@ -1152,14 +1161,14 @@ var Cron = class {
|
|
|
1152
1161
|
let newPrev = prev;
|
|
1153
1162
|
if (this.options.startAt.getTime() <= now.getTime()) {
|
|
1154
1163
|
newPrev = this.options.startAt;
|
|
1155
|
-
let prevTimePlusInterval =
|
|
1164
|
+
let prevTimePlusInterval = newPrev.getTime() + this.options.interval * 1e3;
|
|
1156
1165
|
while (prevTimePlusInterval <= now.getTime()) {
|
|
1157
|
-
newPrev = new CronDate(
|
|
1166
|
+
newPrev = new CronDate(newPrev, this.options.timezone || this.options.utcOffset).increment(
|
|
1158
1167
|
this._states.pattern,
|
|
1159
1168
|
this.options,
|
|
1160
1169
|
true
|
|
1161
1170
|
);
|
|
1162
|
-
prevTimePlusInterval =
|
|
1171
|
+
prevTimePlusInterval = newPrev.getTime() + this.options.interval * 1e3;
|
|
1163
1172
|
}
|
|
1164
1173
|
hasPreviousRun = true;
|
|
1165
1174
|
}
|
package/dist/croner.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ declare module "helpers/minitz" {
|
|
|
6
6
|
h: number;
|
|
7
7
|
i: number;
|
|
8
8
|
s: number;
|
|
9
|
-
tz
|
|
9
|
+
tz?: string;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Converts a date/time from a specific timezone to a normal date object using the system local time
|
|
@@ -29,7 +29,7 @@ declare module "helpers/minitz" {
|
|
|
29
29
|
*/
|
|
30
30
|
function minitz(y: number, m: number, d: number, h: number, i: number, s: number, tz: string, throwOnInvalid?: boolean): Date;
|
|
31
31
|
namespace minitz {
|
|
32
|
-
var fromTZISO: (localTimeStr: string, tz
|
|
32
|
+
var fromTZISO: (localTimeStr: string, tz?: string, throwOnInvalid?: boolean) => Date;
|
|
33
33
|
var fromTZ: (tp: TimePoint, throwOnInvalid?: boolean) => Date;
|
|
34
34
|
var toTZ: (d: Date, tzStr: string) => {
|
|
35
35
|
y: number;
|
|
@@ -40,7 +40,7 @@ declare module "helpers/minitz" {
|
|
|
40
40
|
s: number;
|
|
41
41
|
tz: string;
|
|
42
42
|
};
|
|
43
|
-
var tp: (y: number, m: number, d: number, h: number, i: number, s: number, tz
|
|
43
|
+
var tp: (y: number, m: number, d: number, h: number, i: number, s: number, tz?: string) => {
|
|
44
44
|
y: number;
|
|
45
45
|
m: number;
|
|
46
46
|
d: number;
|
|
@@ -240,7 +240,7 @@ declare module "date" {
|
|
|
240
240
|
* Current full year, in local time or target timezone specified by `this.tz`
|
|
241
241
|
*/
|
|
242
242
|
year: number;
|
|
243
|
-
constructor(d?: CronDate | Date | string, tz?: string | number);
|
|
243
|
+
constructor(d?: CronDate | Date | string | null, tz?: string | number);
|
|
244
244
|
/**
|
|
245
245
|
* Check if the given date is the nth occurrence of a weekday in its month.
|
|
246
246
|
*
|
|
@@ -354,7 +354,7 @@ declare module "croner" {
|
|
|
354
354
|
* @param prev - Date to start from
|
|
355
355
|
* @returns Next run time
|
|
356
356
|
*/
|
|
357
|
-
nextRun(prev?: CronDate | Date | string): Date | null;
|
|
357
|
+
nextRun(prev?: CronDate | Date | string | null): Date | null;
|
|
358
358
|
/**
|
|
359
359
|
* Find next n runs, based on supplied date. Strips milliseconds.
|
|
360
360
|
*
|
|
@@ -362,7 +362,7 @@ declare module "croner" {
|
|
|
362
362
|
* @param previous - Date to start from
|
|
363
363
|
* @returns - Next n run times
|
|
364
364
|
*/
|
|
365
|
-
nextRuns(n: number, previous
|
|
365
|
+
nextRuns(n: number, previous?: Date | string): Date[];
|
|
366
366
|
/**
|
|
367
367
|
* Return the original pattern, if there was one
|
|
368
368
|
*
|
|
@@ -438,6 +438,10 @@ declare module "croner" {
|
|
|
438
438
|
* Trigger a run manually
|
|
439
439
|
*/
|
|
440
440
|
trigger(): Promise<void>;
|
|
441
|
+
/**
|
|
442
|
+
* Returns number of runs left, undefined = unlimited
|
|
443
|
+
*/
|
|
444
|
+
runsLeft(): number | undefined;
|
|
441
445
|
/**
|
|
442
446
|
* Called when it's time to trigger.
|
|
443
447
|
* Checks if all conditions are currently met,
|
package/dist/croner.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare module "helpers/minitz" {
|
|
|
6
6
|
h: number;
|
|
7
7
|
i: number;
|
|
8
8
|
s: number;
|
|
9
|
-
tz
|
|
9
|
+
tz?: string;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Converts a date/time from a specific timezone to a normal date object using the system local time
|
|
@@ -29,7 +29,7 @@ declare module "helpers/minitz" {
|
|
|
29
29
|
*/
|
|
30
30
|
function minitz(y: number, m: number, d: number, h: number, i: number, s: number, tz: string, throwOnInvalid?: boolean): Date;
|
|
31
31
|
namespace minitz {
|
|
32
|
-
var fromTZISO: (localTimeStr: string, tz
|
|
32
|
+
var fromTZISO: (localTimeStr: string, tz?: string, throwOnInvalid?: boolean) => Date;
|
|
33
33
|
var fromTZ: (tp: TimePoint, throwOnInvalid?: boolean) => Date;
|
|
34
34
|
var toTZ: (d: Date, tzStr: string) => {
|
|
35
35
|
y: number;
|
|
@@ -40,7 +40,7 @@ declare module "helpers/minitz" {
|
|
|
40
40
|
s: number;
|
|
41
41
|
tz: string;
|
|
42
42
|
};
|
|
43
|
-
var tp: (y: number, m: number, d: number, h: number, i: number, s: number, tz
|
|
43
|
+
var tp: (y: number, m: number, d: number, h: number, i: number, s: number, tz?: string) => {
|
|
44
44
|
y: number;
|
|
45
45
|
m: number;
|
|
46
46
|
d: number;
|
|
@@ -240,7 +240,7 @@ declare module "date" {
|
|
|
240
240
|
* Current full year, in local time or target timezone specified by `this.tz`
|
|
241
241
|
*/
|
|
242
242
|
year: number;
|
|
243
|
-
constructor(d?: CronDate | Date | string, tz?: string | number);
|
|
243
|
+
constructor(d?: CronDate | Date | string | null, tz?: string | number);
|
|
244
244
|
/**
|
|
245
245
|
* Check if the given date is the nth occurrence of a weekday in its month.
|
|
246
246
|
*
|
|
@@ -354,7 +354,7 @@ declare module "croner" {
|
|
|
354
354
|
* @param prev - Date to start from
|
|
355
355
|
* @returns Next run time
|
|
356
356
|
*/
|
|
357
|
-
nextRun(prev?: CronDate | Date | string): Date | null;
|
|
357
|
+
nextRun(prev?: CronDate | Date | string | null): Date | null;
|
|
358
358
|
/**
|
|
359
359
|
* Find next n runs, based on supplied date. Strips milliseconds.
|
|
360
360
|
*
|
|
@@ -362,7 +362,7 @@ declare module "croner" {
|
|
|
362
362
|
* @param previous - Date to start from
|
|
363
363
|
* @returns - Next n run times
|
|
364
364
|
*/
|
|
365
|
-
nextRuns(n: number, previous
|
|
365
|
+
nextRuns(n: number, previous?: Date | string): Date[];
|
|
366
366
|
/**
|
|
367
367
|
* Return the original pattern, if there was one
|
|
368
368
|
*
|
|
@@ -438,6 +438,10 @@ declare module "croner" {
|
|
|
438
438
|
* Trigger a run manually
|
|
439
439
|
*/
|
|
440
440
|
trigger(): Promise<void>;
|
|
441
|
+
/**
|
|
442
|
+
* Returns number of runs left, undefined = unlimited
|
|
443
|
+
*/
|
|
444
|
+
runsLeft(): number | undefined;
|
|
441
445
|
/**
|
|
442
446
|
* Called when it's time to trigger.
|
|
443
447
|
* Checks if all conditions are currently met,
|
package/dist/croner.js
CHANGED
|
@@ -115,7 +115,7 @@ var CronPattern = class {
|
|
|
115
115
|
* @private
|
|
116
116
|
*/
|
|
117
117
|
parse() {
|
|
118
|
-
if (!(typeof this.pattern === "string")) {
|
|
118
|
+
if (!(typeof this.pattern === "string" || this.pattern instanceof String)) {
|
|
119
119
|
throw new TypeError("CronPattern: Pattern has to be of type string.");
|
|
120
120
|
}
|
|
121
121
|
if (this.pattern.indexOf("@") >= 0) this.pattern = this.handleNicknames(this.pattern).trim();
|
|
@@ -341,6 +341,9 @@ var CronPattern = class {
|
|
|
341
341
|
if (split.length !== 2) {
|
|
342
342
|
throw new TypeError("CronPattern: Syntax error, illegal stepping: '" + conf + "'");
|
|
343
343
|
}
|
|
344
|
+
if (split[0] === "") {
|
|
345
|
+
split[0] = "*";
|
|
346
|
+
}
|
|
344
347
|
let start = 0;
|
|
345
348
|
if (split[0] !== "*") {
|
|
346
349
|
start = parseInt(split[0], 10) + valueIndexOffset;
|
|
@@ -409,13 +412,13 @@ var CronPattern = class {
|
|
|
409
412
|
setNthWeekdayOfMonth(index, nthWeekday) {
|
|
410
413
|
if (typeof nthWeekday !== "number" && nthWeekday === "L") {
|
|
411
414
|
this["dayOfWeek"][index] = this["dayOfWeek"][index] | LAST_OCCURRENCE;
|
|
412
|
-
} else if (
|
|
413
|
-
this["dayOfWeek"][index] = this["dayOfWeek"][index] | OCCURRENCE_BITMASKS[nthWeekday - 1];
|
|
414
|
-
} else if (typeof nthWeekday === "number" && nthWeekday === ANY_OCCURRENCE) {
|
|
415
|
+
} else if (nthWeekday === ANY_OCCURRENCE) {
|
|
415
416
|
this["dayOfWeek"][index] = ANY_OCCURRENCE;
|
|
417
|
+
} else if (nthWeekday < 6 && nthWeekday > 0) {
|
|
418
|
+
this["dayOfWeek"][index] = this["dayOfWeek"][index] | OCCURRENCE_BITMASKS[nthWeekday - 1];
|
|
416
419
|
} else {
|
|
417
420
|
throw new TypeError(
|
|
418
|
-
`CronPattern: nth weekday
|
|
421
|
+
`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${nthWeekday}, Type: ${typeof nthWeekday}`
|
|
419
422
|
);
|
|
420
423
|
}
|
|
421
424
|
}
|
|
@@ -595,7 +598,7 @@ var CronDate = class _CronDate {
|
|
|
595
598
|
*/
|
|
596
599
|
fromString(str) {
|
|
597
600
|
if (typeof this.tz === "number") {
|
|
598
|
-
const inDate = minitz.fromTZISO(str
|
|
601
|
+
const inDate = minitz.fromTZISO(str);
|
|
599
602
|
this.ms = inDate.getUTCMilliseconds();
|
|
600
603
|
this.second = inDate.getUTCSeconds();
|
|
601
604
|
this.minute = inDate.getUTCMinutes();
|
|
@@ -604,8 +607,8 @@ var CronDate = class _CronDate {
|
|
|
604
607
|
this.month = inDate.getUTCMonth();
|
|
605
608
|
this.year = inDate.getUTCFullYear();
|
|
606
609
|
this.apply();
|
|
607
|
-
} else
|
|
608
|
-
return this.fromDate(minitz.fromTZISO(str, this.tz
|
|
610
|
+
} else {
|
|
611
|
+
return this.fromDate(minitz.fromTZISO(str, this.tz));
|
|
609
612
|
}
|
|
610
613
|
}
|
|
611
614
|
/**
|
|
@@ -957,7 +960,7 @@ var Cron = class {
|
|
|
957
960
|
prev = prev || /* @__PURE__ */ new Date();
|
|
958
961
|
const next = this._next(prev);
|
|
959
962
|
if (next) {
|
|
960
|
-
if (prev instanceof CronDate) {
|
|
963
|
+
if (prev instanceof CronDate || prev instanceof Date) {
|
|
961
964
|
return next.getTime() - prev.getTime();
|
|
962
965
|
} else {
|
|
963
966
|
return next.getTime() - new CronDate(prev).getTime();
|
|
@@ -1062,6 +1065,12 @@ var Cron = class {
|
|
|
1062
1065
|
async trigger() {
|
|
1063
1066
|
await this._trigger();
|
|
1064
1067
|
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Returns number of runs left, undefined = unlimited
|
|
1070
|
+
*/
|
|
1071
|
+
runsLeft() {
|
|
1072
|
+
return this._states.maxRuns;
|
|
1073
|
+
}
|
|
1065
1074
|
/**
|
|
1066
1075
|
* Called when it's time to trigger.
|
|
1067
1076
|
* Checks if all conditions are currently met,
|
|
@@ -1122,14 +1131,14 @@ var Cron = class {
|
|
|
1122
1131
|
let newPrev = prev;
|
|
1123
1132
|
if (this.options.startAt.getTime() <= now.getTime()) {
|
|
1124
1133
|
newPrev = this.options.startAt;
|
|
1125
|
-
let prevTimePlusInterval =
|
|
1134
|
+
let prevTimePlusInterval = newPrev.getTime() + this.options.interval * 1e3;
|
|
1126
1135
|
while (prevTimePlusInterval <= now.getTime()) {
|
|
1127
|
-
newPrev = new CronDate(
|
|
1136
|
+
newPrev = new CronDate(newPrev, this.options.timezone || this.options.utcOffset).increment(
|
|
1128
1137
|
this._states.pattern,
|
|
1129
1138
|
this.options,
|
|
1130
1139
|
true
|
|
1131
1140
|
);
|
|
1132
|
-
prevTimePlusInterval =
|
|
1141
|
+
prevTimePlusInterval = newPrev.getTime() + this.options.interval * 1e3;
|
|
1133
1142
|
}
|
|
1134
1143
|
hasPreviousRun = true;
|
|
1135
1144
|
}
|
package/dist/croner.umd.js
CHANGED
|
@@ -145,7 +145,7 @@ var base64 = (() => {
|
|
|
145
145
|
* @private
|
|
146
146
|
*/
|
|
147
147
|
parse() {
|
|
148
|
-
if (!(typeof this.pattern === "string")) {
|
|
148
|
+
if (!(typeof this.pattern === "string" || this.pattern instanceof String)) {
|
|
149
149
|
throw new TypeError("CronPattern: Pattern has to be of type string.");
|
|
150
150
|
}
|
|
151
151
|
if (this.pattern.indexOf("@") >= 0) this.pattern = this.handleNicknames(this.pattern).trim();
|
|
@@ -371,6 +371,9 @@ var base64 = (() => {
|
|
|
371
371
|
if (split.length !== 2) {
|
|
372
372
|
throw new TypeError("CronPattern: Syntax error, illegal stepping: '" + conf + "'");
|
|
373
373
|
}
|
|
374
|
+
if (split[0] === "") {
|
|
375
|
+
split[0] = "*";
|
|
376
|
+
}
|
|
374
377
|
let start = 0;
|
|
375
378
|
if (split[0] !== "*") {
|
|
376
379
|
start = parseInt(split[0], 10) + valueIndexOffset;
|
|
@@ -439,13 +442,13 @@ var base64 = (() => {
|
|
|
439
442
|
setNthWeekdayOfMonth(index, nthWeekday) {
|
|
440
443
|
if (typeof nthWeekday !== "number" && nthWeekday === "L") {
|
|
441
444
|
this["dayOfWeek"][index] = this["dayOfWeek"][index] | LAST_OCCURRENCE;
|
|
442
|
-
} else if (
|
|
443
|
-
this["dayOfWeek"][index] = this["dayOfWeek"][index] | OCCURRENCE_BITMASKS[nthWeekday - 1];
|
|
444
|
-
} else if (typeof nthWeekday === "number" && nthWeekday === ANY_OCCURRENCE) {
|
|
445
|
+
} else if (nthWeekday === ANY_OCCURRENCE) {
|
|
445
446
|
this["dayOfWeek"][index] = ANY_OCCURRENCE;
|
|
447
|
+
} else if (nthWeekday < 6 && nthWeekday > 0) {
|
|
448
|
+
this["dayOfWeek"][index] = this["dayOfWeek"][index] | OCCURRENCE_BITMASKS[nthWeekday - 1];
|
|
446
449
|
} else {
|
|
447
450
|
throw new TypeError(
|
|
448
|
-
`CronPattern: nth weekday
|
|
451
|
+
`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${nthWeekday}, Type: ${typeof nthWeekday}`
|
|
449
452
|
);
|
|
450
453
|
}
|
|
451
454
|
}
|
|
@@ -625,7 +628,7 @@ var base64 = (() => {
|
|
|
625
628
|
*/
|
|
626
629
|
fromString(str) {
|
|
627
630
|
if (typeof this.tz === "number") {
|
|
628
|
-
const inDate = minitz.fromTZISO(str
|
|
631
|
+
const inDate = minitz.fromTZISO(str);
|
|
629
632
|
this.ms = inDate.getUTCMilliseconds();
|
|
630
633
|
this.second = inDate.getUTCSeconds();
|
|
631
634
|
this.minute = inDate.getUTCMinutes();
|
|
@@ -634,8 +637,8 @@ var base64 = (() => {
|
|
|
634
637
|
this.month = inDate.getUTCMonth();
|
|
635
638
|
this.year = inDate.getUTCFullYear();
|
|
636
639
|
this.apply();
|
|
637
|
-
} else
|
|
638
|
-
return this.fromDate(minitz.fromTZISO(str, this.tz
|
|
640
|
+
} else {
|
|
641
|
+
return this.fromDate(minitz.fromTZISO(str, this.tz));
|
|
639
642
|
}
|
|
640
643
|
}
|
|
641
644
|
/**
|
|
@@ -987,7 +990,7 @@ var base64 = (() => {
|
|
|
987
990
|
prev = prev || /* @__PURE__ */ new Date();
|
|
988
991
|
const next = this._next(prev);
|
|
989
992
|
if (next) {
|
|
990
|
-
if (prev instanceof CronDate) {
|
|
993
|
+
if (prev instanceof CronDate || prev instanceof Date) {
|
|
991
994
|
return next.getTime() - prev.getTime();
|
|
992
995
|
} else {
|
|
993
996
|
return next.getTime() - new CronDate(prev).getTime();
|
|
@@ -1092,6 +1095,12 @@ var base64 = (() => {
|
|
|
1092
1095
|
async trigger() {
|
|
1093
1096
|
await this._trigger();
|
|
1094
1097
|
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Returns number of runs left, undefined = unlimited
|
|
1100
|
+
*/
|
|
1101
|
+
runsLeft() {
|
|
1102
|
+
return this._states.maxRuns;
|
|
1103
|
+
}
|
|
1095
1104
|
/**
|
|
1096
1105
|
* Called when it's time to trigger.
|
|
1097
1106
|
* Checks if all conditions are currently met,
|
|
@@ -1152,14 +1161,14 @@ var base64 = (() => {
|
|
|
1152
1161
|
let newPrev = prev;
|
|
1153
1162
|
if (this.options.startAt.getTime() <= now.getTime()) {
|
|
1154
1163
|
newPrev = this.options.startAt;
|
|
1155
|
-
let prevTimePlusInterval =
|
|
1164
|
+
let prevTimePlusInterval = newPrev.getTime() + this.options.interval * 1e3;
|
|
1156
1165
|
while (prevTimePlusInterval <= now.getTime()) {
|
|
1157
|
-
newPrev = new CronDate(
|
|
1166
|
+
newPrev = new CronDate(newPrev, this.options.timezone || this.options.utcOffset).increment(
|
|
1158
1167
|
this._states.pattern,
|
|
1159
1168
|
this.options,
|
|
1160
1169
|
true
|
|
1161
1170
|
);
|
|
1162
|
-
prevTimePlusInterval =
|
|
1171
|
+
prevTimePlusInterval = newPrev.getTime() + this.options.interval * 1e3;
|
|
1163
1172
|
}
|
|
1164
1173
|
hasPreviousRun = true;
|
|
1165
1174
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "croner",
|
|
3
|
-
"version": "9.0.0-dev.
|
|
3
|
+
"version": "9.0.0-dev.4",
|
|
4
4
|
"description": "Trigger functions and/or evaluate cron expressions in JavaScript. No dependencies. Most features. All environments.",
|
|
5
5
|
"author": "Hexagon <github.com/hexagon>",
|
|
6
6
|
"homepage": "https://croner.56k.guru",
|