croner 3.0.40 → 3.0.44

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,212 +1,212 @@
1
- # Croner
2
-
3
- [![Build status](https://travis-ci.org/Hexagon/croner.svg)](https://travis-ci.org/Hexagon/croner) [![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&utm_medium=referral&utm_content=Hexagon/croner&utm_campaign=Badge_Grade)
4
- [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Hexagon/croner/blob/master/LICENSE) [![jsdelivr](https://data.jsdelivr.com/v1/package/npm/croner/badge?style=rounded)](https://www.jsdelivr.com/package/npm/croner)
5
-
6
- Pure JavaScript minimal isomorphic cron parser and scheduler. Or simply speaking - setInterval on steroids.
7
-
8
- Documented with [JSDoc](https://jsdoc.app/) for intellisense, and include [TypeScript](https://www.typescriptlang.org/) typings.
9
-
10
- ```html
11
- <script src="https://cdn.jsdelivr.net/npm/croner@3/dist/croner.min.js"></script>
12
- ```
13
-
14
- ```javascript
15
- // Run a function each second
16
- Cron('* * * * * *', function () {
17
- console.log('This will run every second');
18
- });
19
- ```
20
-
21
- ## Installation
22
-
23
- ### Manual
24
-
25
- * Download latest [zipball](http://github.com/Hexagon/croner/zipball/master/)
26
- * Unpack
27
- * Grab ```croner.min.js``` ([UMD](https://github.com/umdjs/umd)) or ```croner.min.mjs``` ([ES-module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)) from the [dist/](/dist) folder
28
-
29
- ### Node.js
30
-
31
- ```npm install croner --save```
32
-
33
- ```javascript
34
- // ESM Import
35
- import Cron from "croner";
36
-
37
- // ... or
38
-
39
- // CommonJS Require
40
-
41
- const Cron = require("croner");
42
- ```
43
-
44
- ### CDN
45
-
46
- To use as a [UMD](https://github.com/umdjs/umd)-module (stand alone, [RequireJS](https://requirejs.org/) etc.)
47
-
48
- ```html
49
- <script src="https://cdn.jsdelivr.net/npm/croner@3/dist/croner.min.js"></script>
50
- ```
51
-
52
- To use as a [ES-module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
53
-
54
- ```html
55
- <script type="module">
56
- import Cron from "https://cdn.jsdelivr.net/npm/croner@3/dist/croner.min.mjs";
57
-
58
- // ... see usage section ...
59
- </script>
60
- ```
61
-
62
- ... or a ES-module with [import-map](https://github.com/WICG/import-maps)
63
- ```html
64
- <script type="importmap">
65
- {
66
- "imports": {
67
- "croner": "https://cdn.jsdelivr.net/npm/croner@3/dist/croner.min.mjs"
68
- }
69
- }
70
- </script>
71
- <script type="module">
72
- import Cron from 'croner';
73
-
74
- // ... see usage section ...
75
- </script>
76
- ```
77
-
78
- ## Examples
79
-
80
- ### Minimalist scheduling
81
- ```javascript
82
- // Run a function each second
83
- Cron('* * * * * *', function () {
84
- console.log('This will run every second');
85
- });
86
- ```
87
-
88
- ### Minimalist scheduling with stepping
89
- ```javascript
90
- // Run a function every fifth second
91
- Cron('*/5 * * * * *', function () {
92
- console.log('This will run every fifth second');
93
- });
94
- ```
95
-
96
- ### Minimalist scheduling with range
97
- ```javascript
98
- // Run a function the first five seconds of a minute
99
- Cron('0-4 * * * * *', function () {
100
- console.log('This will run the first five seconds every minute');
101
- });
102
- ```
103
-
104
- ### Minimalist scheduling with options
105
- ```javascript
106
- // Run a function each second, limit to five runs
107
- Cron('* * * * * *', { maxRuns: 5 }, function () {
108
- console.log('This will run each second, but only five times.');
109
- });
110
- ```
111
-
112
- ### Minimalist scheduling with job controls
113
- ```javascript
114
- // Run a function each second, get reference to job
115
- var job = Cron('* * * * * *', function () {
116
- console.log('This will run each second.');
117
- });
118
-
119
- // Pause job
120
- job.pause();
121
-
122
- // Resume job
123
- job.resume();
124
-
125
- // Stop job
126
- job.stop();
127
-
128
- ```
129
-
130
- ### Basic scheduling
131
- ```javascript
132
-
133
- // Run every minute
134
- var scheduler = Cron('0 * * * * *');
135
-
136
- scheduler.schedule(function() {
137
- console.log('This will run every minute');
138
- });
139
- ```
140
-
141
- ### Scheduling with options
142
- ```javascript
143
-
144
- // Run every minute
145
- var scheduler = Cron('0 * * * * *');
146
-
147
- // Schedule with options (all options are optional)
148
- scheduler.schedule({ maxRuns: 5 }, function() {
149
- console.log('This will run every minute.');
150
- });
151
- ```
152
- ### Scheduling with job controls
153
- ```javascript
154
-
155
- // Run every minute
156
- var scheduler = Cron('0 * * * * *');
157
-
158
- // Schedule with options (all options are optional)
159
- var job = scheduler.schedule({ maxRuns: 5 }, function() {
160
- console.log('This will run every minute.');
161
- });
162
-
163
- // Pause job
164
- job.pause();
165
-
166
- // Resume job
167
- job.resume();
168
-
169
- // Stop job
170
- job.stop();
171
- ```
172
-
173
- ## Full API
174
- ```javascript
175
-
176
- var o = Cron( <string pattern> [, <object options>] [, <function callback> ] );
177
- ```
178
- ```javascript
179
- // If Cron is initialized without a scheduled function, cron itself is returned
180
- // and the following member functions is available.
181
- o.next( [ <date previous> ] );
182
- o.msToNext();
183
- o.previous();
184
-
185
- // If Cron is initialized _with_ a scheduled function, the job is retured instead.
186
- // Otherwise you get a reference to the job when scheduling a new job.
187
- var job = o.schedule( [ { startAt: <date>, stopAt: <date>, maxRuns: <integer> } ,] callback);
188
-
189
- // These self-explanatory functions is available to control the job
190
- job.pause();
191
- job.resume();
192
- job.stop();
193
-
194
- ```
195
-
196
- ## Pattern
197
-
198
- ```javascript
199
- ┌──────────────── (optional) second (0 - 59)
200
- │ ┌────────────── minute (0 - 59)
201
- │ │ ┌──────────── hour (0 - 23)
202
- │ │ │ ┌────────── day of month (1 - 31)
203
- │ │ │ │ ┌──────── month (1 - 12)
204
- │ │ │ │ │ ┌────── day of week (0 - 6)
205
- │ │ │ │ │ │ (0 to 6 are Sunday to Saturday; 7 is Sunday, the same as 0)
206
- │ │ │ │ │ │
207
- * * * * * *
208
- ```
209
-
210
- ## License
211
-
1
+ # Croner
2
+
3
+ [![Build status](https://travis-ci.org/Hexagon/croner.svg)](https://travis-ci.org/Hexagon/croner) [![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)
4
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Hexagon/croner/blob/master/LICENSE) [![jsdelivr](https://data.jsdelivr.com/v1/package/npm/croner/badge?style=rounded)](https://www.jsdelivr.com/package/npm/croner)
5
+
6
+ Pure JavaScript minimal isomorphic cron parser and scheduler. Or simply speaking - setInterval on steroids.
7
+
8
+ Documented with [JSDoc](https://jsdoc.app/) for intellisense, and include [TypeScript](https://www.typescriptlang.org/) typings.
9
+
10
+ ```html
11
+ <script src="https://cdn.jsdelivr.net/npm/croner@3/dist/croner.min.js"></script>
12
+ ```
13
+
14
+ ```javascript
15
+ // Run a function each second
16
+ Cron('* * * * * *', function () {
17
+ console.log('This will run every second');
18
+ });
19
+ ```
20
+
21
+ ## Installation
22
+
23
+ ### Manual
24
+
25
+ * Download latest [zipball](http://github.com/Hexagon/croner/zipball/master/)
26
+ * Unpack
27
+ * Grab ```croner.min.js``` ([UMD](https://github.com/umdjs/umd)) or ```croner.min.mjs``` ([ES-module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)) from the [dist/](/dist) folder
28
+
29
+ ### Node.js
30
+
31
+ ```npm install croner --save```
32
+
33
+ ```javascript
34
+ // ESM Import
35
+ import Cron from "croner";
36
+
37
+ // ... or
38
+
39
+ // CommonJS Require
40
+
41
+ const Cron = require("croner");
42
+ ```
43
+
44
+ ### CDN
45
+
46
+ To use as a [UMD](https://github.com/umdjs/umd)-module (stand alone, [RequireJS](https://requirejs.org/) etc.)
47
+
48
+ ```html
49
+ <script src="https://cdn.jsdelivr.net/npm/croner@3/dist/croner.min.js"></script>
50
+ ```
51
+
52
+ To use as a [ES-module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
53
+
54
+ ```html
55
+ <script type="module">
56
+ import Cron from "https://cdn.jsdelivr.net/npm/croner@3/dist/croner.min.mjs";
57
+
58
+ // ... see usage section ...
59
+ </script>
60
+ ```
61
+
62
+ ... or a ES-module with [import-map](https://github.com/WICG/import-maps)
63
+ ```html
64
+ <script type="importmap">
65
+ {
66
+ "imports": {
67
+ "croner": "https://cdn.jsdelivr.net/npm/croner@3/dist/croner.min.mjs"
68
+ }
69
+ }
70
+ </script>
71
+ <script type="module">
72
+ import Cron from 'croner';
73
+
74
+ // ... see usage section ...
75
+ </script>
76
+ ```
77
+
78
+ ## Examples
79
+
80
+ ### Minimalist scheduling
81
+ ```javascript
82
+ // Run a function each second
83
+ Cron('* * * * * *', function () {
84
+ console.log('This will run every second');
85
+ });
86
+ ```
87
+
88
+ ### Minimalist scheduling with stepping and custom timezone
89
+ ```javascript
90
+ // Run a function every fifth second
91
+ Cron('*/5 * * * * *', { timezone: 'Europe/Stockholm' } function () {
92
+ console.log('This will run every fifth second');
93
+ });
94
+ ```
95
+
96
+ ### Minimalist scheduling with range
97
+ ```javascript
98
+ // Run a function the first five seconds of a minute
99
+ Cron('0-4 * * * * *', function () {
100
+ console.log('This will run the first five seconds every minute');
101
+ });
102
+ ```
103
+
104
+ ### Minimalist scheduling with options
105
+ ```javascript
106
+ // Run a function each second, limit to five runs
107
+ Cron('* * * * * *', { maxRuns: 5 }, function () {
108
+ console.log('This will run each second, but only five times.');
109
+ });
110
+ ```
111
+
112
+ ### Minimalist scheduling with job controls
113
+ ```javascript
114
+ // Run a function each second, get reference to job
115
+ var job = Cron('* * * * * *', function () {
116
+ console.log('This will run each second.');
117
+ });
118
+
119
+ // Pause job
120
+ job.pause();
121
+
122
+ // Resume job
123
+ job.resume();
124
+
125
+ // Stop job
126
+ job.stop();
127
+
128
+ ```
129
+
130
+ ### Basic scheduling
131
+ ```javascript
132
+
133
+ // Run every minute
134
+ var scheduler = Cron('0 * * * * *');
135
+
136
+ scheduler.schedule(function() {
137
+ console.log('This will run every minute');
138
+ });
139
+ ```
140
+
141
+ ### Scheduling with options
142
+ ```javascript
143
+
144
+ // Run every minute
145
+ var scheduler = Cron('0 * * * * *');
146
+
147
+ // Schedule with options (all options are optional)
148
+ scheduler.schedule({ maxRuns: 5 }, function() {
149
+ console.log('This will run every minute.');
150
+ });
151
+ ```
152
+ ### Scheduling with job controls
153
+ ```javascript
154
+
155
+ // Run every minute
156
+ var scheduler = Cron('0 * * * * *');
157
+
158
+ // Schedule with options (all options are optional)
159
+ var job = scheduler.schedule({ maxRuns: 5 }, function() {
160
+ console.log('This will run every minute.');
161
+ });
162
+
163
+ // Pause job
164
+ job.pause();
165
+
166
+ // Resume job
167
+ job.resume();
168
+
169
+ // Stop job
170
+ job.stop();
171
+ ```
172
+
173
+ ## Full API
174
+ ```javascript
175
+
176
+ var o = Cron( <string pattern> [, <object options>] [, <function callback> ] );
177
+ ```
178
+ ```javascript
179
+ // If Cron is initialized without a scheduled function, cron itself is returned
180
+ // and the following member functions is available.
181
+ o.next( [ <date previous> ] );
182
+ o.msToNext();
183
+ o.previous();
184
+
185
+ // If Cron is initialized _with_ a scheduled function, the job is retured instead.
186
+ // Otherwise you get a reference to the job when scheduling a new job.
187
+ var job = o.schedule( [ { startAt: <date|string>, stopAt: <date|string>, maxRuns: <integer>, timezone: <string> } ,] callback);
188
+
189
+ // These self-explanatory functions is available to control the job
190
+ job.pause();
191
+ job.resume();
192
+ job.stop();
193
+
194
+ ```
195
+
196
+ ## Pattern
197
+
198
+ ```
199
+ ┌──────────────── (optional) second (0 - 59)
200
+ │ ┌────────────── minute (0 - 59)
201
+ │ │ ┌──────────── hour (0 - 23)
202
+ │ │ │ ┌────────── day of month (1 - 31)
203
+ │ │ │ │ ┌──────── month (1 - 12)
204
+ │ │ │ │ │ ┌────── day of week (0 - 6)
205
+ │ │ │ │ │ │ (0 to 6 are Sunday to Saturday; 7 is Sunday, the same as 0)
206
+ │ │ │ │ │ │
207
+ * * * * * *
208
+ ```
209
+
210
+ ## License
211
+
212
212
  MIT
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Cron=e():t.Cron=e()}(this,(function(){return(()=>{"use strict";var t={d:(e,s)=>{for(var r in s)t.o(s,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:s[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>l});const s=Math.pow(2,31)-1;function r(t){throw new TypeError("Cron parser: "+t)}function n(t,e){for(let s=0;s<t.length;s++)t[s]=e;return t}function o(t){this.milliseconds=t.getMilliseconds(),this.seconds=t.getSeconds(),this.minutes=t.getMinutes(),this.hours=t.getHours(),this.days=t.getDate(),this.months=t.getMonth(),this.years=t.getFullYear()}function i(t){this.pattern=t,this.seconds=n(Array(60),0),this.minutes=n(Array(60),0),this.hours=n(Array(24),0),this.days=n(Array(31),0),this.months=n(Array(12),0),this.daysOfWeek=n(Array(8),0),this.parse()}function a(t,e,s){let r=this;return this instanceof a?(r.pattern=new i(t),r.schedulerDefaults={stopAt:1/0,maxRuns:1/0,kill:!1},"function"==typeof e&&(s=e,e={}),r.opts=r.validateOpts(e||{}),void 0===s?r:this.schedule(e,s)):new a(t,e,s)}o.prototype.increment=function(t){this.seconds+=1,this.milliseconds=0;let e=this,s=function(t,s,r,n){for(let o=void 0===n?e[t]+r:0+r;o<s[t].length;o++)if(s[t][o])return e[t]=o-r,!0;return!1},r=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]],n=0;for(;n<5;){if(!s(r[n][0],t,r[n][2]))for(this[r[n][1]]++;n>=0;)s(r[n][0],t,r[n][2],0),n--;n++}for(;!t.daysOfWeek[this.getDate().getDay()];)this.days+=1},o.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds)},i.prototype.parse=function(){"string"!=typeof this.pattern&&this.pattern.constructor!==String&&r("Pattern has to be of type string.");let t,e,s,n,o,i=this.pattern.trim().replace(/\s+/g," ").split(" "),a=/[^/*0-9,-]+/;for((i.length<5||i.length>6)&&r("invalid configuration format ('"+this.pattern+"'), exacly five or six space separated parts required."),5==i.length&&i.unshift("0"),e=0;e<i.length;e++)t=i[e].trim(),a.test(t)&&r("configuration entry "+(e+1)+" ("+t+") contains illegal characters.");s="*"!==i[4],n="*"!==i[5],o="*"!==i[3],n&&(s||o)&&r("configuration invalid, you can not combine month/date with day of week."),this.partToArray("seconds",i[0],0),this.partToArray("minutes",i[1],0),this.partToArray("hours",i[2],0),this.partToArray("days",i[3],-1),this.partToArray("months",i[4],-1),this.partToArray("daysOfWeek",i[5],0),this.daysOfWeek[7]&&(this.daysOfWeek[0]=1)},i.prototype.partToArray=function(t,e,s){let n,o,i,a,l,u=this[t];if("*"!==e)if(o=e.split(","),o.length>1)for(n=0;n<o.length;n++)this.partToArray(t,o[n],s);else if(-1!==e.indexOf("-"))for(o=e.split("-"),2!==o.length&&r("Syntax error, illegal range: '"+e+"'"),i=parseInt(o[0],10)+s,a=parseInt(o[1],10)+s,isNaN(i)?r("Syntax error, illegal lower range (NaN)"):isNaN(a)&&r("Syntax error, illegal upper range (NaN)"),(i<0||a>=u.length)&&r("Value out of range: '"+e+"'"),i>a&&r("From value is larger than to value: '"+e+"'"),n=i;n<=a;n++)u[n+s]=1;else if(-1!==e.indexOf("/"))for(o=e.split("/"),2!==o.length&&r("Syntax error, illegal stepping: '"+e+"'"),"*"!==o[0]&&r("Syntax error, left part of / needs to be * : '"+e+"'"),l=parseInt(o[1],10),isNaN(l)&&r("Syntax error, illegal stepping: (NaN)"),0===l&&r("Syntax error, illegal stepping: 0"),l>u.length&&r("Syntax error, steps cannot be greater than maximum value of part ("+u.length+")"),n=0;n<u.length;n+=l)u[n+s]=1;else n=parseInt(e,10)+s,(n<0||n>=u.length)&&r(t+" value out of range: '"+e+"'"),u[n]=1;else for(n=0;n<u.length;n++)u[n]=1},a.prototype.next=function(t){let e=this._next(t);return e&&e.setMilliseconds(0),e},a.prototype.previous=function(){return this.opts.previous},a.prototype._next=function(t){if(t=t||new Date,this.opts.startAt&&t<this.opts.startAt&&(t=this.opts.startAt),this.opts.maxRuns<=0||this.opts.kill)return;let e,s=this.opts.stopAt||this.schedulerDefaults.stopAt,r=new o(t);return r.increment(this.pattern),e=r.getDate(),s&&e>=s?void 0:e},a.prototype.validateOpts=function(t){return t.startAt&&(t.startAt.constructor!==Date?t.startAt=new Date(Date.parse(t.startAt)-1):t.startAt=new Date(t.startAt.getTime()-1),isNaN(t.startAt)&&r("Provided value for startAt could not be parsed as date.")),t.stopAt&&(t.stopAt.constructor!==Date&&(t.stopAt=new Date(Date.parse(t.stopAt))),isNaN(t.stopAt)&&r("Provided value for stopAt could not be parsed as date.")),t},a.prototype.msToNext=function(t){t=t||new Date;let e=this._next(t);return e?this._next(t)-t.getTime():e},a.prototype.schedule=function(t,e){let r,n=this,o=n.maxDelay||s;if(e||(e=t,t={}),t.paused=void 0!==t.paused&&t.paused,t.kill=t.kill||this.schedulerDefaults.kill,t.rest=t.rest||0,t.maxRuns||0===t.maxRuns||(t.maxRuns=this.schedulerDefaults.maxRuns),n.opts=n.validateOpts(t||{}),r=this.msToNext(t.previous),void 0!==r)return r>o&&(r=o),t.currentTimeout=setTimeout((function(){r!==o&&(t.paused||(t.maxRuns--,e()),t.previous=new Date),n.schedule(t,e)}),r),{stop:function(){t.kill=!0,t.currentTimeout&&clearTimeout(t.currentTimeout)},pause:function(){return(t.paused=!0)&&!t.kill},resume:function(){return!(t.paused=!1)&&!t.kill}}};const l=a;return e.default})()}));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Cron=e():t.Cron=e()}(this,(function(){return(()=>{"use strict";var t={d:(e,r)=>{for(var s in r)t.o(r,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:r[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>i});function r(t,e){if(this.timezone=e,t&&t instanceof Date)this.fromDate(t);else if(void 0===t)this.fromDate(new Date);else if(t&&"string"==typeof t)this.fromString(t);else{if(!(t instanceof r))throw new TypeError("CronDate: Invalid type passed as parameter to CronDate constructor");this.fromCronDate(t)}}function s(t){this.pattern=t,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()}r.prototype.fromDate=function(t){let e=t.getTime();this.timezone&&(t=function(t,e){return new Date(t.toLocaleString("en-US",{timeZone:e}))}(t,this.timezone));let r=t.getTime();this.UTCmsOffset=r-e,this.milliseconds=t.getMilliseconds(),this.seconds=t.getSeconds(),this.minutes=t.getMinutes(),this.hours=t.getHours(),this.days=t.getDate(),this.months=t.getMonth(),this.years=t.getFullYear()},r.prototype.fromCronDate=function(t){this.UTCmsOffset=t.UTCmsOffset,this.milliseconds=t.milliseconds,this.seconds=t.seconds,this.minutes=t.minutes,this.hours=t.hours,this.days=t.days,this.months=t.months,this.years=t.years},r.prototype.fromString=function(t){let e=Date.parse(t);if(isNaN(e))throw new TypeError("CronDate: Provided string value for CronDate could not be parsed as date.");this.fromDate(new Date(e))},r.prototype.increment=function(t){this.seconds+=1,this.milliseconds=0;let e=this,r=function(t,r,s,o){for(let n=void 0===o?e[t]+s:0+s;n<r[t].length;n++)if(r[t][n])return e[t]=n-s,!0;return!1},s=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]],o=0;for(;o<5;){if(!r(s[o][0],t,s[o][2]))for(this[s[o][1]]++;o>=0;)r(s[o][0],t,s[o][2],0),o--;o++}for(;!t.daysOfWeek[this.getDate().getDay()];)this.days+=1;return this},r.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds-this.UTCmsOffset)},r.prototype.getTime=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds-this.UTCmsOffset).getTime()},s.prototype.parse=function(){if("string"!=typeof this.pattern&&this.pattern.constructor!==String)throw new TypeError("CronPattern: Pattern has to be of type string.");let t,e,r,s,o,n=this.pattern.trim().replace(/\s+/g," ").split(" "),i=/[^/*0-9,-]+/;if(n.length<5||n.length>6)throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exacly five or six space separated parts required.");for(5===n.length&&n.unshift("0"),e=0;e<n.length;e++)if(t=n[e].trim(),i.test(t))throw new TypeError("CronPattern: configuration entry "+(e+1)+" ("+t+") contains illegal characters.");if(r="*"!==n[4],s="*"!==n[5],o="*"!==n[3],s&&(r||o))throw new TypeError("CronPattern: configuration invalid, you can not combine month/date with day of week.");this.partToArray("seconds",n[0],0),this.partToArray("minutes",n[1],0),this.partToArray("hours",n[2],0),this.partToArray("days",n[3],-1),this.partToArray("months",n[4],-1),this.partToArray("daysOfWeek",n[5],0),this.daysOfWeek[7]&&(this.daysOfWeek[0]=1)},s.prototype.partToArray=function(t,e,r){let s,o,n,i,a,h=this[t];if("*"!==e)if(o=e.split(","),o.length>1)for(s=0;s<o.length;s++)this.partToArray(t,o[s],r);else if(-1!==e.indexOf("-")){if(o=e.split("-"),2!==o.length)throw new TypeError("CronPattern: Syntax error, illegal range: '"+e+"'");if(n=parseInt(o[0],10)+r,i=parseInt(o[1],10)+r,isNaN(n))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(i))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(n<0||i>=h.length)throw new TypeError("CronPattern: Value out of range: '"+e+"'");if(n>i)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(s=n;s<=i;s++)h[s+r]=1}else if(-1!==e.indexOf("/")){if(o=e.split("/"),2!==o.length)throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+e+"'");if("*"!==o[0])throw new TypeError("CronPattern: Syntax error, left part of / needs to be * : '"+e+"'");if(a=parseInt(o[1],10),isNaN(a))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(0===a)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(a>h.length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+h.length+")");for(s=0;s<h.length;s+=a)h[s+r]=1}else{if(s=parseInt(e,10)+r,s<0||s>=h.length)throw new TypeError("CronPattern: "+t+" value out of range: '"+e+"'");h[s]=1}else for(s=0;s<h.length;s++)h[s]=1};const o=Math.pow(2,31)-1;function n(t,e,r){let o=this;return this instanceof n?(o.pattern=new s(t),o.schedulerDefaults={maxRuns:1/0,kill:!1},"function"==typeof e&&(r=e,e={}),o.opts=o.validateOpts(e||{}),void 0===r?o:this.schedule(e,r)):new n(t,e,r)}n.prototype.next=function(t){let e=this._next(t);return e?e.getDate():null},n.prototype.previous=function(){return this.opts.previous?this.opts.previous.getDate():null},n.prototype._next=function(t){t=new r(t,this.opts.timezone),this.opts.startAt&&t&&t.getTime()<this.opts.startAt.getTime()&&(t=new r(this.opts.startAt,this.opts.timezone));let e=new r(t,this.opts.timezone).increment(this.pattern);return this.opts.maxRuns<=0||this.opts.kill||this.opts.stopAt&&e.getTime()>=this.opts.stopAt.getTime()?null:e},n.prototype.validateOpts=function(t){return t.startAt&&(t.startAt=new r(t.startAt,t.timezone)),t.stopAt&&(t.stopAt=new r(t.stopAt,t.timezone)),t},n.prototype.msToNext=function(t){t=t||new r(void 0,this.opts.timezone);let e=this._next(t);return e?e.getTime()-t.getTime():null},n.prototype.schedule=function(t,e){e||(e=t,t=this.opts),t.paused=void 0!==t.paused&&t.paused,t.kill=t.kill||this.schedulerDefaults.kill,t.maxRuns||0===t.maxRuns||(t.maxRuns=this.schedulerDefaults.maxRuns),this.opts=this.validateOpts(t||{}),this._schedule(t,e)},n.prototype._schedule=function(t,e){let s,n=this,i=n.maxDelay||o;if(s=this.msToNext(n.opts.previous),null!==s)return s>i&&(s=i),n.opts.currentTimeout=setTimeout((function(){s!==i&&(n.opts.paused||(n.opts.maxRuns--,e()),n.opts.previous=new r(n.opts.previous,n.opts.timezone)),n._schedule(n.opts,e)}),s),{stop:function(){n.opts.kill=!0,n.opts.currentTimeout&&clearTimeout(n.opts.currentTimeout)},pause:function(){return(n.opts.paused=!0)&&!n.opts.kill},resume:function(){return!(n.opts.paused=!1)&&!n.opts.kill}}};const i=n;return e.default})()}));
@@ -1 +1 @@
1
- var t={d:(e,s)=>{for(var r in s)t.o(s,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:s[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{Z:()=>l,P:()=>i});const s=Math.pow(2,31)-1;function r(t){throw new TypeError("Cron parser: "+t)}function n(t,e){for(let s=0;s<t.length;s++)t[s]=e;return t}function a(t){this.milliseconds=t.getMilliseconds(),this.seconds=t.getSeconds(),this.minutes=t.getMinutes(),this.hours=t.getHours(),this.days=t.getDate(),this.months=t.getMonth(),this.years=t.getFullYear()}function o(t){this.pattern=t,this.seconds=n(Array(60),0),this.minutes=n(Array(60),0),this.hours=n(Array(24),0),this.days=n(Array(31),0),this.months=n(Array(12),0),this.daysOfWeek=n(Array(8),0),this.parse()}function i(t,e,s){let r=this;return this instanceof i?(r.pattern=new o(t),r.schedulerDefaults={stopAt:1/0,maxRuns:1/0,kill:!1},"function"==typeof e&&(s=e,e={}),r.opts=r.validateOpts(e||{}),void 0===s?r:this.schedule(e,s)):new i(t,e,s)}a.prototype.increment=function(t){this.seconds+=1,this.milliseconds=0;let e=this,s=function(t,s,r,n){for(let a=void 0===n?e[t]+r:0+r;a<s[t].length;a++)if(s[t][a])return e[t]=a-r,!0;return!1},r=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]],n=0;for(;n<5;){if(!s(r[n][0],t,r[n][2]))for(this[r[n][1]]++;n>=0;)s(r[n][0],t,r[n][2],0),n--;n++}for(;!t.daysOfWeek[this.getDate().getDay()];)this.days+=1},a.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds)},o.prototype.parse=function(){"string"!=typeof this.pattern&&this.pattern.constructor!==String&&r("Pattern has to be of type string.");let t,e,s,n,a,o=this.pattern.trim().replace(/\s+/g," ").split(" "),i=/[^/*0-9,-]+/;for((o.length<5||o.length>6)&&r("invalid configuration format ('"+this.pattern+"'), exacly five or six space separated parts required."),5==o.length&&o.unshift("0"),e=0;e<o.length;e++)t=o[e].trim(),i.test(t)&&r("configuration entry "+(e+1)+" ("+t+") contains illegal characters.");s="*"!==o[4],n="*"!==o[5],a="*"!==o[3],n&&(s||a)&&r("configuration invalid, you can not combine month/date with day of week."),this.partToArray("seconds",o[0],0),this.partToArray("minutes",o[1],0),this.partToArray("hours",o[2],0),this.partToArray("days",o[3],-1),this.partToArray("months",o[4],-1),this.partToArray("daysOfWeek",o[5],0),this.daysOfWeek[7]&&(this.daysOfWeek[0]=1)},o.prototype.partToArray=function(t,e,s){let n,a,o,i,l,u=this[t];if("*"!==e)if(a=e.split(","),a.length>1)for(n=0;n<a.length;n++)this.partToArray(t,a[n],s);else if(-1!==e.indexOf("-"))for(a=e.split("-"),2!==a.length&&r("Syntax error, illegal range: '"+e+"'"),o=parseInt(a[0],10)+s,i=parseInt(a[1],10)+s,isNaN(o)?r("Syntax error, illegal lower range (NaN)"):isNaN(i)&&r("Syntax error, illegal upper range (NaN)"),(o<0||i>=u.length)&&r("Value out of range: '"+e+"'"),o>i&&r("From value is larger than to value: '"+e+"'"),n=o;n<=i;n++)u[n+s]=1;else if(-1!==e.indexOf("/"))for(a=e.split("/"),2!==a.length&&r("Syntax error, illegal stepping: '"+e+"'"),"*"!==a[0]&&r("Syntax error, left part of / needs to be * : '"+e+"'"),l=parseInt(a[1],10),isNaN(l)&&r("Syntax error, illegal stepping: (NaN)"),0===l&&r("Syntax error, illegal stepping: 0"),l>u.length&&r("Syntax error, steps cannot be greater than maximum value of part ("+u.length+")"),n=0;n<u.length;n+=l)u[n+s]=1;else n=parseInt(e,10)+s,(n<0||n>=u.length)&&r(t+" value out of range: '"+e+"'"),u[n]=1;else for(n=0;n<u.length;n++)u[n]=1},i.prototype.next=function(t){let e=this._next(t);return e&&e.setMilliseconds(0),e},i.prototype.previous=function(){return this.opts.previous},i.prototype._next=function(t){if(t=t||new Date,this.opts.startAt&&t<this.opts.startAt&&(t=this.opts.startAt),this.opts.maxRuns<=0||this.opts.kill)return;let e,s=this.opts.stopAt||this.schedulerDefaults.stopAt,r=new a(t);return r.increment(this.pattern),e=r.getDate(),s&&e>=s?void 0:e},i.prototype.validateOpts=function(t){return t.startAt&&(t.startAt.constructor!==Date?t.startAt=new Date(Date.parse(t.startAt)-1):t.startAt=new Date(t.startAt.getTime()-1),isNaN(t.startAt)&&r("Provided value for startAt could not be parsed as date.")),t.stopAt&&(t.stopAt.constructor!==Date&&(t.stopAt=new Date(Date.parse(t.stopAt))),isNaN(t.stopAt)&&r("Provided value for stopAt could not be parsed as date.")),t},i.prototype.msToNext=function(t){t=t||new Date;let e=this._next(t);return e?this._next(t)-t.getTime():e},i.prototype.schedule=function(t,e){let r,n=this,a=n.maxDelay||s;if(e||(e=t,t={}),t.paused=void 0!==t.paused&&t.paused,t.kill=t.kill||this.schedulerDefaults.kill,t.rest=t.rest||0,t.maxRuns||0===t.maxRuns||(t.maxRuns=this.schedulerDefaults.maxRuns),n.opts=n.validateOpts(t||{}),r=this.msToNext(t.previous),void 0!==r)return r>a&&(r=a),t.currentTimeout=setTimeout((function(){r!==a&&(t.paused||(t.maxRuns--,e()),t.previous=new Date),n.schedule(t,e)}),r),{stop:function(){t.kill=!0,t.currentTimeout&&clearTimeout(t.currentTimeout)},pause:function(){return(t.paused=!0)&&!t.kill},resume:function(){return!(t.paused=!1)&&!t.kill}}};const l=i;var u=e.P,p=e.Z;export{u as Cron,p as default};
1
+ var t={d:(e,r)=>{for(var s in r)t.o(r,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:r[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{P:()=>n,Z:()=>i});function r(t,e){if(this.timezone=e,t&&t instanceof Date)this.fromDate(t);else if(void 0===t)this.fromDate(new Date);else if(t&&"string"==typeof t)this.fromString(t);else{if(!(t instanceof r))throw new TypeError("CronDate: Invalid type passed as parameter to CronDate constructor");this.fromCronDate(t)}}function s(t){this.pattern=t,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()}r.prototype.fromDate=function(t){let e=t.getTime();this.timezone&&(t=function(t,e){return new Date(t.toLocaleString("en-US",{timeZone:e}))}(t,this.timezone));let r=t.getTime();this.UTCmsOffset=r-e,this.milliseconds=t.getMilliseconds(),this.seconds=t.getSeconds(),this.minutes=t.getMinutes(),this.hours=t.getHours(),this.days=t.getDate(),this.months=t.getMonth(),this.years=t.getFullYear()},r.prototype.fromCronDate=function(t){this.UTCmsOffset=t.UTCmsOffset,this.milliseconds=t.milliseconds,this.seconds=t.seconds,this.minutes=t.minutes,this.hours=t.hours,this.days=t.days,this.months=t.months,this.years=t.years},r.prototype.fromString=function(t){let e=Date.parse(t);if(isNaN(e))throw new TypeError("CronDate: Provided string value for CronDate could not be parsed as date.");this.fromDate(new Date(e))},r.prototype.increment=function(t){this.seconds+=1,this.milliseconds=0;let e=this,r=function(t,r,s,o){for(let n=void 0===o?e[t]+s:0+s;n<r[t].length;n++)if(r[t][n])return e[t]=n-s,!0;return!1},s=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]],o=0;for(;o<5;){if(!r(s[o][0],t,s[o][2]))for(this[s[o][1]]++;o>=0;)r(s[o][0],t,s[o][2],0),o--;o++}for(;!t.daysOfWeek[this.getDate().getDay()];)this.days+=1;return this},r.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds-this.UTCmsOffset)},r.prototype.getTime=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds-this.UTCmsOffset).getTime()},s.prototype.parse=function(){if("string"!=typeof this.pattern&&this.pattern.constructor!==String)throw new TypeError("CronPattern: Pattern has to be of type string.");let t,e,r,s,o,n=this.pattern.trim().replace(/\s+/g," ").split(" "),i=/[^/*0-9,-]+/;if(n.length<5||n.length>6)throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exacly five or six space separated parts required.");for(5===n.length&&n.unshift("0"),e=0;e<n.length;e++)if(t=n[e].trim(),i.test(t))throw new TypeError("CronPattern: configuration entry "+(e+1)+" ("+t+") contains illegal characters.");if(r="*"!==n[4],s="*"!==n[5],o="*"!==n[3],s&&(r||o))throw new TypeError("CronPattern: configuration invalid, you can not combine month/date with day of week.");this.partToArray("seconds",n[0],0),this.partToArray("minutes",n[1],0),this.partToArray("hours",n[2],0),this.partToArray("days",n[3],-1),this.partToArray("months",n[4],-1),this.partToArray("daysOfWeek",n[5],0),this.daysOfWeek[7]&&(this.daysOfWeek[0]=1)},s.prototype.partToArray=function(t,e,r){let s,o,n,i,a,h=this[t];if("*"!==e)if(o=e.split(","),o.length>1)for(s=0;s<o.length;s++)this.partToArray(t,o[s],r);else if(-1!==e.indexOf("-")){if(o=e.split("-"),2!==o.length)throw new TypeError("CronPattern: Syntax error, illegal range: '"+e+"'");if(n=parseInt(o[0],10)+r,i=parseInt(o[1],10)+r,isNaN(n))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(i))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(n<0||i>=h.length)throw new TypeError("CronPattern: Value out of range: '"+e+"'");if(n>i)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(s=n;s<=i;s++)h[s+r]=1}else if(-1!==e.indexOf("/")){if(o=e.split("/"),2!==o.length)throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+e+"'");if("*"!==o[0])throw new TypeError("CronPattern: Syntax error, left part of / needs to be * : '"+e+"'");if(a=parseInt(o[1],10),isNaN(a))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(0===a)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(a>h.length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+h.length+")");for(s=0;s<h.length;s+=a)h[s+r]=1}else{if(s=parseInt(e,10)+r,s<0||s>=h.length)throw new TypeError("CronPattern: "+t+" value out of range: '"+e+"'");h[s]=1}else for(s=0;s<h.length;s++)h[s]=1};const o=Math.pow(2,31)-1;function n(t,e,r){let o=this;return this instanceof n?(o.pattern=new s(t),o.schedulerDefaults={maxRuns:1/0,kill:!1},"function"==typeof e&&(r=e,e={}),o.opts=o.validateOpts(e||{}),void 0===r?o:this.schedule(e,r)):new n(t,e,r)}n.prototype.next=function(t){let e=this._next(t);return e?e.getDate():null},n.prototype.previous=function(){return this.opts.previous?this.opts.previous.getDate():null},n.prototype._next=function(t){t=new r(t,this.opts.timezone),this.opts.startAt&&t&&t.getTime()<this.opts.startAt.getTime()&&(t=new r(this.opts.startAt,this.opts.timezone));let e=new r(t,this.opts.timezone).increment(this.pattern);return this.opts.maxRuns<=0||this.opts.kill||this.opts.stopAt&&e.getTime()>=this.opts.stopAt.getTime()?null:e},n.prototype.validateOpts=function(t){return t.startAt&&(t.startAt=new r(t.startAt,t.timezone)),t.stopAt&&(t.stopAt=new r(t.stopAt,t.timezone)),t},n.prototype.msToNext=function(t){t=t||new r(void 0,this.opts.timezone);let e=this._next(t);return e?e.getTime()-t.getTime():null},n.prototype.schedule=function(t,e){e||(e=t,t=this.opts),t.paused=void 0!==t.paused&&t.paused,t.kill=t.kill||this.schedulerDefaults.kill,t.maxRuns||0===t.maxRuns||(t.maxRuns=this.schedulerDefaults.maxRuns),this.opts=this.validateOpts(t||{}),this._schedule(t,e)},n.prototype._schedule=function(t,e){let s,n=this,i=n.maxDelay||o;if(s=this.msToNext(n.opts.previous),null!==s)return s>i&&(s=i),n.opts.currentTimeout=setTimeout((function(){s!==i&&(n.opts.paused||(n.opts.maxRuns--,e()),n.opts.previous=new r(n.opts.previous,n.opts.timezone)),n._schedule(n.opts,e)}),s),{stop:function(){n.opts.kill=!0,n.opts.currentTimeout&&clearTimeout(n.opts.currentTimeout)},pause:function(){return(n.opts.paused=!0)&&!n.opts.kill},resume:function(){return!(n.opts.paused=!1)&&!n.opts.kill}}};const i=n;var a=e.P,h=e.Z;export{a as Cron,h as default};
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Cron=e():t.Cron=e()}(this,(function(){return(()=>{"use strict";var t={d:(e,s)=>{for(var r in s)t.o(s,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:s[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>l});const s=Math.pow(2,31)-1;function r(t){throw new TypeError("Cron parser: "+t)}function n(t,e){for(let s=0;s<t.length;s++)t[s]=e;return t}function o(t){this.milliseconds=t.getMilliseconds(),this.seconds=t.getSeconds(),this.minutes=t.getMinutes(),this.hours=t.getHours(),this.days=t.getDate(),this.months=t.getMonth(),this.years=t.getFullYear()}function i(t){this.pattern=t,this.seconds=n(Array(60),0),this.minutes=n(Array(60),0),this.hours=n(Array(24),0),this.days=n(Array(31),0),this.months=n(Array(12),0),this.daysOfWeek=n(Array(8),0),this.parse()}function a(t,e,s){let r=this;return this instanceof a?(r.pattern=new i(t),r.schedulerDefaults={stopAt:1/0,maxRuns:1/0,kill:!1},"function"==typeof e&&(s=e,e={}),r.opts=r.validateOpts(e||{}),void 0===s?r:this.schedule(e,s)):new a(t,e,s)}o.prototype.increment=function(t){this.seconds+=1,this.milliseconds=0;let e=this,s=function(t,s,r,n){for(let o=void 0===n?e[t]+r:0+r;o<s[t].length;o++)if(s[t][o])return e[t]=o-r,!0;return!1},r=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]],n=0;for(;n<5;){if(!s(r[n][0],t,r[n][2]))for(this[r[n][1]]++;n>=0;)s(r[n][0],t,r[n][2],0),n--;n++}for(;!t.daysOfWeek[this.getDate().getDay()];)this.days+=1},o.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds)},i.prototype.parse=function(){"string"!=typeof this.pattern&&this.pattern.constructor!==String&&r("Pattern has to be of type string.");let t,e,s,n,o,i=this.pattern.trim().replace(/\s+/g," ").split(" "),a=/[^/*0-9,-]+/;for((i.length<5||i.length>6)&&r("invalid configuration format ('"+this.pattern+"'), exacly five or six space separated parts required."),5==i.length&&i.unshift("0"),e=0;e<i.length;e++)t=i[e].trim(),a.test(t)&&r("configuration entry "+(e+1)+" ("+t+") contains illegal characters.");s="*"!==i[4],n="*"!==i[5],o="*"!==i[3],n&&(s||o)&&r("configuration invalid, you can not combine month/date with day of week."),this.partToArray("seconds",i[0],0),this.partToArray("minutes",i[1],0),this.partToArray("hours",i[2],0),this.partToArray("days",i[3],-1),this.partToArray("months",i[4],-1),this.partToArray("daysOfWeek",i[5],0),this.daysOfWeek[7]&&(this.daysOfWeek[0]=1)},i.prototype.partToArray=function(t,e,s){let n,o,i,a,l,u=this[t];if("*"!==e)if(o=e.split(","),o.length>1)for(n=0;n<o.length;n++)this.partToArray(t,o[n],s);else if(-1!==e.indexOf("-"))for(o=e.split("-"),2!==o.length&&r("Syntax error, illegal range: '"+e+"'"),i=parseInt(o[0],10)+s,a=parseInt(o[1],10)+s,isNaN(i)?r("Syntax error, illegal lower range (NaN)"):isNaN(a)&&r("Syntax error, illegal upper range (NaN)"),(i<0||a>=u.length)&&r("Value out of range: '"+e+"'"),i>a&&r("From value is larger than to value: '"+e+"'"),n=i;n<=a;n++)u[n+s]=1;else if(-1!==e.indexOf("/"))for(o=e.split("/"),2!==o.length&&r("Syntax error, illegal stepping: '"+e+"'"),"*"!==o[0]&&r("Syntax error, left part of / needs to be * : '"+e+"'"),l=parseInt(o[1],10),isNaN(l)&&r("Syntax error, illegal stepping: (NaN)"),0===l&&r("Syntax error, illegal stepping: 0"),l>u.length&&r("Syntax error, steps cannot be greater than maximum value of part ("+u.length+")"),n=0;n<u.length;n+=l)u[n+s]=1;else n=parseInt(e,10)+s,(n<0||n>=u.length)&&r(t+" value out of range: '"+e+"'"),u[n]=1;else for(n=0;n<u.length;n++)u[n]=1},a.prototype.next=function(t){let e=this._next(t);return e&&e.setMilliseconds(0),e},a.prototype.previous=function(){return this.opts.previous},a.prototype._next=function(t){if(t=t||new Date,this.opts.startAt&&t<this.opts.startAt&&(t=this.opts.startAt),this.opts.maxRuns<=0||this.opts.kill)return;let e,s=this.opts.stopAt||this.schedulerDefaults.stopAt,r=new o(t);return r.increment(this.pattern),e=r.getDate(),s&&e>=s?void 0:e},a.prototype.validateOpts=function(t){return t.startAt&&(t.startAt.constructor!==Date?t.startAt=new Date(Date.parse(t.startAt)-1):t.startAt=new Date(t.startAt.getTime()-1),isNaN(t.startAt)&&r("Provided value for startAt could not be parsed as date.")),t.stopAt&&(t.stopAt.constructor!==Date&&(t.stopAt=new Date(Date.parse(t.stopAt))),isNaN(t.stopAt)&&r("Provided value for stopAt could not be parsed as date.")),t},a.prototype.msToNext=function(t){t=t||new Date;let e=this._next(t);return e?this._next(t)-t.getTime():e},a.prototype.schedule=function(t,e){let r,n=this,o=n.maxDelay||s;if(e||(e=t,t={}),t.paused=void 0!==t.paused&&t.paused,t.kill=t.kill||this.schedulerDefaults.kill,t.rest=t.rest||0,t.maxRuns||0===t.maxRuns||(t.maxRuns=this.schedulerDefaults.maxRuns),n.opts=n.validateOpts(t||{}),r=this.msToNext(t.previous),void 0!==r)return r>o&&(r=o),t.currentTimeout=setTimeout((function(){r!==o&&(t.paused||(t.maxRuns--,e()),t.previous=new Date),n.schedule(t,e)}),r),{stop:function(){t.kill=!0,t.currentTimeout&&clearTimeout(t.currentTimeout)},pause:function(){return(t.paused=!0)&&!t.kill},resume:function(){return!(t.paused=!1)&&!t.kill}}};const l=a;return e.default})()}));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Cron=e():t.Cron=e()}(this,(function(){return(()=>{"use strict";var t={d:(e,r)=>{for(var s in r)t.o(r,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:r[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>i});function r(t,e){if(this.timezone=e,t&&t instanceof Date)this.fromDate(t);else if(void 0===t)this.fromDate(new Date);else if(t&&"string"==typeof t)this.fromString(t);else{if(!(t instanceof r))throw new TypeError("CronDate: Invalid type passed as parameter to CronDate constructor");this.fromCronDate(t)}}function s(t){this.pattern=t,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()}r.prototype.fromDate=function(t){let e=t.getTime();this.timezone&&(t=function(t,e){return new Date(t.toLocaleString("en-US",{timeZone:e}))}(t,this.timezone));let r=t.getTime();this.UTCmsOffset=r-e,this.milliseconds=t.getMilliseconds(),this.seconds=t.getSeconds(),this.minutes=t.getMinutes(),this.hours=t.getHours(),this.days=t.getDate(),this.months=t.getMonth(),this.years=t.getFullYear()},r.prototype.fromCronDate=function(t){this.UTCmsOffset=t.UTCmsOffset,this.milliseconds=t.milliseconds,this.seconds=t.seconds,this.minutes=t.minutes,this.hours=t.hours,this.days=t.days,this.months=t.months,this.years=t.years},r.prototype.fromString=function(t){let e=Date.parse(t);if(isNaN(e))throw new TypeError("CronDate: Provided string value for CronDate could not be parsed as date.");this.fromDate(new Date(e))},r.prototype.increment=function(t){this.seconds+=1,this.milliseconds=0;let e=this,r=function(t,r,s,o){for(let n=void 0===o?e[t]+s:0+s;n<r[t].length;n++)if(r[t][n])return e[t]=n-s,!0;return!1},s=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]],o=0;for(;o<5;){if(!r(s[o][0],t,s[o][2]))for(this[s[o][1]]++;o>=0;)r(s[o][0],t,s[o][2],0),o--;o++}for(;!t.daysOfWeek[this.getDate().getDay()];)this.days+=1;return this},r.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds-this.UTCmsOffset)},r.prototype.getTime=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds-this.UTCmsOffset).getTime()},s.prototype.parse=function(){if("string"!=typeof this.pattern&&this.pattern.constructor!==String)throw new TypeError("CronPattern: Pattern has to be of type string.");let t,e,r,s,o,n=this.pattern.trim().replace(/\s+/g," ").split(" "),i=/[^/*0-9,-]+/;if(n.length<5||n.length>6)throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exacly five or six space separated parts required.");for(5===n.length&&n.unshift("0"),e=0;e<n.length;e++)if(t=n[e].trim(),i.test(t))throw new TypeError("CronPattern: configuration entry "+(e+1)+" ("+t+") contains illegal characters.");if(r="*"!==n[4],s="*"!==n[5],o="*"!==n[3],s&&(r||o))throw new TypeError("CronPattern: configuration invalid, you can not combine month/date with day of week.");this.partToArray("seconds",n[0],0),this.partToArray("minutes",n[1],0),this.partToArray("hours",n[2],0),this.partToArray("days",n[3],-1),this.partToArray("months",n[4],-1),this.partToArray("daysOfWeek",n[5],0),this.daysOfWeek[7]&&(this.daysOfWeek[0]=1)},s.prototype.partToArray=function(t,e,r){let s,o,n,i,a,h=this[t];if("*"!==e)if(o=e.split(","),o.length>1)for(s=0;s<o.length;s++)this.partToArray(t,o[s],r);else if(-1!==e.indexOf("-")){if(o=e.split("-"),2!==o.length)throw new TypeError("CronPattern: Syntax error, illegal range: '"+e+"'");if(n=parseInt(o[0],10)+r,i=parseInt(o[1],10)+r,isNaN(n))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(i))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(n<0||i>=h.length)throw new TypeError("CronPattern: Value out of range: '"+e+"'");if(n>i)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(s=n;s<=i;s++)h[s+r]=1}else if(-1!==e.indexOf("/")){if(o=e.split("/"),2!==o.length)throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+e+"'");if("*"!==o[0])throw new TypeError("CronPattern: Syntax error, left part of / needs to be * : '"+e+"'");if(a=parseInt(o[1],10),isNaN(a))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(0===a)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(a>h.length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+h.length+")");for(s=0;s<h.length;s+=a)h[s+r]=1}else{if(s=parseInt(e,10)+r,s<0||s>=h.length)throw new TypeError("CronPattern: "+t+" value out of range: '"+e+"'");h[s]=1}else for(s=0;s<h.length;s++)h[s]=1};const o=Math.pow(2,31)-1;function n(t,e,r){let o=this;return this instanceof n?(o.pattern=new s(t),o.schedulerDefaults={maxRuns:1/0,kill:!1},"function"==typeof e&&(r=e,e={}),o.opts=o.validateOpts(e||{}),void 0===r?o:this.schedule(e,r)):new n(t,e,r)}n.prototype.next=function(t){let e=this._next(t);return e?e.getDate():null},n.prototype.previous=function(){return this.opts.previous?this.opts.previous.getDate():null},n.prototype._next=function(t){t=new r(t,this.opts.timezone),this.opts.startAt&&t&&t.getTime()<this.opts.startAt.getTime()&&(t=new r(this.opts.startAt,this.opts.timezone));let e=new r(t,this.opts.timezone).increment(this.pattern);return this.opts.maxRuns<=0||this.opts.kill||this.opts.stopAt&&e.getTime()>=this.opts.stopAt.getTime()?null:e},n.prototype.validateOpts=function(t){return t.startAt&&(t.startAt=new r(t.startAt,t.timezone)),t.stopAt&&(t.stopAt=new r(t.stopAt,t.timezone)),t},n.prototype.msToNext=function(t){t=t||new r(void 0,this.opts.timezone);let e=this._next(t);return e?e.getTime()-t.getTime():null},n.prototype.schedule=function(t,e){e||(e=t,t=this.opts),t.paused=void 0!==t.paused&&t.paused,t.kill=t.kill||this.schedulerDefaults.kill,t.maxRuns||0===t.maxRuns||(t.maxRuns=this.schedulerDefaults.maxRuns),this.opts=this.validateOpts(t||{}),this._schedule(t,e)},n.prototype._schedule=function(t,e){let s,n=this,i=n.maxDelay||o;if(s=this.msToNext(n.opts.previous),null!==s)return s>i&&(s=i),n.opts.currentTimeout=setTimeout((function(){s!==i&&(n.opts.paused||(n.opts.maxRuns--,e()),n.opts.previous=new r(n.opts.previous,n.opts.timezone)),n._schedule(n.opts,e)}),s),{stop:function(){n.opts.kill=!0,n.opts.currentTimeout&&clearTimeout(n.opts.currentTimeout)},pause:function(){return(n.opts.paused=!0)&&!n.opts.kill},resume:function(){return!(n.opts.paused=!1)&&!n.opts.kill}}};const i=n;return e.default})()}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "croner",
3
- "version": "3.0.40",
3
+ "version": "3.0.44",
4
4
  "description": "Isomorphic JavaScript cron parser and scheduler.",
5
5
  "author": "Hexagon <github.com/hexagon>",
6
6
  "contributors": [