croner 4.0.82 → 4.0.86
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 +48 -42
- package/dist/croner.cjs +50 -6
- package/dist/croner.min.js +1 -1
- package/dist/croner.min.js.map +1 -1
- package/dist/croner.min.mjs +1 -1
- package/dist/croner.min.mjs.map +1 -1
- package/package.json +4 -3
- package/src/croner.js +23 -1
- package/src/date.js +17 -5
- package/src/pattern.js +10 -0
- package/types/croner.d.ts +9 -1
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
<img src="/croner.png" alt="Croner" width="150" height="150"><br>
|
|
3
|
+
Trigger functions and/or evaluate cron expressions in JavaScript. No dependencies. Most features. Node. Deno. Browser. <br><br>Try it live on <a href="https://jsfiddle.net/hexag0n/hoa8kwsb/">jsfiddle</a>.<br>
|
|
4
4
|
</p>
|
|
5
5
|
|
|
6
6
|
# Croner
|
|
7
7
|
|
|
8
8
|
 [](https://badge.fury.io/js/croner) [](https://www.codacy.com/gh/Hexagon/croner/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Hexagon/croner&utm_campaign=Badge_Grade)
|
|
9
9
|
[](https://github.com/Hexagon/croner/blob/master/LICENSE) [](https://www.npmjs.org/package/croner)
|
|
10
|
-
|
|
10
|
+

|
|
11
11
|
|
|
12
12
|
* Trigger functions in JavaScript using [Cron](https://en.wikipedia.org/wiki/Cron#CRON_expression) syntax.
|
|
13
|
-
* Pause, resume or stop execution after a task is scheduled.
|
|
14
13
|
* Find first date of next month, find date of next tuesday, etc.
|
|
14
|
+
* Pause, resume or stop execution after a task is scheduled.
|
|
15
15
|
* Works in Node.js >=4.0 (both require and import).
|
|
16
16
|
* Works in Deno >=1.16.
|
|
17
17
|
* Works in browsers as standalone, UMD or ES-module.
|
|
@@ -26,9 +26,9 @@ const job = Cron('* * * * * *', () => {
|
|
|
26
26
|
console.log('This will run every second');
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
// What
|
|
30
|
-
const
|
|
31
|
-
console.log(
|
|
29
|
+
// What dates do the next 100 sundays occur at?
|
|
30
|
+
const nextSundays = Cron('0 0 0 * * 7').enumerate(100);
|
|
31
|
+
console.log(nextSundays);
|
|
32
32
|
|
|
33
33
|
// How many days left to christmas eve?
|
|
34
34
|
const msLeft = Cron('59 59 23 24 DEC *').next() - new Date();
|
|
@@ -41,51 +41,49 @@ More [examples](#examples)...
|
|
|
41
41
|
|
|
42
42
|
Because the existing ones isn't good enough. They have serious bugs, use bloated dependencies, does not work in all environments and/or just doesn't work as expected.
|
|
43
43
|
|
|
44
|
-
Benchmark at
|
|
44
|
+
Benchmark at 2022-02-01:
|
|
45
45
|
|
|
46
46
|
```
|
|
47
47
|
> node cron-implementation-test.js
|
|
48
48
|
|
|
49
49
|
Test: When is next saturday 29th of february, pattern '0 0 0 29 2 6'
|
|
50
50
|
|
|
51
|
-
node-schedule: 2022-02-05 00:00:00 in
|
|
52
|
-
node-cron: ??? in
|
|
53
|
-
cron: 2022-03-05 00:00:00 in
|
|
54
|
-
croner: 2048-02-29 00:00:00 in
|
|
55
|
-
|
|
56
|
-
> node cron-implementation-test.js
|
|
51
|
+
node-schedule: 2022-02-05 00:00:00 in 55.13ms
|
|
52
|
+
node-cron: ??? in 14.587ms
|
|
53
|
+
cron: 2022-03-05 00:00:00 in 21.07ms
|
|
54
|
+
croner: 2048-02-29 00:00:00 in 10.508ms
|
|
55
|
+
```
|
|
57
56
|
|
|
57
|
+
<details>
|
|
58
|
+
<summary>More test results</summary>
|
|
59
|
+
|
|
60
|
+
```
|
|
58
61
|
Test: When is next 15th of february, pattern '0 0 0 15 2 *'
|
|
59
62
|
|
|
60
|
-
node-schedule: 2022-02-15 00:00:00 in
|
|
61
|
-
node-cron: ??? in
|
|
62
|
-
cron: 2022-03-15 00:00:00 in
|
|
63
|
-
croner: 2022-02-15 00:00:00 in
|
|
63
|
+
node-schedule: 2022-02-15 00:00:00 in 13.306ms
|
|
64
|
+
node-cron: ??? in 1.676ms
|
|
65
|
+
cron: 2022-03-15 00:00:00 in 6.066ms
|
|
66
|
+
croner: 2022-02-15 00:00:00 in 0.575ms
|
|
64
67
|
|
|
65
68
|
Test: When is next monday in october, pattern '0 0 0 * 10 1'
|
|
66
69
|
|
|
67
|
-
node-schedule: 2022-10-03 00:00:00 in
|
|
68
|
-
node-cron: ??? in
|
|
69
|
-
cron:
|
|
70
|
-
croner: 2022-10-03 00:00:00 in
|
|
71
|
-
|
|
72
|
-
Test: When is next monday the 1st of any month, pattern '0 0 0 1 * 1'
|
|
73
|
-
|
|
74
|
-
node-schedule: 2021-11-29 00:00:00 in 39.591ms
|
|
75
|
-
node-cron: ??? in 7.078ms
|
|
76
|
-
cron: 2021-11-29 00:00:00 in 10.107ms
|
|
77
|
-
croner: 2022-08-01 00:00:00 in 9.473ms
|
|
70
|
+
node-schedule: 2022-10-03 00:00:00 in 15.26ms
|
|
71
|
+
node-cron: ??? in 1.076ms
|
|
72
|
+
cron: 2022-11-07 00:00:00 in 2.923ms
|
|
73
|
+
croner: 2022-10-03 00:00:00 in 1.774ms
|
|
78
74
|
|
|
79
75
|
Test: When is 23:00 next 31st march, pattern '0 0 23 31 3 *'
|
|
80
76
|
|
|
81
|
-
node-schedule: 2022-03-31 23:00:00 in
|
|
82
|
-
node-cron: ??? in
|
|
77
|
+
node-schedule: 2022-03-31 23:00:00 in 18.894ms
|
|
78
|
+
node-cron: ??? in 3.017ms
|
|
83
79
|
Month '3' is limited to '30' days.
|
|
84
|
-
cron: 2022-04-01 23:00:00 in
|
|
85
|
-
croner: 2022-03-31 23:00:00 in
|
|
86
|
-
|
|
80
|
+
cron: 2022-04-01 23:00:00 in 4.508ms
|
|
81
|
+
croner: 2022-03-31 23:00:00 in 1.381ms
|
|
87
82
|
```
|
|
88
|
-
|
|
83
|
+
|
|
84
|
+
</details>
|
|
85
|
+
|
|
86
|
+
https://gist.github.com/Hexagon/703f85f2dd86443cc17eef8f5cc6cb70
|
|
89
87
|
|
|
90
88
|
## Installation
|
|
91
89
|
|
|
@@ -111,7 +109,7 @@ TypeScript
|
|
|
111
109
|
import Cron from "croner";
|
|
112
110
|
|
|
113
111
|
const scheduler : Cron = new Cron("* * * * * *", () => {
|
|
114
|
-
|
|
112
|
+
console.log("This will run every second.");
|
|
115
113
|
});
|
|
116
114
|
```
|
|
117
115
|
|
|
@@ -123,7 +121,7 @@ JavaScript
|
|
|
123
121
|
import Cron from "https://cdn.jsdelivr.net/gh/hexagon/croner@4/src/croner.js";
|
|
124
122
|
|
|
125
123
|
Cron("* * * * * *", () => {
|
|
126
|
-
|
|
124
|
+
console.log("This will run every second.");
|
|
127
125
|
});
|
|
128
126
|
```
|
|
129
127
|
|
|
@@ -133,7 +131,7 @@ TypeScript
|
|
|
133
131
|
import { Cron } from "https://cdn.jsdelivr.net/gh/hexagon/croner@4/src/croner.js";
|
|
134
132
|
|
|
135
133
|
const _scheduler : Cron = new Cron("* * * * * *", () => {
|
|
136
|
-
|
|
134
|
+
console.log("This will run every second.");
|
|
137
135
|
});
|
|
138
136
|
```
|
|
139
137
|
|
|
@@ -184,6 +182,7 @@ job.schedule((/* optional */ job, /* optional */ context) => {});
|
|
|
184
182
|
|
|
185
183
|
// States
|
|
186
184
|
const nextRun = job.next( /*optional*/ previousRun ); // Get a Date object representing next run
|
|
185
|
+
const nextRuns = job.enumerate(10, /*optional*/ startFrom ); // Get a array of Dates, containing next 10 runs according to pattern
|
|
187
186
|
const prevRun = job.previous( );
|
|
188
187
|
const msToNext = job.msToNext( /*optional*/ previousRun ); // Milliseconds left to next execution
|
|
189
188
|
const isRunning = job.running();
|
|
@@ -207,7 +206,14 @@ job.stop();
|
|
|
207
206
|
| paused | false | Boolean | If the job should be paused from start. |
|
|
208
207
|
| context | undefined | Any | Passed as the second parameter to triggered function |
|
|
209
208
|
|
|
210
|
-
####
|
|
209
|
+
#### Expressions
|
|
210
|
+
|
|
211
|
+
The expressions of Croner are very similar to the ones of Vixie Cron, with a few additions and changes listed below.
|
|
212
|
+
|
|
213
|
+
* In croner, a combination of day-of-week and day-of-month will only trigger when both conditions match. An example: ```0 20 1 * MON``` will only trigger when monday occur the first day of any month. In Vixie Cron, it would trigger every monday AND the first day of every month.
|
|
214
|
+
|
|
215
|
+
* Croner expressions support the following additional modifiers
|
|
216
|
+
- *`?`*: A question mark is substituted with croner initialization time, as an example - `? ? * * * *` would be substituted with `25 8 * * * *` if time is `<any hour>:08:25` at the time of `new Cron('? ? * * * *', <...>)`. The question mark can be used in any field.
|
|
211
217
|
|
|
212
218
|
```javascript
|
|
213
219
|
// ┌──────────────── (optional) second (0 - 59)
|
|
@@ -237,10 +243,10 @@ job.stop();
|
|
|
237
243
|
#### Expressions
|
|
238
244
|
```javascript
|
|
239
245
|
// Run a function according to pattern
|
|
240
|
-
Cron('15-45/10 */5 1,2,3
|
|
246
|
+
Cron('15-45/10 */5 1,2,3 ? JAN-MAR SAT', function () {
|
|
241
247
|
console.log('This will run every tenth second between second 15-45');
|
|
242
|
-
console.log('every fifth minute of hour 1,2 and 3');
|
|
243
|
-
console.log('every saturday in January to March.');
|
|
248
|
+
console.log('every fifth minute of hour 1,2 and 3 when day of month');
|
|
249
|
+
console.log('is the same as when Cron started, every saturday in January to March.');
|
|
244
250
|
});
|
|
245
251
|
```
|
|
246
252
|
|
package/dist/croner.cjs
CHANGED
|
@@ -168,19 +168,19 @@
|
|
|
168
168
|
|
|
169
169
|
},
|
|
170
170
|
|
|
171
|
-
resetPrevious = () => {
|
|
171
|
+
resetPrevious = (offset) => {
|
|
172
172
|
// Now when we have gone to next minute, we have to set seconds to the first match
|
|
173
173
|
// Now we are at 00:01:05 following the same example.
|
|
174
174
|
//
|
|
175
175
|
// This goes all the way back to seconds, hence the reverse loop.
|
|
176
|
-
while(doing >= 0) {
|
|
176
|
+
while(doing + offset >= 0) {
|
|
177
177
|
|
|
178
178
|
// Ok, reset current member(e.g. seconds) to first match in pattern, using
|
|
179
179
|
// the same method as aerlier
|
|
180
180
|
//
|
|
181
181
|
// Note the fourth parameter, stating that we should start matching the pattern
|
|
182
182
|
// from zero, instead of current time.
|
|
183
|
-
findNext(toDo[doing][0], pattern, toDo[doing][2], 0);
|
|
183
|
+
findNext(toDo[doing + offset][0], pattern, toDo[doing + offset][2], 0);
|
|
184
184
|
|
|
185
185
|
// Go back up, days -> hours -> minutes -> seconds
|
|
186
186
|
doing--;
|
|
@@ -211,12 +211,24 @@
|
|
|
211
211
|
// If time is 00:00:01 and pattern says *:*:05, seconds will
|
|
212
212
|
// be set to 5
|
|
213
213
|
|
|
214
|
-
//
|
|
214
|
+
// Store current value at current level
|
|
215
|
+
let currentValue = this[toDo[doing][0]];
|
|
216
|
+
|
|
217
|
+
// If pattern didn't provide a match, increment next value (e.g. minues)
|
|
215
218
|
if(!findNext(toDo[doing][0], pattern, toDo[doing][2])) {
|
|
216
219
|
this[toDo[doing][1]]++;
|
|
217
|
-
|
|
220
|
+
|
|
221
|
+
// Reset current level and previous levels
|
|
222
|
+
resetPrevious(0);
|
|
223
|
+
|
|
224
|
+
// If pattern provided a match, but changed current value ...
|
|
225
|
+
} else if (currentValue !== this[toDo[doing][0]]) {
|
|
226
|
+
// Reset previous levels
|
|
227
|
+
resetPrevious(-1);
|
|
228
|
+
|
|
218
229
|
}
|
|
219
230
|
|
|
231
|
+
|
|
220
232
|
// Bail out if an impossible pattern is used
|
|
221
233
|
if (this.years >= 4000) {
|
|
222
234
|
return null;
|
|
@@ -366,6 +378,16 @@
|
|
|
366
378
|
parts[4] = this.replaceAlphaMonths(parts[4]);
|
|
367
379
|
parts[5] = this.replaceAlphaDays(parts[5]);
|
|
368
380
|
|
|
381
|
+
// Implement '?' in the simplest possible way - replace ? with current value, before further processing
|
|
382
|
+
let initDate = new Date();
|
|
383
|
+
|
|
384
|
+
parts[0] = parts[0].replace("?", initDate.getSeconds());
|
|
385
|
+
parts[1] = parts[1].replace("?", initDate.getMinutes());
|
|
386
|
+
parts[2] = parts[2].replace("?", initDate.getHours());
|
|
387
|
+
parts[3] = parts[3].replace("?", initDate.getDate());
|
|
388
|
+
parts[4] = parts[4].replace("?", initDate.getMonth()+1);
|
|
389
|
+
parts[5] = parts[5].replace("?", initDate.getDay());
|
|
390
|
+
|
|
369
391
|
// Check part content
|
|
370
392
|
this.throwAtIllegalCharacters(parts);
|
|
371
393
|
|
|
@@ -745,7 +767,7 @@
|
|
|
745
767
|
/**
|
|
746
768
|
* Find next runtime, based on supplied date. Strips milliseconds.
|
|
747
769
|
*
|
|
748
|
-
* @param {Date} [prev] -
|
|
770
|
+
* @param {Date} [prev] - Date to start from
|
|
749
771
|
* @returns {Date | null} - Next run time
|
|
750
772
|
*/
|
|
751
773
|
Cron.prototype.next = function (prev) {
|
|
@@ -754,6 +776,28 @@
|
|
|
754
776
|
return next ? next.getDate() : null;
|
|
755
777
|
};
|
|
756
778
|
|
|
779
|
+
/**
|
|
780
|
+
* Find next n runs, based on supplied date. Strips milliseconds.
|
|
781
|
+
*
|
|
782
|
+
* @param {number} n - Number of runs to enumerate
|
|
783
|
+
* @param {Date} [prev] - Date to start from
|
|
784
|
+
* @returns {Date[]} - Next n run times
|
|
785
|
+
*/
|
|
786
|
+
Cron.prototype.enumerate = function (n, previous) {
|
|
787
|
+
let enumeration = [];
|
|
788
|
+
|
|
789
|
+
while(n--) {
|
|
790
|
+
previous = this.next(previous);
|
|
791
|
+
if (previous !== null) {
|
|
792
|
+
enumeration.push(previous);
|
|
793
|
+
} else {
|
|
794
|
+
break;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
return enumeration;
|
|
799
|
+
};
|
|
800
|
+
|
|
757
801
|
/**
|
|
758
802
|
* Is running?
|
|
759
803
|
* @public
|
package/dist/croner.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,global.Cron=factory())})(this,function(){"use strict";function convertTZ(date,tzString){return new Date(date.toLocaleString("en-US",{timeZone:tzString}))}function CronDate(date,timezone){this.timezone=timezone;if(date&&date instanceof Date){this.fromDate(date)}else if(date===void 0){this.fromDate(new Date)}else if(date&&typeof date==="string"){this.fromString(date)}else if(date instanceof CronDate){this.fromCronDate(date)}else{throw new TypeError("CronDate: Invalid type ("+typeof date+") passed as parameter to CronDate constructor")}}CronDate.prototype.fromDate=function(date,fromLocal){if(this.timezone&&!fromLocal){date=convertTZ(date,this.timezone)}this.milliseconds=date.getMilliseconds();this.seconds=date.getSeconds();this.minutes=date.getMinutes();this.hours=date.getHours();this.days=date.getDate();this.months=date.getMonth();this.years=date.getFullYear()};CronDate.prototype.fromCronDate=function(date){this.timezone=date.timezone;this.milliseconds=date.milliseconds;this.seconds=date.seconds;this.minutes=date.minutes;this.hours=date.hours;this.days=date.days;this.months=date.months;this.years=date.years};CronDate.prototype.apply=function(){const newDate=new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds);this.milliseconds=newDate.getMilliseconds();this.seconds=newDate.getSeconds();this.minutes=newDate.getMinutes();this.hours=newDate.getHours();this.days=newDate.getDate();this.months=newDate.getMonth();this.years=newDate.getFullYear()};CronDate.prototype.fromString=function(str){const parsedDate=this.parseISOLocal(str);if(isNaN(parsedDate)){throw new TypeError("CronDate: Provided string value for CronDate could not be parsed as date.")}this.fromDate(parsedDate,true)};CronDate.prototype.increment=function(pattern,rerun){if(!rerun){this.seconds+=1}this.milliseconds=0;const origTime=this.getTime(),findNext=(target,pattern,offset,override)=>{const startPos=override===void 0?this[target]+offset:0+offset;for(let i=startPos;i<pattern[target].length;i++){if(pattern[target][i]){this[target]=i-offset;return true}}return false},resetPrevious=()=>{while(doing>=0){findNext(toDo[doing][0],pattern,toDo[doing][2],0);doing--}};const toDo=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]];let doing=0;while(doing<5){if(!findNext(toDo[doing][0],pattern,toDo[doing][2])){this[toDo[doing][1]]++;resetPrevious()}if(this.years>=4e3){return null}doing++}while(!pattern.daysOfWeek[this.getDate(true).getDay()]){this.days+=1;doing=2;resetPrevious()}if(origTime!=this.getTime()){this.apply();return this.increment(pattern,true)}else{return this}};CronDate.prototype.getDate=function(internal){const targetDate=new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds);if(internal||!this.timezone){return targetDate}else{const offset=convertTZ(targetDate,this.timezone).getTime()-targetDate.getTime();return new Date(targetDate.getTime()-offset)}};CronDate.prototype.getTime=function(internal){return this.getDate(internal).getTime()};CronDate.prototype.parseISOLocal=function(dateTimeString){const dateTimeStringSplit=dateTimeString.split(/\D/);if(dateTimeStringSplit.length<6){return NaN}const year=parseInt(dateTimeStringSplit[0],10),month=parseInt(dateTimeStringSplit[1],10),day=parseInt(dateTimeStringSplit[2],10),hour=parseInt(dateTimeStringSplit[3],10),minute=parseInt(dateTimeStringSplit[4],10),second=parseInt(dateTimeStringSplit[5],10);if(isNaN(year)||isNaN(month)||isNaN(day)||isNaN(hour)||isNaN(minute)||isNaN(second)){return NaN}else{return new Date(year,month-1,day,hour,minute,second)}};function CronPattern(pattern){this.pattern=pattern;this.seconds=Array(60).fill(0);this.minutes=Array(60).fill(0);this.hours=Array(24).fill(0);this.days=Array(31).fill(0);this.months=Array(12).fill(0);this.daysOfWeek=Array(8).fill(0);this.parse()}CronPattern.prototype.parse=function(){if(!(typeof this.pattern==="string"||this.pattern.constructor===String)){throw new TypeError("CronPattern: Pattern has to be of type string.")}const parts=this.pattern.trim().replace(/\s+/g," ").split(" ");if(parts.length<5||parts.length>6){throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exacly five or six space separated parts required.")}if(parts.length===5){parts.unshift("0")}parts[4]=this.replaceAlphaMonths(parts[4]);parts[5]=this.replaceAlphaDays(parts[5]);this.throwAtIllegalCharacters(parts);this.partToArray("seconds",parts[0],0);this.partToArray("minutes",parts[1],0);this.partToArray("hours",parts[2],0);this.partToArray("days",parts[3],-1);this.partToArray("months",parts[4],-1);this.partToArray("daysOfWeek",parts[5],0);if(this.daysOfWeek[7]){this.daysOfWeek[0]=1}};CronPattern.prototype.partToArray=function(type,conf,valueIndexOffset,recursed){const arr=this[type];if(conf==="*"){for(let i=0;i<arr.length;i++){arr[i]=1}return}const split=conf.split(",");if(split.length>1){for(let i=0;i<split.length;i++){this.partToArray(type,split[i],valueIndexOffset,true)}}else if(conf.indexOf("-")!==-1&&conf.indexOf("/")!==-1){if(recursed)throw new Error("CronPattern: Range with stepping cannot coexist with ,");this.handleRangeWithStepping(conf,type,valueIndexOffset)}else if(conf.indexOf("-")!==-1){if(recursed)throw new Error("CronPattern: Range with stepping cannot coexist with ,");this.handleRange(conf,type,valueIndexOffset)}else if(conf.indexOf("/")!==-1){if(recursed)throw new Error("CronPattern: Range with stepping cannot coexist with ,");this.handleStepping(conf,type,valueIndexOffset)}else{this.handleNumber(conf,type,valueIndexOffset)}};CronPattern.prototype.throwAtIllegalCharacters=function(parts){const reValidCron=/[^/*0-9,-]+/;for(let i=0;i<parts.length;i++){if(reValidCron.test(parts[i])){throw new TypeError("CronPattern: configuration entry "+i+" ("+parts[i]+") contains illegal characters.")}}};CronPattern.prototype.handleNumber=function(conf,type,valueIndexOffset){const i=parseInt(conf,10)+valueIndexOffset;if(i<0||i>=this[type].length){throw new TypeError("CronPattern: "+type+" value out of range: '"+conf+"'")}this[type][i]=1};CronPattern.prototype.handleRangeWithStepping=function(conf,type,valueIndexOffset){const matches=conf.match(/^(\d+)-(\d+)\/(\d+)$/);if(matches===null)throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '"+conf+"'");let[,lower,upper,steps]=matches;lower=parseInt(lower,10)+valueIndexOffset;upper=parseInt(upper,10)+valueIndexOffset;steps=parseInt(steps,10)+valueIndexOffset;if(isNaN(lower))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(upper))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(isNaN(steps))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(steps===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(steps>this[type].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[type].length+")");if(lower<0||upper>=this[type].length)throw new TypeError("CronPattern: Value out of range: '"+conf+"'");if(lower>upper)throw new TypeError("CronPattern: From value is larger than to value: '"+conf+"'");for(let i=lower;i<=upper;i+=steps){this[type][i+valueIndexOffset]=1}};CronPattern.prototype.handleRange=function(conf,type,valueIndexOffset){const split=conf.split("-");if(split.length!==2){throw new TypeError("CronPattern: Syntax error, illegal range: '"+conf+"'")}const lower=parseInt(split[0],10)+valueIndexOffset,upper=parseInt(split[1],10)+valueIndexOffset;if(isNaN(lower)){throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)")}else if(isNaN(upper)){throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)")}if(lower<0||upper>=this[type].length){throw new TypeError("CronPattern: Value out of range: '"+conf+"'")}if(lower>upper){throw new TypeError("CronPattern: From value is larger than to value: '"+conf+"'")}for(let i=lower;i<=upper;i++){this[type][i+valueIndexOffset]=1}};CronPattern.prototype.handleStepping=function(conf,type,valueIndexOffset){const split=conf.split("/");if(split.length!==2){throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+conf+"'")}let start=0;if(split[0]!=="*"){start=parseInt(split[0],10)}const steps=parseInt(split[1],10);if(isNaN(steps))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(steps===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(steps>this[type].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[type].length+")");for(let i=start;i<this[type].length;i+=steps){this[type][i+valueIndexOffset]=1}};CronPattern.prototype.replaceAlphaDays=function(conf){return conf.replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")};CronPattern.prototype.replaceAlphaMonths=function(conf){return conf.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")};const maxDelay=Math.pow(2,32-1)-1;function Cron(pattern,options,func){if(!(this instanceof Cron)){return new Cron(pattern,options,func)}this.pattern=new CronPattern(pattern);if(typeof options==="function"){func=options;options=void 0}this.options=this.processOptions(options);if(func!==void 0){this.fn=func;this.schedule()}return this}Cron.prototype.processOptions=function(options){if(options===void 0){options={}}options.paused=options.paused===void 0?false:options.paused;options.maxRuns=options.maxRuns===void 0?Infinity:options.maxRuns;options.catch=options.catch===void 0?false:options.catch;options.kill=false;if(options.startAt){options.startAt=new CronDate(options.startAt,options.timezone)}if(options.stopAt){options.stopAt=new CronDate(options.stopAt,options.timezone)}return options};Cron.prototype.next=function(prev){prev=new CronDate(prev,this.options.timezone);const next=this._next(prev);return next?next.getDate():null};Cron.prototype.running=function(){const msLeft=this.msToNext(this.previousrun);const running=!this.options.paused&&this.fn!==void 0;return msLeft!==null&&running};Cron.prototype.previous=function(){return this.previousrun?this.previousrun.getDate():null};Cron.prototype._next=function(prev){if(this.options.startAt&&prev&&prev.getTime(true)<this.options.startAt.getTime(true)){prev=new CronDate(this.options.startAt,this.options.timezone)}const nextRun=new CronDate(prev,this.options.timezone).increment(this.pattern);if(nextRun===null||this.options.maxRuns<=0||this.options.kill||this.options.stopAt&&nextRun.getTime(true)>=this.options.stopAt.getTime(true)){return null}else{return nextRun}};Cron.prototype.msToNext=function(prev){prev=new CronDate(prev,this.options.timezone);const next=this._next(prev);if(next){return next.getTime(true)-prev.getTime(true)}else{return null}};Cron.prototype.stop=function(){this.options.kill=true;if(this.currentTimeout){clearTimeout(this.currentTimeout)}};Cron.prototype.pause=function(){return(this.options.paused=true)&&!this.options.kill};Cron.prototype.resume=function(){return!(this.options.paused=false)&&!this.options.kill};Cron.prototype.schedule=function(func){if(func&&this.fn){throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.")}else if(func){this.fn=func}let waitMs=this.msToNext(this.previousrun);if(waitMs===null)return this;const _maxDelay=this.maxDelay||maxDelay;if(waitMs>_maxDelay){waitMs=_maxDelay}const go=()=>{if(waitMs!==_maxDelay&&!this.options.paused){this.options.maxRuns--;if(this.options.catch){try{this.fn(this,this.options.context)}catch(_e){}}else{this.fn(this,this.options.context)}this.previousrun=new CronDate(void 0,this.options.timezone)}this.schedule()};this.currentTimeout=setTimeout(go,waitMs);return this};return Cron});
|
|
1
|
+
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,global.Cron=factory())})(this,function(){"use strict";function convertTZ(date,tzString){return new Date(date.toLocaleString("en-US",{timeZone:tzString}))}function CronDate(date,timezone){this.timezone=timezone;if(date&&date instanceof Date){this.fromDate(date)}else if(date===void 0){this.fromDate(new Date)}else if(date&&typeof date==="string"){this.fromString(date)}else if(date instanceof CronDate){this.fromCronDate(date)}else{throw new TypeError("CronDate: Invalid type ("+typeof date+") passed as parameter to CronDate constructor")}}CronDate.prototype.fromDate=function(date,fromLocal){if(this.timezone&&!fromLocal){date=convertTZ(date,this.timezone)}this.milliseconds=date.getMilliseconds();this.seconds=date.getSeconds();this.minutes=date.getMinutes();this.hours=date.getHours();this.days=date.getDate();this.months=date.getMonth();this.years=date.getFullYear()};CronDate.prototype.fromCronDate=function(date){this.timezone=date.timezone;this.milliseconds=date.milliseconds;this.seconds=date.seconds;this.minutes=date.minutes;this.hours=date.hours;this.days=date.days;this.months=date.months;this.years=date.years};CronDate.prototype.apply=function(){const newDate=new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds);this.milliseconds=newDate.getMilliseconds();this.seconds=newDate.getSeconds();this.minutes=newDate.getMinutes();this.hours=newDate.getHours();this.days=newDate.getDate();this.months=newDate.getMonth();this.years=newDate.getFullYear()};CronDate.prototype.fromString=function(str){const parsedDate=this.parseISOLocal(str);if(isNaN(parsedDate)){throw new TypeError("CronDate: Provided string value for CronDate could not be parsed as date.")}this.fromDate(parsedDate,true)};CronDate.prototype.increment=function(pattern,rerun){if(!rerun){this.seconds+=1}this.milliseconds=0;const origTime=this.getTime(),findNext=(target,pattern,offset,override)=>{const startPos=override===void 0?this[target]+offset:0+offset;for(let i=startPos;i<pattern[target].length;i++){if(pattern[target][i]){this[target]=i-offset;return true}}return false},resetPrevious=offset=>{while(doing+offset>=0){findNext(toDo[doing+offset][0],pattern,toDo[doing+offset][2],0);doing--}};const toDo=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]];let doing=0;while(doing<5){let currentValue=this[toDo[doing][0]];if(!findNext(toDo[doing][0],pattern,toDo[doing][2])){this[toDo[doing][1]]++;resetPrevious(0)}else if(currentValue!==this[toDo[doing][0]]){resetPrevious(-1)}if(this.years>=4e3){return null}doing++}while(!pattern.daysOfWeek[this.getDate(true).getDay()]){this.days+=1;doing=2;resetPrevious()}if(origTime!=this.getTime()){this.apply();return this.increment(pattern,true)}else{return this}};CronDate.prototype.getDate=function(internal){const targetDate=new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds);if(internal||!this.timezone){return targetDate}else{const offset=convertTZ(targetDate,this.timezone).getTime()-targetDate.getTime();return new Date(targetDate.getTime()-offset)}};CronDate.prototype.getTime=function(internal){return this.getDate(internal).getTime()};CronDate.prototype.parseISOLocal=function(dateTimeString){const dateTimeStringSplit=dateTimeString.split(/\D/);if(dateTimeStringSplit.length<6){return NaN}const year=parseInt(dateTimeStringSplit[0],10),month=parseInt(dateTimeStringSplit[1],10),day=parseInt(dateTimeStringSplit[2],10),hour=parseInt(dateTimeStringSplit[3],10),minute=parseInt(dateTimeStringSplit[4],10),second=parseInt(dateTimeStringSplit[5],10);if(isNaN(year)||isNaN(month)||isNaN(day)||isNaN(hour)||isNaN(minute)||isNaN(second)){return NaN}else{return new Date(year,month-1,day,hour,minute,second)}};function CronPattern(pattern){this.pattern=pattern;this.seconds=Array(60).fill(0);this.minutes=Array(60).fill(0);this.hours=Array(24).fill(0);this.days=Array(31).fill(0);this.months=Array(12).fill(0);this.daysOfWeek=Array(8).fill(0);this.parse()}CronPattern.prototype.parse=function(){if(!(typeof this.pattern==="string"||this.pattern.constructor===String)){throw new TypeError("CronPattern: Pattern has to be of type string.")}const parts=this.pattern.trim().replace(/\s+/g," ").split(" ");if(parts.length<5||parts.length>6){throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exacly five or six space separated parts required.")}if(parts.length===5){parts.unshift("0")}parts[4]=this.replaceAlphaMonths(parts[4]);parts[5]=this.replaceAlphaDays(parts[5]);let initDate=new Date;parts[0]=parts[0].replace("?",initDate.getSeconds());parts[1]=parts[1].replace("?",initDate.getMinutes());parts[2]=parts[2].replace("?",initDate.getHours());parts[3]=parts[3].replace("?",initDate.getDate());parts[4]=parts[4].replace("?",initDate.getMonth()+1);parts[5]=parts[5].replace("?",initDate.getDay());this.throwAtIllegalCharacters(parts);this.partToArray("seconds",parts[0],0);this.partToArray("minutes",parts[1],0);this.partToArray("hours",parts[2],0);this.partToArray("days",parts[3],-1);this.partToArray("months",parts[4],-1);this.partToArray("daysOfWeek",parts[5],0);if(this.daysOfWeek[7]){this.daysOfWeek[0]=1}};CronPattern.prototype.partToArray=function(type,conf,valueIndexOffset,recursed){const arr=this[type];if(conf==="*"){for(let i=0;i<arr.length;i++){arr[i]=1}return}const split=conf.split(",");if(split.length>1){for(let i=0;i<split.length;i++){this.partToArray(type,split[i],valueIndexOffset,true)}}else if(conf.indexOf("-")!==-1&&conf.indexOf("/")!==-1){if(recursed)throw new Error("CronPattern: Range with stepping cannot coexist with ,");this.handleRangeWithStepping(conf,type,valueIndexOffset)}else if(conf.indexOf("-")!==-1){if(recursed)throw new Error("CronPattern: Range with stepping cannot coexist with ,");this.handleRange(conf,type,valueIndexOffset)}else if(conf.indexOf("/")!==-1){if(recursed)throw new Error("CronPattern: Range with stepping cannot coexist with ,");this.handleStepping(conf,type,valueIndexOffset)}else{this.handleNumber(conf,type,valueIndexOffset)}};CronPattern.prototype.throwAtIllegalCharacters=function(parts){const reValidCron=/[^/*0-9,-]+/;for(let i=0;i<parts.length;i++){if(reValidCron.test(parts[i])){throw new TypeError("CronPattern: configuration entry "+i+" ("+parts[i]+") contains illegal characters.")}}};CronPattern.prototype.handleNumber=function(conf,type,valueIndexOffset){const i=parseInt(conf,10)+valueIndexOffset;if(i<0||i>=this[type].length){throw new TypeError("CronPattern: "+type+" value out of range: '"+conf+"'")}this[type][i]=1};CronPattern.prototype.handleRangeWithStepping=function(conf,type,valueIndexOffset){const matches=conf.match(/^(\d+)-(\d+)\/(\d+)$/);if(matches===null)throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '"+conf+"'");let[,lower,upper,steps]=matches;lower=parseInt(lower,10)+valueIndexOffset;upper=parseInt(upper,10)+valueIndexOffset;steps=parseInt(steps,10)+valueIndexOffset;if(isNaN(lower))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(upper))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(isNaN(steps))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(steps===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(steps>this[type].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[type].length+")");if(lower<0||upper>=this[type].length)throw new TypeError("CronPattern: Value out of range: '"+conf+"'");if(lower>upper)throw new TypeError("CronPattern: From value is larger than to value: '"+conf+"'");for(let i=lower;i<=upper;i+=steps){this[type][i+valueIndexOffset]=1}};CronPattern.prototype.handleRange=function(conf,type,valueIndexOffset){const split=conf.split("-");if(split.length!==2){throw new TypeError("CronPattern: Syntax error, illegal range: '"+conf+"'")}const lower=parseInt(split[0],10)+valueIndexOffset,upper=parseInt(split[1],10)+valueIndexOffset;if(isNaN(lower)){throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)")}else if(isNaN(upper)){throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)")}if(lower<0||upper>=this[type].length){throw new TypeError("CronPattern: Value out of range: '"+conf+"'")}if(lower>upper){throw new TypeError("CronPattern: From value is larger than to value: '"+conf+"'")}for(let i=lower;i<=upper;i++){this[type][i+valueIndexOffset]=1}};CronPattern.prototype.handleStepping=function(conf,type,valueIndexOffset){const split=conf.split("/");if(split.length!==2){throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+conf+"'")}let start=0;if(split[0]!=="*"){start=parseInt(split[0],10)}const steps=parseInt(split[1],10);if(isNaN(steps))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(steps===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(steps>this[type].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[type].length+")");for(let i=start;i<this[type].length;i+=steps){this[type][i+valueIndexOffset]=1}};CronPattern.prototype.replaceAlphaDays=function(conf){return conf.replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")};CronPattern.prototype.replaceAlphaMonths=function(conf){return conf.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")};const maxDelay=Math.pow(2,32-1)-1;function Cron(pattern,options,func){if(!(this instanceof Cron)){return new Cron(pattern,options,func)}this.pattern=new CronPattern(pattern);if(typeof options==="function"){func=options;options=void 0}this.options=this.processOptions(options);if(func!==void 0){this.fn=func;this.schedule()}return this}Cron.prototype.processOptions=function(options){if(options===void 0){options={}}options.paused=options.paused===void 0?false:options.paused;options.maxRuns=options.maxRuns===void 0?Infinity:options.maxRuns;options.catch=options.catch===void 0?false:options.catch;options.kill=false;if(options.startAt){options.startAt=new CronDate(options.startAt,options.timezone)}if(options.stopAt){options.stopAt=new CronDate(options.stopAt,options.timezone)}return options};Cron.prototype.next=function(prev){prev=new CronDate(prev,this.options.timezone);const next=this._next(prev);return next?next.getDate():null};Cron.prototype.enumerate=function(n,previous){let enumeration=[];while(n--){previous=this.next(previous);if(previous!==null){enumeration.push(previous)}else{break}}return enumeration};Cron.prototype.running=function(){const msLeft=this.msToNext(this.previousrun);const running=!this.options.paused&&this.fn!==void 0;return msLeft!==null&&running};Cron.prototype.previous=function(){return this.previousrun?this.previousrun.getDate():null};Cron.prototype._next=function(prev){if(this.options.startAt&&prev&&prev.getTime(true)<this.options.startAt.getTime(true)){prev=new CronDate(this.options.startAt,this.options.timezone)}const nextRun=new CronDate(prev,this.options.timezone).increment(this.pattern);if(nextRun===null||this.options.maxRuns<=0||this.options.kill||this.options.stopAt&&nextRun.getTime(true)>=this.options.stopAt.getTime(true)){return null}else{return nextRun}};Cron.prototype.msToNext=function(prev){prev=new CronDate(prev,this.options.timezone);const next=this._next(prev);if(next){return next.getTime(true)-prev.getTime(true)}else{return null}};Cron.prototype.stop=function(){this.options.kill=true;if(this.currentTimeout){clearTimeout(this.currentTimeout)}};Cron.prototype.pause=function(){return(this.options.paused=true)&&!this.options.kill};Cron.prototype.resume=function(){return!(this.options.paused=false)&&!this.options.kill};Cron.prototype.schedule=function(func){if(func&&this.fn){throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.")}else if(func){this.fn=func}let waitMs=this.msToNext(this.previousrun);if(waitMs===null)return this;const _maxDelay=this.maxDelay||maxDelay;if(waitMs>_maxDelay){waitMs=_maxDelay}const go=()=>{if(waitMs!==_maxDelay&&!this.options.paused){this.options.maxRuns--;if(this.options.catch){try{this.fn(this,this.options.context)}catch(_e){}}else{this.fn(this,this.options.context)}this.previousrun=new CronDate(void 0,this.options.timezone)}this.schedule()};this.currentTimeout=setTimeout(go,waitMs);return this};return Cron});
|
package/dist/croner.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["dist/croner.cjs"],"names":["global","factory","exports","module","define","amd","globalThis","self","Cron","this","convertTZ","date","tzString","Date","toLocaleString","timeZone","CronDate","timezone","fromDate","fromString","fromCronDate","TypeError","prototype","fromLocal","milliseconds","getMilliseconds","seconds","getSeconds","minutes","getMinutes","hours","getHours","days","getDate","months","getMonth","years","getFullYear","apply","newDate","str","parsedDate","parseISOLocal","isNaN","increment","pattern","rerun","origTime","getTime","findNext","target","offset","override","startPos","let","i","length","resetPrevious","doing","toDo","daysOfWeek","getDay","internal","targetDate","dateTimeString","dateTimeStringSplit","split","NaN","year","parseInt","month","day","hour","minute","second","CronPattern","Array","fill","parse","constructor","String","parts","trim","replace","unshift","replaceAlphaMonths","replaceAlphaDays","throwAtIllegalCharacters","partToArray","type","conf","valueIndexOffset","recursed","arr","indexOf","Error","handleRangeWithStepping","handleRange","handleStepping","handleNumber","reValidCron","test","matches","match","lower","upper","steps","start","maxDelay","Math","pow","options","func","processOptions","fn","schedule","paused","maxRuns","Infinity","catch","kill","startAt","stopAt","next","prev","_next","running","msLeft","msToNext","previousrun","previous","nextRun","stop","currentTimeout","clearTimeout","pause","resume","waitMs","_maxDelay","go","context","_e","setTimeout"],"mappings":"CAAA,SAAWA,OAAQC,gBACXC,UAAY,iBAAmBC,SAAW,YAAcA,OAAOD,QAAUD,iBACzEG,SAAW,YAAcA,OAAOC,IAAMD,OAAOH,UACnDD,cAAgBM,aAAe,YAAcA,WAAaN,QAAUO,KAAMP,OAAOQ,KAAOP,YAH1F,CAIGQ,KAAM,wBAkBR,SAASC,UAAUC,KAAMC,UACxB,OAAO,I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QvG,KAAKyG,GAAI,CACpB,MAAM,IAAInB,MAAM,0FAGV,GAAIiB,KAAM,CAChBvG,KAAKyG,GAAKF,KAIX1D,IAAImF,OAAShI,KAAKuH,SAASvH,KAAKwH,aAChC,GAAMQ,SAAW,KAAQ,OAAOhI,KAIhC,MAAMiI,UAAYjI,KAAKmG,UAAYA,SAGnC,GAAI6B,OAASC,UAAY,CACxBD,OAASC,UAIV,MAAMC,GAAK,KAEV,GAAIF,SAAWC,YAAcjI,KAAKsG,QAAQK,OAAS,CAElD3G,KAAKsG,QAAQM,UAGb,GAAI5G,KAAKsG,QAAQQ,MAAO,CACvB,IACC9G,KAAKyG,GAAGzG,KAAMA,KAAKsG,QAAQ6B,SAC1B,MAAOC,UAGH,CACNpI,KAAKyG,GAAGzG,KAAMA,KAAKsG,QAAQ6B,SAG5BnI,KAAKwH,YAAc,IAAIjH,cAAc,EAAGP,KAAKsG,QAAQ9F,UAKtDR,KAAK0G,YAIN1G,KAAK4H,eAAiBS,WAAWH,GAAIF,QAErC,OAAOhI,MAIR,OAAOD"}
|
|
1
|
+
{"version":3,"sources":["dist/croner.cjs"],"names":["global","factory","exports","module","define","amd","globalThis","self","Cron","this","convertTZ","date","tzString","Date","toLocaleString","timeZone","CronDate","timezone","fromDate","fromString","fromCronDate","TypeError","prototype","fromLocal","milliseconds","getMilliseconds","seconds","getSeconds","minutes","getMinutes","hours","getHours","days","getDate","months","getMonth","years","getFullYear","apply","newDate","str","parsedDate","parseISOLocal","isNaN","increment","pattern","rerun","origTime","getTime","findNext","target","offset","override","startPos","let","i","length","resetPrevious","doing","toDo","currentValue","daysOfWeek","getDay","internal","targetDate","dateTimeString","dateTimeStringSplit","split","NaN","year","parseInt","month","day","hour","minute","second","CronPattern","Array","fill","parse","constructor","String","parts","trim","replace","unshift","replaceAlphaMonths","replaceAlphaDays","initDate","throwAtIllegalCharacters","partToArray","type","conf","valueIndexOffset","recursed","arr","indexOf","Error","handleRangeWithStepping","handleRange","handleStepping","handleNumber","reValidCron","test","matches","match","lower","upper","steps","start","maxDelay","Math","pow","options","func","processOptions","fn","schedule","paused","maxRuns","Infinity","catch","kill","startAt","stopAt","next","prev","_next","enumerate","n","previous","enumeration","push","running","msLeft","msToNext","previousrun","nextRun","stop","currentTimeout","clearTimeout","pause","resume","waitMs","_maxDelay","go","context","_e","setTimeout"],"mappings":"CAAA,SAAWA,OAAQC,gBACXC,UAAY,iBAAmBC,SAAW,YAAcA,OAAOD,QAAUD,iBACzEG,SAAW,YAAcA,OAAOC,IAAMD,OAAOH,UACnDD,cAAgBM,aAAe,YAAcA,WAAaN,QAAUO,KAAMP,OAAOQ,KAAOP,YAH1F,CAIGQ,KAAM,wBAkBR,SAASC,UAAUC,KAAMC,UACxB,OAAO,IAAIC,KAAKF,KAAKG,eAAe,QAAS,CAACC,SAAUH,YAUzD,SAASI,SAAUL,KAAMM,UAExBR,KAAKQ,SAAWA,SAEhB,GAAIN,MAAQA,gBAAgBE,KAAM,CACjCJ,KAAKS,SAASP,WACR,GAAIA,YAAc,EAAG,CAC3BF,KAAKS,SAAS,IAAIL,WACZ,GAAIF,aAAeA,OAAS,SAAU,CAC5CF,KAAKU,WAAWR,WACV,GAAIA,gBAAgBK,SAAU,CACpCP,KAAKW,aAAaT,UACZ,CACN,MAAM,IAAIU,UAAU,kCAAoCV,KAAO,kDAWjEK,SAASM,UAAUJ,SAAW,SAAUP,KAAMY,WAE7C,GAAId,KAAKQ,WAAaM,UAAW,CAChCZ,KAAOD,UAAUC,KAAMF,KAAKQ,UAG7BR,KAAKe,aAAeb,KAAKc,kBACzBhB,KAAKiB,QAAUf,KAAKgB,aACpBlB,KAAKmB,QAAUjB,KAAKkB,aACpBpB,KAAKqB,MAAQnB,KAAKoB,WAClBtB,KAAKuB,KAAOrB,KAAKsB,UACjBxB,KAAKyB,OAAUvB,KAAKwB,WACpB1B,KAAK2B,MAAQzB,KAAK0B,eASnBrB,SAASM,UAAUF,aAAe,SAAUT,MAC3CF,KAAKQ,SAAW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,0FAGV,GAAIiB,KAAM,CAChBzG,KAAK2G,GAAKF,KAIX5D,IAAIyF,OAAStI,KAAK8H,SAAS9H,KAAK+H,aAChC,GAAMO,SAAW,KAAQ,OAAOtI,KAIhC,MAAMuI,UAAYvI,KAAKqG,UAAYA,SAGnC,GAAIiC,OAASC,UAAY,CACxBD,OAASC,UAIV,MAAMC,GAAK,KAEV,GAAIF,SAAWC,YAAcvI,KAAKwG,QAAQK,OAAS,CAElD7G,KAAKwG,QAAQM,UAGb,GAAI9G,KAAKwG,QAAQQ,MAAO,CACvB,IACChH,KAAK2G,GAAG3G,KAAMA,KAAKwG,QAAQiC,SAC1B,MAAOC,UAGH,CACN1I,KAAK2G,GAAG3G,KAAMA,KAAKwG,QAAQiC,SAG5BzI,KAAK+H,YAAc,IAAIxH,cAAc,EAAGP,KAAKwG,QAAQhG,UAKtDR,KAAK4G,YAIN5G,KAAKkI,eAAiBS,WAAWH,GAAIF,QAErC,OAAOtI,MAIR,OAAOD"}
|
package/dist/croner.min.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function convertTZ(date,tzString){return new Date(date.toLocaleString("en-US",{timeZone:tzString}))}function CronDate(date,timezone){this.timezone=timezone;if(date&&date instanceof Date){this.fromDate(date)}else if(date===void 0){this.fromDate(new Date)}else if(date&&typeof date==="string"){this.fromString(date)}else if(date instanceof CronDate){this.fromCronDate(date)}else{throw new TypeError("CronDate: Invalid type ("+typeof date+") passed as parameter to CronDate constructor")}}CronDate.prototype.fromDate=function(date,fromLocal){if(this.timezone&&!fromLocal){date=convertTZ(date,this.timezone)}this.milliseconds=date.getMilliseconds();this.seconds=date.getSeconds();this.minutes=date.getMinutes();this.hours=date.getHours();this.days=date.getDate();this.months=date.getMonth();this.years=date.getFullYear()};CronDate.prototype.fromCronDate=function(date){this.timezone=date.timezone;this.milliseconds=date.milliseconds;this.seconds=date.seconds;this.minutes=date.minutes;this.hours=date.hours;this.days=date.days;this.months=date.months;this.years=date.years};CronDate.prototype.apply=function(){const newDate=new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds);this.milliseconds=newDate.getMilliseconds();this.seconds=newDate.getSeconds();this.minutes=newDate.getMinutes();this.hours=newDate.getHours();this.days=newDate.getDate();this.months=newDate.getMonth();this.years=newDate.getFullYear()};CronDate.prototype.fromString=function(str){const parsedDate=this.parseISOLocal(str);if(isNaN(parsedDate)){throw new TypeError("CronDate: Provided string value for CronDate could not be parsed as date.")}this.fromDate(parsedDate,true)};CronDate.prototype.increment=function(pattern,rerun){if(!rerun){this.seconds+=1}this.milliseconds=0;const origTime=this.getTime(),findNext=(target,pattern,offset,override)=>{const startPos=override===void 0?this[target]+offset:0+offset;for(let i=startPos;i<pattern[target].length;i++){if(pattern[target][i]){this[target]=i-offset;return true}}return false},resetPrevious=()=>{while(doing>=0){findNext(toDo[doing][0],pattern,toDo[doing][2],0);doing--}};const toDo=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]];let doing=0;while(doing<5){if(!findNext(toDo[doing][0],pattern,toDo[doing][2])){this[toDo[doing][1]]++;resetPrevious()}if(this.years>=4e3){return null}doing++}while(!pattern.daysOfWeek[this.getDate(true).getDay()]){this.days+=1;doing=2;resetPrevious()}if(origTime!=this.getTime()){this.apply();return this.increment(pattern,true)}else{return this}};CronDate.prototype.getDate=function(internal){const targetDate=new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds);if(internal||!this.timezone){return targetDate}else{const offset=convertTZ(targetDate,this.timezone).getTime()-targetDate.getTime();return new Date(targetDate.getTime()-offset)}};CronDate.prototype.getTime=function(internal){return this.getDate(internal).getTime()};CronDate.prototype.parseISOLocal=function(dateTimeString){const dateTimeStringSplit=dateTimeString.split(/\D/);if(dateTimeStringSplit.length<6){return NaN}const year=parseInt(dateTimeStringSplit[0],10),month=parseInt(dateTimeStringSplit[1],10),day=parseInt(dateTimeStringSplit[2],10),hour=parseInt(dateTimeStringSplit[3],10),minute=parseInt(dateTimeStringSplit[4],10),second=parseInt(dateTimeStringSplit[5],10);if(isNaN(year)||isNaN(month)||isNaN(day)||isNaN(hour)||isNaN(minute)||isNaN(second)){return NaN}else{return new Date(year,month-1,day,hour,minute,second)}};function CronPattern(pattern){this.pattern=pattern;this.seconds=Array(60).fill(0);this.minutes=Array(60).fill(0);this.hours=Array(24).fill(0);this.days=Array(31).fill(0);this.months=Array(12).fill(0);this.daysOfWeek=Array(8).fill(0);this.parse()}CronPattern.prototype.parse=function(){if(!(typeof this.pattern==="string"||this.pattern.constructor===String)){throw new TypeError("CronPattern: Pattern has to be of type string.")}const parts=this.pattern.trim().replace(/\s+/g," ").split(" ");if(parts.length<5||parts.length>6){throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exacly five or six space separated parts required.")}if(parts.length===5){parts.unshift("0")}parts[4]=this.replaceAlphaMonths(parts[4]);parts[5]=this.replaceAlphaDays(parts[5]);this.throwAtIllegalCharacters(parts);this.partToArray("seconds",parts[0],0);this.partToArray("minutes",parts[1],0);this.partToArray("hours",parts[2],0);this.partToArray("days",parts[3],-1);this.partToArray("months",parts[4],-1);this.partToArray("daysOfWeek",parts[5],0);if(this.daysOfWeek[7]){this.daysOfWeek[0]=1}};CronPattern.prototype.partToArray=function(type,conf,valueIndexOffset,recursed){const arr=this[type];if(conf==="*"){for(let i=0;i<arr.length;i++){arr[i]=1}return}const split=conf.split(",");if(split.length>1){for(let i=0;i<split.length;i++){this.partToArray(type,split[i],valueIndexOffset,true)}}else if(conf.indexOf("-")!==-1&&conf.indexOf("/")!==-1){if(recursed)throw new Error("CronPattern: Range with stepping cannot coexist with ,");this.handleRangeWithStepping(conf,type,valueIndexOffset)}else if(conf.indexOf("-")!==-1){if(recursed)throw new Error("CronPattern: Range with stepping cannot coexist with ,");this.handleRange(conf,type,valueIndexOffset)}else if(conf.indexOf("/")!==-1){if(recursed)throw new Error("CronPattern: Range with stepping cannot coexist with ,");this.handleStepping(conf,type,valueIndexOffset)}else{this.handleNumber(conf,type,valueIndexOffset)}};CronPattern.prototype.throwAtIllegalCharacters=function(parts){const reValidCron=/[^/*0-9,-]+/;for(let i=0;i<parts.length;i++){if(reValidCron.test(parts[i])){throw new TypeError("CronPattern: configuration entry "+i+" ("+parts[i]+") contains illegal characters.")}}};CronPattern.prototype.handleNumber=function(conf,type,valueIndexOffset){const i=parseInt(conf,10)+valueIndexOffset;if(i<0||i>=this[type].length){throw new TypeError("CronPattern: "+type+" value out of range: '"+conf+"'")}this[type][i]=1};CronPattern.prototype.handleRangeWithStepping=function(conf,type,valueIndexOffset){const matches=conf.match(/^(\d+)-(\d+)\/(\d+)$/);if(matches===null)throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '"+conf+"'");let[,lower,upper,steps]=matches;lower=parseInt(lower,10)+valueIndexOffset;upper=parseInt(upper,10)+valueIndexOffset;steps=parseInt(steps,10)+valueIndexOffset;if(isNaN(lower))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(upper))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(isNaN(steps))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(steps===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(steps>this[type].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[type].length+")");if(lower<0||upper>=this[type].length)throw new TypeError("CronPattern: Value out of range: '"+conf+"'");if(lower>upper)throw new TypeError("CronPattern: From value is larger than to value: '"+conf+"'");for(let i=lower;i<=upper;i+=steps){this[type][i+valueIndexOffset]=1}};CronPattern.prototype.handleRange=function(conf,type,valueIndexOffset){const split=conf.split("-");if(split.length!==2){throw new TypeError("CronPattern: Syntax error, illegal range: '"+conf+"'")}const lower=parseInt(split[0],10)+valueIndexOffset,upper=parseInt(split[1],10)+valueIndexOffset;if(isNaN(lower)){throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)")}else if(isNaN(upper)){throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)")}if(lower<0||upper>=this[type].length){throw new TypeError("CronPattern: Value out of range: '"+conf+"'")}if(lower>upper){throw new TypeError("CronPattern: From value is larger than to value: '"+conf+"'")}for(let i=lower;i<=upper;i++){this[type][i+valueIndexOffset]=1}};CronPattern.prototype.handleStepping=function(conf,type,valueIndexOffset){const split=conf.split("/");if(split.length!==2){throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+conf+"'")}let start=0;if(split[0]!=="*"){start=parseInt(split[0],10)}const steps=parseInt(split[1],10);if(isNaN(steps))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(steps===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(steps>this[type].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[type].length+")");for(let i=start;i<this[type].length;i+=steps){this[type][i+valueIndexOffset]=1}};CronPattern.prototype.replaceAlphaDays=function(conf){return conf.replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")};CronPattern.prototype.replaceAlphaMonths=function(conf){return conf.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")};const maxDelay=Math.pow(2,32-1)-1;function Cron(pattern,options,func){if(!(this instanceof Cron)){return new Cron(pattern,options,func)}this.pattern=new CronPattern(pattern);if(typeof options==="function"){func=options;options=void 0}this.options=this.processOptions(options);if(func!==void 0){this.fn=func;this.schedule()}return this}Cron.prototype.processOptions=function(options){if(options===void 0){options={}}options.paused=options.paused===void 0?false:options.paused;options.maxRuns=options.maxRuns===void 0?Infinity:options.maxRuns;options.catch=options.catch===void 0?false:options.catch;options.kill=false;if(options.startAt){options.startAt=new CronDate(options.startAt,options.timezone)}if(options.stopAt){options.stopAt=new CronDate(options.stopAt,options.timezone)}return options};Cron.prototype.next=function(prev){prev=new CronDate(prev,this.options.timezone);const next=this._next(prev);return next?next.getDate():null};Cron.prototype.running=function(){const msLeft=this.msToNext(this.previousrun);const running=!this.options.paused&&this.fn!==void 0;return msLeft!==null&&running};Cron.prototype.previous=function(){return this.previousrun?this.previousrun.getDate():null};Cron.prototype._next=function(prev){if(this.options.startAt&&prev&&prev.getTime(true)<this.options.startAt.getTime(true)){prev=new CronDate(this.options.startAt,this.options.timezone)}const nextRun=new CronDate(prev,this.options.timezone).increment(this.pattern);if(nextRun===null||this.options.maxRuns<=0||this.options.kill||this.options.stopAt&&nextRun.getTime(true)>=this.options.stopAt.getTime(true)){return null}else{return nextRun}};Cron.prototype.msToNext=function(prev){prev=new CronDate(prev,this.options.timezone);const next=this._next(prev);if(next){return next.getTime(true)-prev.getTime(true)}else{return null}};Cron.prototype.stop=function(){this.options.kill=true;if(this.currentTimeout){clearTimeout(this.currentTimeout)}};Cron.prototype.pause=function(){return(this.options.paused=true)&&!this.options.kill};Cron.prototype.resume=function(){return!(this.options.paused=false)&&!this.options.kill};Cron.prototype.schedule=function(func){if(func&&this.fn){throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.")}else if(func){this.fn=func}let waitMs=this.msToNext(this.previousrun);if(waitMs===null)return this;const _maxDelay=this.maxDelay||maxDelay;if(waitMs>_maxDelay){waitMs=_maxDelay}const go=()=>{if(waitMs!==_maxDelay&&!this.options.paused){this.options.maxRuns--;if(this.options.catch){try{this.fn(this,this.options.context)}catch(_e){}}else{this.fn(this,this.options.context)}this.previousrun=new CronDate(void 0,this.options.timezone)}this.schedule()};this.currentTimeout=setTimeout(go,waitMs);return this};export{Cron,Cron as default};
|
|
1
|
+
function convertTZ(date,tzString){return new Date(date.toLocaleString("en-US",{timeZone:tzString}))}function CronDate(date,timezone){this.timezone=timezone;if(date&&date instanceof Date){this.fromDate(date)}else if(date===void 0){this.fromDate(new Date)}else if(date&&typeof date==="string"){this.fromString(date)}else if(date instanceof CronDate){this.fromCronDate(date)}else{throw new TypeError("CronDate: Invalid type ("+typeof date+") passed as parameter to CronDate constructor")}}CronDate.prototype.fromDate=function(date,fromLocal){if(this.timezone&&!fromLocal){date=convertTZ(date,this.timezone)}this.milliseconds=date.getMilliseconds();this.seconds=date.getSeconds();this.minutes=date.getMinutes();this.hours=date.getHours();this.days=date.getDate();this.months=date.getMonth();this.years=date.getFullYear()};CronDate.prototype.fromCronDate=function(date){this.timezone=date.timezone;this.milliseconds=date.milliseconds;this.seconds=date.seconds;this.minutes=date.minutes;this.hours=date.hours;this.days=date.days;this.months=date.months;this.years=date.years};CronDate.prototype.apply=function(){const newDate=new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds);this.milliseconds=newDate.getMilliseconds();this.seconds=newDate.getSeconds();this.minutes=newDate.getMinutes();this.hours=newDate.getHours();this.days=newDate.getDate();this.months=newDate.getMonth();this.years=newDate.getFullYear()};CronDate.prototype.fromString=function(str){const parsedDate=this.parseISOLocal(str);if(isNaN(parsedDate)){throw new TypeError("CronDate: Provided string value for CronDate could not be parsed as date.")}this.fromDate(parsedDate,true)};CronDate.prototype.increment=function(pattern,rerun){if(!rerun){this.seconds+=1}this.milliseconds=0;const origTime=this.getTime(),findNext=(target,pattern,offset,override)=>{const startPos=override===void 0?this[target]+offset:0+offset;for(let i=startPos;i<pattern[target].length;i++){if(pattern[target][i]){this[target]=i-offset;return true}}return false},resetPrevious=offset=>{while(doing+offset>=0){findNext(toDo[doing+offset][0],pattern,toDo[doing+offset][2],0);doing--}};const toDo=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]];let doing=0;while(doing<5){let currentValue=this[toDo[doing][0]];if(!findNext(toDo[doing][0],pattern,toDo[doing][2])){this[toDo[doing][1]]++;resetPrevious(0)}else if(currentValue!==this[toDo[doing][0]]){resetPrevious(-1)}if(this.years>=4e3){return null}doing++}while(!pattern.daysOfWeek[this.getDate(true).getDay()]){this.days+=1;doing=2;resetPrevious()}if(origTime!=this.getTime()){this.apply();return this.increment(pattern,true)}else{return this}};CronDate.prototype.getDate=function(internal){const targetDate=new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds);if(internal||!this.timezone){return targetDate}else{const offset=convertTZ(targetDate,this.timezone).getTime()-targetDate.getTime();return new Date(targetDate.getTime()-offset)}};CronDate.prototype.getTime=function(internal){return this.getDate(internal).getTime()};CronDate.prototype.parseISOLocal=function(dateTimeString){const dateTimeStringSplit=dateTimeString.split(/\D/);if(dateTimeStringSplit.length<6){return NaN}const year=parseInt(dateTimeStringSplit[0],10),month=parseInt(dateTimeStringSplit[1],10),day=parseInt(dateTimeStringSplit[2],10),hour=parseInt(dateTimeStringSplit[3],10),minute=parseInt(dateTimeStringSplit[4],10),second=parseInt(dateTimeStringSplit[5],10);if(isNaN(year)||isNaN(month)||isNaN(day)||isNaN(hour)||isNaN(minute)||isNaN(second)){return NaN}else{return new Date(year,month-1,day,hour,minute,second)}};function CronPattern(pattern){this.pattern=pattern;this.seconds=Array(60).fill(0);this.minutes=Array(60).fill(0);this.hours=Array(24).fill(0);this.days=Array(31).fill(0);this.months=Array(12).fill(0);this.daysOfWeek=Array(8).fill(0);this.parse()}CronPattern.prototype.parse=function(){if(!(typeof this.pattern==="string"||this.pattern.constructor===String)){throw new TypeError("CronPattern: Pattern has to be of type string.")}const parts=this.pattern.trim().replace(/\s+/g," ").split(" ");if(parts.length<5||parts.length>6){throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exacly five or six space separated parts required.")}if(parts.length===5){parts.unshift("0")}parts[4]=this.replaceAlphaMonths(parts[4]);parts[5]=this.replaceAlphaDays(parts[5]);let initDate=new Date;parts[0]=parts[0].replace("?",initDate.getSeconds());parts[1]=parts[1].replace("?",initDate.getMinutes());parts[2]=parts[2].replace("?",initDate.getHours());parts[3]=parts[3].replace("?",initDate.getDate());parts[4]=parts[4].replace("?",initDate.getMonth()+1);parts[5]=parts[5].replace("?",initDate.getDay());this.throwAtIllegalCharacters(parts);this.partToArray("seconds",parts[0],0);this.partToArray("minutes",parts[1],0);this.partToArray("hours",parts[2],0);this.partToArray("days",parts[3],-1);this.partToArray("months",parts[4],-1);this.partToArray("daysOfWeek",parts[5],0);if(this.daysOfWeek[7]){this.daysOfWeek[0]=1}};CronPattern.prototype.partToArray=function(type,conf,valueIndexOffset,recursed){const arr=this[type];if(conf==="*"){for(let i=0;i<arr.length;i++){arr[i]=1}return}const split=conf.split(",");if(split.length>1){for(let i=0;i<split.length;i++){this.partToArray(type,split[i],valueIndexOffset,true)}}else if(conf.indexOf("-")!==-1&&conf.indexOf("/")!==-1){if(recursed)throw new Error("CronPattern: Range with stepping cannot coexist with ,");this.handleRangeWithStepping(conf,type,valueIndexOffset)}else if(conf.indexOf("-")!==-1){if(recursed)throw new Error("CronPattern: Range with stepping cannot coexist with ,");this.handleRange(conf,type,valueIndexOffset)}else if(conf.indexOf("/")!==-1){if(recursed)throw new Error("CronPattern: Range with stepping cannot coexist with ,");this.handleStepping(conf,type,valueIndexOffset)}else{this.handleNumber(conf,type,valueIndexOffset)}};CronPattern.prototype.throwAtIllegalCharacters=function(parts){const reValidCron=/[^/*0-9,-]+/;for(let i=0;i<parts.length;i++){if(reValidCron.test(parts[i])){throw new TypeError("CronPattern: configuration entry "+i+" ("+parts[i]+") contains illegal characters.")}}};CronPattern.prototype.handleNumber=function(conf,type,valueIndexOffset){const i=parseInt(conf,10)+valueIndexOffset;if(i<0||i>=this[type].length){throw new TypeError("CronPattern: "+type+" value out of range: '"+conf+"'")}this[type][i]=1};CronPattern.prototype.handleRangeWithStepping=function(conf,type,valueIndexOffset){const matches=conf.match(/^(\d+)-(\d+)\/(\d+)$/);if(matches===null)throw new TypeError("CronPattern: Syntax error, illegal range with stepping: '"+conf+"'");let[,lower,upper,steps]=matches;lower=parseInt(lower,10)+valueIndexOffset;upper=parseInt(upper,10)+valueIndexOffset;steps=parseInt(steps,10)+valueIndexOffset;if(isNaN(lower))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(upper))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(isNaN(steps))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(steps===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(steps>this[type].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[type].length+")");if(lower<0||upper>=this[type].length)throw new TypeError("CronPattern: Value out of range: '"+conf+"'");if(lower>upper)throw new TypeError("CronPattern: From value is larger than to value: '"+conf+"'");for(let i=lower;i<=upper;i+=steps){this[type][i+valueIndexOffset]=1}};CronPattern.prototype.handleRange=function(conf,type,valueIndexOffset){const split=conf.split("-");if(split.length!==2){throw new TypeError("CronPattern: Syntax error, illegal range: '"+conf+"'")}const lower=parseInt(split[0],10)+valueIndexOffset,upper=parseInt(split[1],10)+valueIndexOffset;if(isNaN(lower)){throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)")}else if(isNaN(upper)){throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)")}if(lower<0||upper>=this[type].length){throw new TypeError("CronPattern: Value out of range: '"+conf+"'")}if(lower>upper){throw new TypeError("CronPattern: From value is larger than to value: '"+conf+"'")}for(let i=lower;i<=upper;i++){this[type][i+valueIndexOffset]=1}};CronPattern.prototype.handleStepping=function(conf,type,valueIndexOffset){const split=conf.split("/");if(split.length!==2){throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+conf+"'")}let start=0;if(split[0]!=="*"){start=parseInt(split[0],10)}const steps=parseInt(split[1],10);if(isNaN(steps))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(steps===0)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(steps>this[type].length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[type].length+")");for(let i=start;i<this[type].length;i+=steps){this[type][i+valueIndexOffset]=1}};CronPattern.prototype.replaceAlphaDays=function(conf){return conf.replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")};CronPattern.prototype.replaceAlphaMonths=function(conf){return conf.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")};const maxDelay=Math.pow(2,32-1)-1;function Cron(pattern,options,func){if(!(this instanceof Cron)){return new Cron(pattern,options,func)}this.pattern=new CronPattern(pattern);if(typeof options==="function"){func=options;options=void 0}this.options=this.processOptions(options);if(func!==void 0){this.fn=func;this.schedule()}return this}Cron.prototype.processOptions=function(options){if(options===void 0){options={}}options.paused=options.paused===void 0?false:options.paused;options.maxRuns=options.maxRuns===void 0?Infinity:options.maxRuns;options.catch=options.catch===void 0?false:options.catch;options.kill=false;if(options.startAt){options.startAt=new CronDate(options.startAt,options.timezone)}if(options.stopAt){options.stopAt=new CronDate(options.stopAt,options.timezone)}return options};Cron.prototype.next=function(prev){prev=new CronDate(prev,this.options.timezone);const next=this._next(prev);return next?next.getDate():null};Cron.prototype.enumerate=function(n,previous){let enumeration=[];while(n--){previous=this.next(previous);if(previous!==null){enumeration.push(previous)}else{break}}return enumeration};Cron.prototype.running=function(){const msLeft=this.msToNext(this.previousrun);const running=!this.options.paused&&this.fn!==void 0;return msLeft!==null&&running};Cron.prototype.previous=function(){return this.previousrun?this.previousrun.getDate():null};Cron.prototype._next=function(prev){if(this.options.startAt&&prev&&prev.getTime(true)<this.options.startAt.getTime(true)){prev=new CronDate(this.options.startAt,this.options.timezone)}const nextRun=new CronDate(prev,this.options.timezone).increment(this.pattern);if(nextRun===null||this.options.maxRuns<=0||this.options.kill||this.options.stopAt&&nextRun.getTime(true)>=this.options.stopAt.getTime(true)){return null}else{return nextRun}};Cron.prototype.msToNext=function(prev){prev=new CronDate(prev,this.options.timezone);const next=this._next(prev);if(next){return next.getTime(true)-prev.getTime(true)}else{return null}};Cron.prototype.stop=function(){this.options.kill=true;if(this.currentTimeout){clearTimeout(this.currentTimeout)}};Cron.prototype.pause=function(){return(this.options.paused=true)&&!this.options.kill};Cron.prototype.resume=function(){return!(this.options.paused=false)&&!this.options.kill};Cron.prototype.schedule=function(func){if(func&&this.fn){throw new Error("Cron: It is not allowed to schedule two functions using the same Croner instance.")}else if(func){this.fn=func}let waitMs=this.msToNext(this.previousrun);if(waitMs===null)return this;const _maxDelay=this.maxDelay||maxDelay;if(waitMs>_maxDelay){waitMs=_maxDelay}const go=()=>{if(waitMs!==_maxDelay&&!this.options.paused){this.options.maxRuns--;if(this.options.catch){try{this.fn(this,this.options.context)}catch(_e){}}else{this.fn(this,this.options.context)}this.previousrun=new CronDate(void 0,this.options.timezone)}this.schedule()};this.currentTimeout=setTimeout(go,waitMs);return this};export{Cron,Cron as default};
|
package/dist/croner.min.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["dist/croner.mjs"],"names":["convertTZ","date","tzString","Date","toLocaleString","timeZone","CronDate","timezone","this","fromDate","fromString","fromCronDate","TypeError","prototype","fromLocal","milliseconds","getMilliseconds","seconds","getSeconds","minutes","getMinutes","hours","getHours","days","getDate","months","getMonth","years","getFullYear","apply","newDate","str","parsedDate","parseISOLocal","isNaN","increment","pattern","rerun","origTime","getTime","findNext","target","offset","override","startPos","let","i","length","resetPrevious","doing","toDo","daysOfWeek","getDay","internal","targetDate","dateTimeString","dateTimeStringSplit","split","NaN","year","parseInt","month","day","hour","minute","second","CronPattern","Array","fill","parse","constructor","String","parts","trim","replace","unshift","replaceAlphaMonths","replaceAlphaDays","throwAtIllegalCharacters","partToArray","type","conf","valueIndexOffset","recursed","arr","indexOf","Error","handleRangeWithStepping","handleRange","handleStepping","handleNumber","reValidCron","test","matches","match","lower","upper","steps","start","maxDelay","Math","pow","Cron","options","func","processOptions","fn","schedule","paused","maxRuns","Infinity","catch","kill","startAt","stopAt","next","prev","_next","running","msLeft","msToNext","previousrun","previous","nextRun","stop","currentTimeout","clearTimeout","pause","resume","waitMs","_maxDelay","go","context","_e","setTimeout"],"mappings":"AAgBA,SAASA,UAAUC,KAAMC,UACxB,OAAO,IAAIC,KAAKF,KAAKG,eAAe,QAAS,CAACC,SAAUH,YAUzD,SAASI,SAAUL,KAAMM,UAExBC,KAAKD,SAAWA,SAEhB,GAAIN,MAAQA,gBAAgBE,KAAM,CACjCK,KAAKC,SAASR,WACR,GAAIA,YAAc,EAAG,CAC3BO,KAAKC,SAAS,IAAIN,WACZ,GAAIF,aAAeA,OAAS,SAAU,CAC5CO,KAAKE,WAAWT,WACV,GAAIA,gBAAgBK,SAAU,CACpCE,KAAKG,aAAaV,UACZ,CACN,MAAM,IAAIW,UAAU,kCAAoCX,KAAO,kDAWjEK,SAASO,UAAUJ,SAAW,SAAUR,KAAMa,WAE7C,GAAIN,KAAKD,WAAaO,UAAW,CAChCb,KAAOD,UAAUC,KAAMO,KAAKD,UAG7BC,KAAKO,aAAed,KAAKe,kBACzBR,KAAKS,QAAUhB,KAAKiB,aACpBV,KAAKW,QAAUlB,KAAKmB,aACpBZ,KAAKa,MAAQpB,KAAKqB,WAClBd,KAAKe,KAAOtB,KAAKuB,UACjBhB,KAAKiB,OAAUxB,KAAKyB,WACpBlB,KAAKmB,MAAQ1B,KAAK2B,eASnBtB,SAASO,UAAUF,aAAe,SAAUV,MAC3CO,KAAKD,SAAWN,KAAKM,SACrBC,KAAKO,aAAed,KAAKc,aACzBP,KAAKS,QAAUhB,KAAKgB,QACpBT,KAAKW,QAAUlB,KAAKkB,QACpBX,KAAKa,MAAQpB,KAAKoB,MAClBb,KAAKe,KAAOtB,KAAKsB,KACjBf,KAAKiB,OAAUxB,KAAKwB,OACpBjB,KA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MAAQ,WACtB,OAAQvH,KAAK+F,QAAQK,OAAS,QAAUpG,KAAK+F,QAAQS,MAStDV,KAAKzF,UAAUmH,OAAS,WACvB,QAASxH,KAAK+F,QAAQK,OAAS,SAAWpG,KAAK+F,QAAQS,MAUxDV,KAAKzF,UAAU8F,SAAW,SAAUH,MAGnC,GAAIA,MAAQhG,KAAKkG,GAAI,CACpB,MAAM,IAAIpB,MAAM,0FAGV,GAAIkB,KAAM,CAChBhG,KAAKkG,GAAKF,KAIX3D,IAAIoF,OAASzH,KAAKgH,SAAShH,KAAKiH,aAChC,GAAMQ,SAAW,KAAQ,OAAOzH,KAIhC,MAAM0H,UAAY1H,KAAK2F,UAAYA,SAGnC,GAAI8B,OAASC,UAAY,CACxBD,OAASC,UAIV,MAAMC,GAAK,KAEV,GAAIF,SAAWC,YAAc1H,KAAK+F,QAAQK,OAAS,CAElDpG,KAAK+F,QAAQM,UAGb,GAAIrG,KAAK+F,QAAQQ,MAAO,CACvB,IACCvG,KAAKkG,GAAGlG,KAAMA,KAAK+F,QAAQ6B,SAC1B,MAAOC,UAGH,CACN7H,KAAKkG,GAAGlG,KAAMA,KAAK+F,QAAQ6B,SAG5B5H,KAAKiH,YAAc,IAAInH,cAAc,EAAGE,KAAK+F,QAAQhG,UAKtDC,KAAKmG,YAINnG,KAAKqH,eAAiBS,WAAWH,GAAIF,QAErC,OAAOzH,aAIC8F,KAAMA"}
|
|
1
|
+
{"version":3,"sources":["dist/croner.mjs"],"names":["convertTZ","date","tzString","Date","toLocaleString","timeZone","CronDate","timezone","this","fromDate","fromString","fromCronDate","TypeError","prototype","fromLocal","milliseconds","getMilliseconds","seconds","getSeconds","minutes","getMinutes","hours","getHours","days","getDate","months","getMonth","years","getFullYear","apply","newDate","str","parsedDate","parseISOLocal","isNaN","increment","pattern","rerun","origTime","getTime","findNext","target","offset","override","startPos","let","i","length","resetPrevious","doing","toDo","currentValue","daysOfWeek","getDay","internal","targetDate","dateTimeString","dateTimeStringSplit","split","NaN","year","parseInt","month","day","hour","minute","second","CronPattern","Array","fill","parse","constructor","String","parts","trim","replace","unshift","replaceAlphaMonths","replaceAlphaDays","initDate","throwAtIllegalCharacters","partToArray","type","conf","valueIndexOffset","recursed","arr","indexOf","Error","handleRangeWithStepping","handleRange","handleStepping","handleNumber","reValidCron","test","matches","match","lower","upper","steps","start","maxDelay","Math","pow","Cron","options","func","processOptions","fn","schedule","paused","maxRuns","Infinity","catch","kill","startAt","stopAt","next","prev","_next","enumerate","n","previous","enumeration","push","running","msLeft","msToNext","previousrun","nextRun","stop","currentTimeout","clearTimeout","pause","resume","waitMs","_maxDelay","go","context","_e","setTimeout"],"mappings":"AAgBA,SAASA,UAAUC,KAAMC,UACxB,OAAO,IAAIC,KAAKF,KAAKG,eAAe,QAAS,CAACC,SAAUH,YAUzD,SAASI,SAAUL,KAAMM,UAExBC,KAAKD,SAAWA,SAEhB,GAAIN,MAAQA,gBAAgBE,KAAM,CACjCK,KAAKC,SAASR,WACR,GAAIA,YAAc,EAAG,CAC3BO,KAAKC,SAAS,IAAIN,WACZ,GAAIF,aAAeA,OAAS,SAAU,CAC5CO,KAAKE,WAAWT,WACV,GAAIA,gBAAgBK,SAAU,CACpCE,KAAKG,aAAaV,UACZ,CACN,MAAM,IAAIW,UAAU,kCAAoCX,KAAO,kDAWjEK,SAASO,UAAUJ,SAAW,SAAUR,KAAMa,WAE7C,GAAIN,KAAKD,WAAaO,UAAW,CAChCb,KAAOD,UAAUC,KAAMO,KAAKD,UAG7BC,KAAKO,aAAed,KAAKe,kBACzBR,KAAKS,QAAUhB,KAAKiB,aACpBV,KAAKW,QAAUlB,KAAKmB,aACpBZ,KAAKa,MAAQpB,KAAKqB,WAClBd,KAAKe,KAAOtB,KAAKuB,UACjBhB,KAAKiB,OAAUxB,KAAKyB,WACpBlB,KAAKmB,MAAQ1B,KAAK2B,eASnBtB,SAASO,UAAUF,aAAe,SAAUV,MAC3CO,KAAKD,SAAWN,KAAKM,SACrBC,KAAKO,aAAed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,IAAI0F,OAAS/H,KAAKuH,SAASvH,KAAKwH,aAChC,GAAMO,SAAW,KAAQ,OAAO/H,KAIhC,MAAMgI,UAAYhI,KAAK6F,UAAYA,SAGnC,GAAIkC,OAASC,UAAY,CACxBD,OAASC,UAIV,MAAMC,GAAK,KAEV,GAAIF,SAAWC,YAAchI,KAAKiG,QAAQK,OAAS,CAElDtG,KAAKiG,QAAQM,UAGb,GAAIvG,KAAKiG,QAAQQ,MAAO,CACvB,IACCzG,KAAKoG,GAAGpG,KAAMA,KAAKiG,QAAQiC,SAC1B,MAAOC,UAGH,CACNnI,KAAKoG,GAAGpG,KAAMA,KAAKiG,QAAQiC,SAG5BlI,KAAKwH,YAAc,IAAI1H,cAAc,EAAGE,KAAKiG,QAAQlG,UAKtDC,KAAKqG,YAINrG,KAAK2H,eAAiBS,WAAWH,GAAIF,QAErC,OAAO/H,aAICgG,KAAMA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "croner",
|
|
3
|
-
"version": "4.0.
|
|
4
|
-
"description": "Trigger functions
|
|
3
|
+
"version": "4.0.86",
|
|
4
|
+
"description": "Trigger functions and/or evaluate cron expressions in JavaScript. No dependencies. Most features. All environmens.",
|
|
5
5
|
"author": "Hexagon <github.com/hexagon>",
|
|
6
6
|
"homepage": "https://hexagon.github.io/croner",
|
|
7
7
|
"contributors": [
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"module": "./src/croner.js",
|
|
54
54
|
"types": "types/croner.single.d.ts",
|
|
55
55
|
"exports": {
|
|
56
|
+
"./package.json": "./package.json",
|
|
56
57
|
".": {
|
|
57
58
|
"import": "./src/croner.js",
|
|
58
59
|
"require": "./dist/croner.cjs",
|
|
@@ -66,7 +67,7 @@
|
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
69
|
"c8": "^7.10.0",
|
|
69
|
-
"eslint": "^8.
|
|
70
|
+
"eslint": "^8.8.0",
|
|
70
71
|
"jsdoc": "^3.6.7",
|
|
71
72
|
"jsdoc-chameleon-template": "^1.0.2",
|
|
72
73
|
"rollup": "^2.59.0",
|
package/src/croner.js
CHANGED
|
@@ -128,7 +128,7 @@ Cron.prototype.processOptions = function (options) {
|
|
|
128
128
|
/**
|
|
129
129
|
* Find next runtime, based on supplied date. Strips milliseconds.
|
|
130
130
|
*
|
|
131
|
-
* @param {Date} [prev] -
|
|
131
|
+
* @param {Date} [prev] - Date to start from
|
|
132
132
|
* @returns {Date | null} - Next run time
|
|
133
133
|
*/
|
|
134
134
|
Cron.prototype.next = function (prev) {
|
|
@@ -137,6 +137,28 @@ Cron.prototype.next = function (prev) {
|
|
|
137
137
|
return next ? next.getDate() : null;
|
|
138
138
|
};
|
|
139
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Find next n runs, based on supplied date. Strips milliseconds.
|
|
142
|
+
*
|
|
143
|
+
* @param {number} n - Number of runs to enumerate
|
|
144
|
+
* @param {Date} [prev] - Date to start from
|
|
145
|
+
* @returns {Date[]} - Next n run times
|
|
146
|
+
*/
|
|
147
|
+
Cron.prototype.enumerate = function (n, previous) {
|
|
148
|
+
let enumeration = [];
|
|
149
|
+
|
|
150
|
+
while(n--) {
|
|
151
|
+
previous = this.next(previous);
|
|
152
|
+
if (previous !== null) {
|
|
153
|
+
enumeration.push(previous);
|
|
154
|
+
} else {
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return enumeration;
|
|
160
|
+
};
|
|
161
|
+
|
|
140
162
|
/**
|
|
141
163
|
* Is running?
|
|
142
164
|
* @public
|
package/src/date.js
CHANGED
|
@@ -144,19 +144,19 @@ CronDate.prototype.increment = function (pattern, rerun) {
|
|
|
144
144
|
|
|
145
145
|
},
|
|
146
146
|
|
|
147
|
-
resetPrevious = () => {
|
|
147
|
+
resetPrevious = (offset) => {
|
|
148
148
|
// Now when we have gone to next minute, we have to set seconds to the first match
|
|
149
149
|
// Now we are at 00:01:05 following the same example.
|
|
150
150
|
//
|
|
151
151
|
// This goes all the way back to seconds, hence the reverse loop.
|
|
152
|
-
while(doing >= 0) {
|
|
152
|
+
while(doing + offset >= 0) {
|
|
153
153
|
|
|
154
154
|
// Ok, reset current member(e.g. seconds) to first match in pattern, using
|
|
155
155
|
// the same method as aerlier
|
|
156
156
|
//
|
|
157
157
|
// Note the fourth parameter, stating that we should start matching the pattern
|
|
158
158
|
// from zero, instead of current time.
|
|
159
|
-
findNext(toDo[doing][0], pattern, toDo[doing][2], 0);
|
|
159
|
+
findNext(toDo[doing + offset][0], pattern, toDo[doing + offset][2], 0);
|
|
160
160
|
|
|
161
161
|
// Go back up, days -> hours -> minutes -> seconds
|
|
162
162
|
doing--;
|
|
@@ -187,12 +187,24 @@ CronDate.prototype.increment = function (pattern, rerun) {
|
|
|
187
187
|
// If time is 00:00:01 and pattern says *:*:05, seconds will
|
|
188
188
|
// be set to 5
|
|
189
189
|
|
|
190
|
-
//
|
|
190
|
+
// Store current value at current level
|
|
191
|
+
let currentValue = this[toDo[doing][0]];
|
|
192
|
+
|
|
193
|
+
// If pattern didn't provide a match, increment next value (e.g. minues)
|
|
191
194
|
if(!findNext(toDo[doing][0], pattern, toDo[doing][2])) {
|
|
192
195
|
this[toDo[doing][1]]++;
|
|
193
|
-
|
|
196
|
+
|
|
197
|
+
// Reset current level and previous levels
|
|
198
|
+
resetPrevious(0);
|
|
199
|
+
|
|
200
|
+
// If pattern provided a match, but changed current value ...
|
|
201
|
+
} else if (currentValue !== this[toDo[doing][0]]) {
|
|
202
|
+
// Reset previous levels
|
|
203
|
+
resetPrevious(-1);
|
|
204
|
+
|
|
194
205
|
}
|
|
195
206
|
|
|
207
|
+
|
|
196
208
|
// Bail out if an impossible pattern is used
|
|
197
209
|
if (this.years >= 4000) {
|
|
198
210
|
return null;
|
package/src/pattern.js
CHANGED
|
@@ -60,6 +60,16 @@ CronPattern.prototype.parse = function () {
|
|
|
60
60
|
parts[4] = this.replaceAlphaMonths(parts[4]);
|
|
61
61
|
parts[5] = this.replaceAlphaDays(parts[5]);
|
|
62
62
|
|
|
63
|
+
// Implement '?' in the simplest possible way - replace ? with current value, before further processing
|
|
64
|
+
let initDate = new Date();
|
|
65
|
+
|
|
66
|
+
parts[0] = parts[0].replace("?", initDate.getSeconds());
|
|
67
|
+
parts[1] = parts[1].replace("?", initDate.getMinutes());
|
|
68
|
+
parts[2] = parts[2].replace("?", initDate.getHours());
|
|
69
|
+
parts[3] = parts[3].replace("?", initDate.getDate());
|
|
70
|
+
parts[4] = parts[4].replace("?", initDate.getMonth()+1);
|
|
71
|
+
parts[5] = parts[5].replace("?", initDate.getDay());
|
|
72
|
+
|
|
63
73
|
// Check part content
|
|
64
74
|
this.throwAtIllegalCharacters(parts);
|
|
65
75
|
|
package/types/croner.d.ts
CHANGED
|
@@ -66,10 +66,18 @@ export class Cron {
|
|
|
66
66
|
/**
|
|
67
67
|
* Find next runtime, based on supplied date. Strips milliseconds.
|
|
68
68
|
*
|
|
69
|
-
* @param {Date} [prev] -
|
|
69
|
+
* @param {Date} [prev] - Date to start from
|
|
70
70
|
* @returns {Date | null} - Next run time
|
|
71
71
|
*/
|
|
72
72
|
next(prev?: Date): Date | null;
|
|
73
|
+
/**
|
|
74
|
+
* Find next n runs, based on supplied date. Strips milliseconds.
|
|
75
|
+
*
|
|
76
|
+
* @param {number} n - Number of runs to enumerate
|
|
77
|
+
* @param {Date} [prev] - Date to start from
|
|
78
|
+
* @returns {Date[]} - Next n run times
|
|
79
|
+
*/
|
|
80
|
+
enumerate(n: number, previous: any): Date[];
|
|
73
81
|
/**
|
|
74
82
|
* Is running?
|
|
75
83
|
* @public
|