croner 4.0.85 → 4.0.89

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 CHANGED
@@ -1,17 +1,17 @@
1
1
  <p align="center">
2
- <img src="/croner.png" alt="Croner" width="150" height="150"><br>
3
- Trigger functions in JavaScript using Cron syntax.<br><br>Try it live on <a href="https://jsfiddle.net/hexag0n/hoa8kwsb/">jsfiddle</a>.<br>
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
  ![Node.js CI](https://github.com/Hexagon/croner/workflows/Node.js%20CI/badge.svg?branch=master) [![npm version](https://badge.fury.io/js/croner.svg)](https://badge.fury.io/js/croner) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/4978bdbf495941c087ecb32b120f28ff)](https://www.codacy.com/gh/Hexagon/croner/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Hexagon/croner&amp;utm_campaign=Badge_Grade)
9
9
  [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Hexagon/croner/blob/master/LICENSE) [![NPM Downloads](https://img.shields.io/npm/dm/croner.svg)](https://www.npmjs.org/package/croner)
10
- [![Support Server](https://img.shields.io/discord/912830749948915713.svg?color=7289da&label=Croner&logo=discord&style=flat-square)](https://discord.gg/VgpuJ48K8K)
10
+ ![No dependencies](https://img.shields.io/badge/dependencies-none-brightgreen)
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 date is next sunday?
30
- const nextSunday = Cron('0 0 0 * * 7').next();
31
- console.log(nextSunday.toLocaleDateString());
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 2021-11-26:
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 37.77ms
52
- node-cron: ??? in 6.746ms
53
- cron: 2022-03-05 00:00:00 in 8.282ms
54
- croner: 2048-02-29 00:00:00 in 2.676ms
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 91.834ms
61
- node-cron: ??? in 7.69ms
62
- cron: 2022-03-15 00:00:00 in 12.354ms
63
- croner: 2022-02-15 00:00:00 in 4.398ms
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 244.057ms
68
- node-cron: ??? in 12.001ms
69
- cron: 2021-11-29 00:00:00 in 19.322ms
70
- croner: 2022-10-03 00:00:00 in 5.394ms
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 87.661ms
82
- node-cron: ??? in 10.299ms
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 25.756ms
85
- croner: 2022-03-31 23:00:00 in 5.569ms
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
- https://gist.github.com/Hexagon/703f85f2dd86443cc17eef8f5cc6cb70
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
- console.log("This will run every second.");
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
- console.log("This will run every second.");
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
- console.log("This will run every second.");
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,15 @@ 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
- #### Pattern
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.
217
+ - *L*: L can be used in the day of month field, to specify the last day of the month.
211
218
 
212
219
  ```javascript
213
220
  // ┌──────────────── (optional) second (0 - 59)
@@ -223,12 +230,12 @@ job.stop();
223
230
 
224
231
  | Field | Required | Allowed values | Allowed special characters | Remarks |
225
232
  |--------------|----------|----------------|----------------------------|---------------------------------------|
226
- | Seconds | Optional | 0-59 | * , - / | |
227
- | Minutes | Yes | 0-59 | * , - / | |
228
- | Hours | Yes | 0-23 | * , - / | |
229
- | Day of Month | Yes | 1-31 | * , - / | |
230
- | Month | Yes | 1-12 or JAN-DEC| * , - / | |
231
- | Day of Week | Yes | 0-7 or SUN-MON | * , - / | 0 to 6 are Sunday to Saturday<br>7 is Sunday, the same as 0 |
233
+ | Seconds | Optional | 0-59 | * , - / ? | |
234
+ | Minutes | Yes | 0-59 | * , - / ? | |
235
+ | Hours | Yes | 0-23 | * , - / ? | |
236
+ | Day of Month | Yes | 1-31 | * , - / ? L | |
237
+ | Month | Yes | 1-12 or JAN-DEC| * , - / ? | |
238
+ | Day of Week | Yes | 0-7 or SUN-MON | * , - / ? | 0 to 6 are Sunday to Saturday<br>7 is Sunday, the same as 0 |
232
239
 
233
240
  **Note**: Weekday and month names are case insensitive. Both MON and mon works.
234
241
 
@@ -237,23 +244,25 @@ job.stop();
237
244
  #### Expressions
238
245
  ```javascript
239
246
  // Run a function according to pattern
240
- Cron('15-45/10 */5 1,2,3 * JAN-MAR SAT', function () {
247
+ Cron('15-45/10 */5 1,2,3 ? JAN-MAR SAT', function () {
241
248
  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.');
249
+ console.log('every fifth minute of hour 1,2 and 3 when day of month');
250
+ console.log('is the same as when Cron started, every saturday in January to March.');
244
251
  });
245
252
  ```
246
253
 
247
254
  #### Find dates
248
255
  ```javascript
249
256
  // Find next month
250
- const nextMonth = Cron('0 0 0 1 * *').next(),
251
- nextSunday = Cron('0 0 0 * * 7').next(),
252
- nextSat29feb = Cron("0 0 0 29 2 6").next();
257
+ const nextMonth = Cron("0 0 0 1 * *").next(),
258
+ nextSunday = Cron("0 0 0 * * 7").next(),
259
+ nextSat29feb = Cron("0 0 0 29 2 6").next(),
260
+ nextSunLastOfMonth = Cron("0 0 0 L * 7").next();
253
261
 
254
262
  console.log("First day of next month: " + nextMonth.toLocaleDateString());
255
263
  console.log("Next sunday: " + nextSunday.toLocaleDateString());
256
264
  console.log("Next saturday at 29th of february: " + nextSat29feb.toLocaleDateString()); // 2048-02-29
265
+ console.log("Next month ending with a sunday: " + nextSunLastOfMonth.toLocaleDateString());
257
266
  ```
258
267
 
259
268
  #### With options
package/dist/croner.cjs CHANGED
@@ -158,7 +158,6 @@
158
158
  const startPos = (override === void 0) ? this[target] + offset : 0 + offset;
159
159
 
160
160
  for( let i = startPos; i < pattern[target].length; i++ ) {
161
-
162
161
  if( pattern[target][i] ) {
163
162
  this[target] = i-offset;
164
163
  return true;
@@ -238,10 +237,29 @@
238
237
  doing++;
239
238
  }
240
239
 
240
+ // This is a special case for last day of month, increase days until days+1 changes month, stop, and re-evaluate
241
+ if (pattern.lastDayOfMonth) {
242
+ let baseDate = this.getDate(true),
243
+ originalDays = this.days;
244
+
245
+ // Set days to one day before the first of next month
246
+ baseDate.setMonth(baseDate.getMonth()+1);
247
+ baseDate.setDate(0);
248
+ this.days = baseDate.getDate();
249
+
250
+ // If day has changed, reset everything before days
251
+ if (this.days !== originalDays) {
252
+ doing = 2;
253
+ resetPrevious();
254
+ }
255
+ }
256
+
241
257
  // This is a special case for weekday, as the user isn't able to combine date/month patterns
242
258
  // with weekday patterns, it's just to increment days until we get a match.
243
259
  while (!pattern.daysOfWeek[this.getDate(true).getDay()]) {
244
260
  this.days += 1;
261
+
262
+ // Reset everything before days
245
263
  doing = 2;
246
264
  resetPrevious();
247
265
  }
@@ -334,10 +352,12 @@
334
352
  * Create a CronPattern instance from pattern string ('* * * * * *')
335
353
  * @constructor
336
354
  * @param {string} pattern - Input pattern
355
+ * @param {string} timezone - Input timezone, used for '?'-substitution
337
356
  */
338
- function CronPattern (pattern) {
357
+ function CronPattern (pattern, timezone) {
339
358
 
340
359
  this.pattern = pattern;
360
+ this.timezone = timezone;
341
361
 
342
362
  this.seconds = Array(60).fill(0); // 0-59
343
363
  this.minutes = Array(60).fill(0); // 0-59
@@ -346,6 +366,8 @@
346
366
  this.months = Array(12).fill(0); // 0-11 in array, 1-12 in config
347
367
  this.daysOfWeek = Array(8).fill(0); // 0-7 Where 0 = Sunday and 7=Sunday;
348
368
 
369
+ this.lastDayOfMonth = false;
370
+
349
371
  this.parse();
350
372
 
351
373
  }
@@ -374,10 +396,27 @@
374
396
  parts.unshift("0");
375
397
  }
376
398
 
399
+ // Convert 'L' to '*' and add lastDayOfMonth flag,
400
+ // and set days to 28,29,30,31 as those are the only days that can be the last day of month
401
+ if(parts[3].toUpperCase() == "L") {
402
+ parts[3] = "28,29,30,31";
403
+ this.lastDayOfMonth = true;
404
+ }
405
+
377
406
  // Replace alpha representations
378
407
  parts[4] = this.replaceAlphaMonths(parts[4]);
379
408
  parts[5] = this.replaceAlphaDays(parts[5]);
380
409
 
410
+ // Implement '?' in the simplest possible way - replace ? with current value, before further processing
411
+ let initDate = new CronDate(new Date(),this.timezone).getDate(true);
412
+
413
+ parts[0] = parts[0].replace("?", initDate.getSeconds());
414
+ parts[1] = parts[1].replace("?", initDate.getMinutes());
415
+ parts[2] = parts[2].replace("?", initDate.getHours());
416
+ parts[3] = parts[3].replace("?", initDate.getDate());
417
+ parts[4] = parts[4].replace("?", initDate.getMonth()+1); // getMonth is zero indexed while pattern starts from 1
418
+ parts[5] = parts[5].replace("?", initDate.getDay());
419
+
381
420
  // Check part content
382
421
  this.throwAtIllegalCharacters(parts);
383
422
 
@@ -699,9 +738,6 @@
699
738
  return new Cron(pattern, options, func);
700
739
  }
701
740
 
702
- /** @type {CronPattern} */
703
- this.pattern = new CronPattern(pattern);
704
-
705
741
  // Make options optional
706
742
  if( typeof options === "function" ) {
707
743
  func = options;
@@ -711,6 +747,9 @@
711
747
  /** @type {CronOptions} */
712
748
  this.options = this.processOptions(options);
713
749
 
750
+ /** @type {CronPattern} */
751
+ this.pattern = new CronPattern(pattern, this.options.timezone);
752
+
714
753
  /**
715
754
  * Allow shorthand scheduling
716
755
  */
@@ -757,7 +796,7 @@
757
796
  /**
758
797
  * Find next runtime, based on supplied date. Strips milliseconds.
759
798
  *
760
- * @param {Date} [prev] - Input pattern
799
+ * @param {Date} [prev] - Date to start from
761
800
  * @returns {Date | null} - Next run time
762
801
  */
763
802
  Cron.prototype.next = function (prev) {
@@ -766,6 +805,28 @@
766
805
  return next ? next.getDate() : null;
767
806
  };
768
807
 
808
+ /**
809
+ * Find next n runs, based on supplied date. Strips milliseconds.
810
+ *
811
+ * @param {number} n - Number of runs to enumerate
812
+ * @param {Date} [prev] - Date to start from
813
+ * @returns {Date[]} - Next n run times
814
+ */
815
+ Cron.prototype.enumerate = function (n, previous) {
816
+ let enumeration = [];
817
+
818
+ while(n--) {
819
+ previous = this.next(previous);
820
+ if (previous !== null) {
821
+ enumeration.push(previous);
822
+ } else {
823
+ break;
824
+ }
825
+ }
826
+
827
+ return enumeration;
828
+ };
829
+
769
830
  /**
770
831
  * Is running?
771
832
  * @public
@@ -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=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]);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++}if(pattern.lastDayOfMonth){let baseDate=this.getDate(true),originalDays=this.days;baseDate.setMonth(baseDate.getMonth()+1);baseDate.setDate(0);this.days=baseDate.getDate();if(this.days!==originalDays){doing=2;resetPrevious()}}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,timezone){this.pattern=pattern;this.timezone=timezone;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.lastDayOfMonth=false;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")}if(parts[3].toUpperCase()=="L"){parts[3]="28,29,30,31";this.lastDayOfMonth=true}parts[4]=this.replaceAlphaMonths(parts[4]);parts[5]=this.replaceAlphaDays(parts[5]);let initDate=new CronDate(new Date,this.timezone).getDate(true);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)}if(typeof options==="function"){func=options;options=void 0}this.options=this.processOptions(options);this.pattern=new CronPattern(pattern,this.options.timezone);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});
@@ -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","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","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,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,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xG,KAAK0G,GAAKF,KAIX3D,IAAIoF,OAASjI,KAAKwH,SAASxH,KAAKyH,aAChC,GAAMQ,SAAW,KAAQ,OAAOjI,KAIhC,MAAMkI,UAAYlI,KAAKoG,UAAYA,SAGnC,GAAI6B,OAASC,UAAY,CACxBD,OAASC,UAIV,MAAMC,GAAK,KAEV,GAAIF,SAAWC,YAAclI,KAAKuG,QAAQK,OAAS,CAElD5G,KAAKuG,QAAQM,UAGb,GAAI7G,KAAKuG,QAAQQ,MAAO,CACvB,IACC/G,KAAK0G,GAAG1G,KAAMA,KAAKuG,QAAQ6B,SAC1B,MAAOC,UAGH,CACNrI,KAAK0G,GAAG1G,KAAMA,KAAKuG,QAAQ6B,SAG5BpI,KAAKyH,YAAc,IAAIlH,cAAc,EAAGP,KAAKuG,QAAQ/F,UAKtDR,KAAK2G,YAIN3G,KAAK6H,eAAiBS,WAAWH,GAAIF,QAErC,OAAOjI,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","lastDayOfMonth","baseDate","originalDays","setMonth","setDate","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","toUpperCase","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,SAAWN,KAAKM,SACrBR,KAAKe,aAAeb,KAA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,MAAQoF,KAAKpF,QAAQ,UACpC,CACN,OAAO,OAQTxC,KAAKc,UAAU0H,KAAO,WACrBvI,KAAK8G,QAAQS,KAAO,KAEpB,GAAIvH,KAAKwI,eAAiB,CACzBC,aAAczI,KAAKwI,kBAUrBzI,KAAKc,UAAU6H,MAAQ,WACtB,OAAQ1I,KAAK8G,QAAQK,OAAS,QAAUnH,KAAK8G,QAAQS,MAStDxH,KAAKc,UAAU8H,OAAS,WACvB,QAAS3I,KAAK8G,QAAQK,OAAS,SAAWnH,KAAK8G,QAAQS,MAUxDxH,KAAKc,UAAUqG,SAAW,SAAUH,MAGnC,GAAIA,MAAQ/G,KAAKiH,GAAI,CACpB,MAAM,IAAInB,MAAM,0FAGV,GAAIiB,KAAM,CAChB/G,KAAKiH,GAAKF,KAIXlE,IAAI+F,OAAS5I,KAAKoI,SAASpI,KAAKqI,aAChC,GAAMO,SAAW,KAAQ,OAAO5I,KAIhC,MAAM6I,UAAY7I,KAAK2G,UAAYA,SAGnC,GAAIiC,OAASC,UAAY,CACxBD,OAASC,UAIV,MAAMC,GAAK,KAEV,GAAIF,SAAWC,YAAc7I,KAAK8G,QAAQK,OAAS,CAElDnH,KAAK8G,QAAQM,UAGb,GAAIpH,KAAK8G,QAAQQ,MAAO,CACvB,IACCtH,KAAKiH,GAAGjH,KAAMA,KAAK8G,QAAQiC,SAC1B,MAAOC,UAGH,CACNhJ,KAAKiH,GAAGjH,KAAMA,KAAK8G,QAAQiC,SAG5B/I,KAAKqI,YAAc,IAAI9H,cAAc,EAAGP,KAAK8G,QAAQtG,UAKtDR,KAAKkH,YAINlH,KAAKwI,eAAiBS,WAAWH,GAAIF,QAErC,OAAO5I,MAIR,OAAOD"}
@@ -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=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]);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++}if(pattern.lastDayOfMonth){let baseDate=this.getDate(true),originalDays=this.days;baseDate.setMonth(baseDate.getMonth()+1);baseDate.setDate(0);this.days=baseDate.getDate();if(this.days!==originalDays){doing=2;resetPrevious()}}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,timezone){this.pattern=pattern;this.timezone=timezone;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.lastDayOfMonth=false;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")}if(parts[3].toUpperCase()=="L"){parts[3]="28,29,30,31";this.lastDayOfMonth=true}parts[4]=this.replaceAlphaMonths(parts[4]);parts[5]=this.replaceAlphaDays(parts[5]);let initDate=new CronDate(new Date,this.timezone).getDate(true);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)}if(typeof options==="function"){func=options;options=void 0}this.options=this.processOptions(options);this.pattern=new CronPattern(pattern,this.options.timezone);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};
@@ -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","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","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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AQ,OAAO1H,KAIhC,MAAM2H,UAAY3H,KAAK4F,UAAYA,SAGnC,GAAI8B,OAASC,UAAY,CACxBD,OAASC,UAIV,MAAMC,GAAK,KAEV,GAAIF,SAAWC,YAAc3H,KAAKgG,QAAQK,OAAS,CAElDrG,KAAKgG,QAAQM,UAGb,GAAItG,KAAKgG,QAAQQ,MAAO,CACvB,IACCxG,KAAKmG,GAAGnG,KAAMA,KAAKgG,QAAQ6B,SAC1B,MAAOC,UAGH,CACN9H,KAAKmG,GAAGnG,KAAMA,KAAKgG,QAAQ6B,SAG5B7H,KAAKkH,YAAc,IAAIpH,cAAc,EAAGE,KAAKgG,QAAQjG,UAKtDC,KAAKoG,YAINpG,KAAKsH,eAAiBS,WAAWH,GAAIF,QAErC,OAAO1H,aAIC+F,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","lastDayOfMonth","baseDate","originalDays","setMonth","setDate","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","toUpperCase","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","n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,GAAIA,MAAQxG,KAAK0G,GAAI,CACpB,MAAM,IAAIpB,MAAM,0FAGV,GAAIkB,KAAM,CAChBxG,KAAK0G,GAAKF,KAIXnE,IAAIgG,OAASrI,KAAK6H,SAAS7H,KAAK8H,aAChC,GAAMO,SAAW,KAAQ,OAAOrI,KAIhC,MAAMsI,UAAYtI,KAAKmG,UAAYA,SAGnC,GAAIkC,OAASC,UAAY,CACxBD,OAASC,UAIV,MAAMC,GAAK,KAEV,GAAIF,SAAWC,YAActI,KAAKuG,QAAQK,OAAS,CAElD5G,KAAKuG,QAAQM,UAGb,GAAI7G,KAAKuG,QAAQQ,MAAO,CACvB,IACC/G,KAAK0G,GAAG1G,KAAMA,KAAKuG,QAAQiC,SAC1B,MAAOC,UAGH,CACNzI,KAAK0G,GAAG1G,KAAMA,KAAKuG,QAAQiC,SAG5BxI,KAAK8H,YAAc,IAAIhI,cAAc,EAAGE,KAAKuG,QAAQxG,UAKtDC,KAAK2G,YAIN3G,KAAKiI,eAAiBS,WAAWH,GAAIF,QAErC,OAAOrI,aAICsG,KAAMA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "croner",
3
- "version": "4.0.85",
4
- "description": "Trigger functions in javascript using Cron syntax. No dependencies.",
3
+ "version": "4.0.89",
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": [
package/src/croner.js CHANGED
@@ -70,9 +70,6 @@ function Cron (pattern, options, func) {
70
70
  return new Cron(pattern, options, func);
71
71
  }
72
72
 
73
- /** @type {CronPattern} */
74
- this.pattern = new CronPattern(pattern);
75
-
76
73
  // Make options optional
77
74
  if( typeof options === "function" ) {
78
75
  func = options;
@@ -82,6 +79,9 @@ function Cron (pattern, options, func) {
82
79
  /** @type {CronOptions} */
83
80
  this.options = this.processOptions(options);
84
81
 
82
+ /** @type {CronPattern} */
83
+ this.pattern = new CronPattern(pattern, this.options.timezone);
84
+
85
85
  /**
86
86
  * Allow shorthand scheduling
87
87
  */
@@ -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] - Input pattern
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
@@ -134,7 +134,6 @@ CronDate.prototype.increment = function (pattern, rerun) {
134
134
  const startPos = (override === void 0) ? this[target] + offset : 0 + offset;
135
135
 
136
136
  for( let i = startPos; i < pattern[target].length; i++ ) {
137
-
138
137
  if( pattern[target][i] ) {
139
138
  this[target] = i-offset;
140
139
  return true;
@@ -214,10 +213,29 @@ CronDate.prototype.increment = function (pattern, rerun) {
214
213
  doing++;
215
214
  }
216
215
 
216
+ // This is a special case for last day of month, increase days until days+1 changes month, stop, and re-evaluate
217
+ if (pattern.lastDayOfMonth) {
218
+ let baseDate = this.getDate(true),
219
+ originalDays = this.days;
220
+
221
+ // Set days to one day before the first of next month
222
+ baseDate.setMonth(baseDate.getMonth()+1);
223
+ baseDate.setDate(0);
224
+ this.days = baseDate.getDate();
225
+
226
+ // If day has changed, reset everything before days
227
+ if (this.days !== originalDays) {
228
+ doing = 2;
229
+ resetPrevious();
230
+ }
231
+ }
232
+
217
233
  // This is a special case for weekday, as the user isn't able to combine date/month patterns
218
234
  // with weekday patterns, it's just to increment days until we get a match.
219
235
  while (!pattern.daysOfWeek[this.getDate(true).getDay()]) {
220
236
  this.days += 1;
237
+
238
+ // Reset everything before days
221
239
  doing = 2;
222
240
  resetPrevious();
223
241
  }
package/src/pattern.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { CronDate } from "./date.js";
2
+
1
3
  /**
2
4
  * Name for each part of the cron pattern
3
5
  * @typedef {("seconds" | "minutes" | "hours" | "days" | "months" | "daysOfWeek")} CronPatternPart
@@ -16,10 +18,12 @@
16
18
  * Create a CronPattern instance from pattern string ('* * * * * *')
17
19
  * @constructor
18
20
  * @param {string} pattern - Input pattern
21
+ * @param {string} timezone - Input timezone, used for '?'-substitution
19
22
  */
20
- function CronPattern (pattern) {
23
+ function CronPattern (pattern, timezone) {
21
24
 
22
25
  this.pattern = pattern;
26
+ this.timezone = timezone;
23
27
 
24
28
  this.seconds = Array(60).fill(0); // 0-59
25
29
  this.minutes = Array(60).fill(0); // 0-59
@@ -28,6 +32,8 @@ function CronPattern (pattern) {
28
32
  this.months = Array(12).fill(0); // 0-11 in array, 1-12 in config
29
33
  this.daysOfWeek = Array(8).fill(0); // 0-7 Where 0 = Sunday and 7=Sunday;
30
34
 
35
+ this.lastDayOfMonth = false;
36
+
31
37
  this.parse();
32
38
 
33
39
  }
@@ -56,10 +62,27 @@ CronPattern.prototype.parse = function () {
56
62
  parts.unshift("0");
57
63
  }
58
64
 
65
+ // Convert 'L' to '*' and add lastDayOfMonth flag,
66
+ // and set days to 28,29,30,31 as those are the only days that can be the last day of month
67
+ if(parts[3].toUpperCase() == "L") {
68
+ parts[3] = "28,29,30,31";
69
+ this.lastDayOfMonth = true;
70
+ }
71
+
59
72
  // Replace alpha representations
60
73
  parts[4] = this.replaceAlphaMonths(parts[4]);
61
74
  parts[5] = this.replaceAlphaDays(parts[5]);
62
75
 
76
+ // Implement '?' in the simplest possible way - replace ? with current value, before further processing
77
+ let initDate = new CronDate(new Date(),this.timezone).getDate(true);
78
+
79
+ parts[0] = parts[0].replace("?", initDate.getSeconds());
80
+ parts[1] = parts[1].replace("?", initDate.getMinutes());
81
+ parts[2] = parts[2].replace("?", initDate.getHours());
82
+ parts[3] = parts[3].replace("?", initDate.getDate());
83
+ parts[4] = parts[4].replace("?", initDate.getMonth()+1); // getMonth is zero indexed while pattern starts from 1
84
+ parts[5] = parts[5].replace("?", initDate.getDay());
85
+
63
86
  // Check part content
64
87
  this.throwAtIllegalCharacters(parts);
65
88
 
package/types/croner.d.ts CHANGED
@@ -57,19 +57,27 @@ export class Cron {
57
57
  * @returns {Cron}
58
58
  */
59
59
  constructor(pattern: string, options?: CronOptions | Function, func?: Function);
60
- /** @type {CronPattern} */
61
- pattern: CronPattern;
62
60
  /** @type {CronOptions} */
63
61
  options: CronOptions;
62
+ /** @type {CronPattern} */
63
+ pattern: CronPattern;
64
64
  fn: Function;
65
65
  private processOptions;
66
66
  /**
67
67
  * Find next runtime, based on supplied date. Strips milliseconds.
68
68
  *
69
- * @param {Date} [prev] - Input pattern
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
@@ -25,8 +25,9 @@ export type CronIndexOffset = number;
25
25
  * Create a CronPattern instance from pattern string ('* * * * * *')
26
26
  * @constructor
27
27
  * @param {string} pattern - Input pattern
28
+ * @param {string} timezone - Input timezone, used for '?'-substitution
28
29
  */
29
- export function CronPattern(pattern: string): void;
30
+ export function CronPattern(pattern: string, timezone: string): void;
30
31
  export class CronPattern {
31
32
  /**
32
33
  * Name for each part of the cron pattern
@@ -44,15 +45,18 @@ export class CronPattern {
44
45
  * Create a CronPattern instance from pattern string ('* * * * * *')
45
46
  * @constructor
46
47
  * @param {string} pattern - Input pattern
48
+ * @param {string} timezone - Input timezone, used for '?'-substitution
47
49
  */
48
- constructor(pattern: string);
50
+ constructor(pattern: string, timezone: string);
49
51
  pattern: string;
52
+ timezone: string;
50
53
  seconds: any;
51
54
  minutes: any;
52
55
  hours: any;
53
56
  days: any;
54
57
  months: any;
55
58
  daysOfWeek: any;
59
+ lastDayOfMonth: boolean;
56
60
  private parse;
57
61
  private partToArray;
58
62
  private throwAtIllegalCharacters;