cron-schedule 3.0.6 → 4.0.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,11 +11,11 @@ A zero-dependency cron parser and scheduler for Node.js, Deno and the browser.
11
11
  * Get next or previous schedules from a specific starting date.
12
12
  * Check if a date matches a cron expression.
13
13
  * Schedule a function call based on a cron expression.
14
- * Supports Node.js, Deno and the browser (IIFE or ESM, ES6 required)
14
+ * Supports Node.js, Deno and the browser (ESM only)
15
15
  * [Lightweight](https://bundlephobia.com/result?p=cron-schedule@latest) and tree-shakeable.
16
16
 
17
17
  ## Installation and usage
18
- ### Node.js (CommonJS)
18
+ ### Node.js
19
19
  Via npm:
20
20
 
21
21
  `$ npm install cron-schedule`
@@ -24,7 +24,7 @@ Via yarn:
24
24
 
25
25
  `$ yarn add cron-schedule`
26
26
 
27
- **We test our code against the following Node.js releases (`12.18`, `14.13`, `16.12`).**
27
+ **We test our code against the following Node.js releases (`16.19`, `18.15`).**
28
28
  Other versions of node.js may also work, but this is not tested.
29
29
 
30
30
  ##### Usage
@@ -35,25 +35,7 @@ console.log(cron.getNextDate(new Date(2020, 10, 20, 18, 32)))
35
35
  // 2020-11-20T17:35:00.000Z
36
36
  ```
37
37
 
38
- ## Browser (IIFE)
39
- ```html
40
- <script src="https://unpkg.com/cron-schedule@:version"></script>
41
- ```
42
-
43
- After the script has been loaded, you can use the global `cronSchedule` object to access the API.
44
-
45
- ##### Usage
46
- ```html
47
- <script>
48
- const cron = cronSchedule.parseCronExpression('*/5 * * * *')
49
- console.log(cron.getNextDate(new Date(2020, 10, 20, 18, 32)))
50
- // 2020-11-20T17:35:00.000Z
51
- </script>
52
- ```
53
-
54
- **Requires ES6 (ES2015) browser support. Internet Explorer is not supported.** If you need to support older browsers, get _cron-schedule_ via npm or yarn and transpile it with your bundler.
55
-
56
- ### Browser (ECMAScript module)
38
+ ### Browser via CDN
57
39
  ```html
58
40
  <script type="module">
59
41
  import { parseCronExpression } from 'https://cdn.skypack.dev/cron-schedule@:version'
@@ -65,7 +47,7 @@ After the script has been loaded, you can use the global `cronSchedule` object t
65
47
 
66
48
  ### Deno
67
49
  ```ts
68
- import { parseCronExpression } from 'https://cdn.skypack.dev/cron-schedule@:version?dts'
50
+ import { parseCronExpression } from 'npm:cron-schedule@:version'
69
51
  // TypeScript types are automatically shipped with the X-TypeScript-Types http header.
70
52
  const cron = parseCronExpression('*/5 * * * *')
71
53
  console.log(cron.getNextDate(new Date(2020, 10, 20, 18, 32)))
@@ -73,14 +55,14 @@ console.log(cron.getNextDate(new Date(2020, 10, 20, 18, 32)))
73
55
  ```
74
56
 
75
57
  ### Note on CDN usage
76
- The examples above use [unpkg](http://unpkg.com) for IIFE and [Skypack](https://www.skypack.dev) for ESM.
58
+ The examples above use [Skypack](https://www.skypack.dev).
77
59
 
78
- The urls contain `:version` placeholder. Replace `:version` with the desired version. Semver ranges are supported. To always use the latest `2.x` version use `^2.0.0`.
60
+ The urls contain `:version` placeholder. Replace `:version` with the desired version. Semver ranges are supported. To always use the latest `4.x` version use `^4.0.0`.
79
61
  See https://www.npmjs.com/package/cron-schedule for a list of available versions.
80
62
 
81
63
  ## Work with cron expressions
82
64
  ```ts
83
- // Import method to parse a cron expression. In the browser with IIFE: cronSchedule.parseCronExpression
65
+ // Import method to parse a cron expression.
84
66
  import { parseCronExpression } from 'cron-schedule'
85
67
 
86
68
  // Parse a cron expression to return a Cron instance.
@@ -120,8 +102,8 @@ The timer based cron scheduler creates one timer for every scheduled cron.
120
102
  When the node timeout limit of ~24 days would be exceeded, it uses multiple consecutive timeouts.
121
103
 
122
104
  ```ts
123
- // Import the scheduler. In the browser with IIFE: cronSchedule.TimerBasedCronScheduler
124
- import { TimerBasedCronScheduler as scheduler } from 'cron-schedule'
105
+ // Import the scheduler.
106
+ import { TimerBasedCronScheduler as scheduler } from 'cron-schedule/schedulers/timer-based.js'
125
107
 
126
108
  // Create a timeout, which fill fire the task on the next cron date.
127
109
  // An optional errorHandler can be provided, which is called when the task throws an error or returns a promise that gets rejected.
@@ -149,8 +131,8 @@ scheduler.clearTimeoutOrInterval(handle: ITimerHandle): void
149
131
  The interval based scheduler checks for due task in a fixed interval. So there is only one interval for all tasks assigned to a scheduler.
150
132
  You can have multiple instances of an interval based scheduler.
151
133
  ```ts
152
- // Import the scheduler. In the browser with IIFE: cronSchedule.IntervalBasedCronScheduler
153
- import { IntervalBasedCronScheduler } from 'cron-schedule'
134
+ // Import the scheduler.
135
+ import { IntervalBasedCronScheduler } from 'cron-schedule/schedulers/interval-based.js'
154
136
 
155
137
  // Instantiate a new instance of the scheduler with the given interval. In this example, the scheduler would check every 60 seconds.
156
138
  const scheduler = new IntervalBasedCronScheduler(60 * 1000)
@@ -1,3 +1,3 @@
1
- import { Cron } from './cron';
1
+ import { Cron } from './cron.js';
2
2
  /** Parses a cron expression into a Cron instance. */
3
3
  export declare function parseCronExpression(cronExpression: string): Cron;
@@ -0,0 +1,156 @@
1
+ import { Cron } from './cron.js';
2
+ const secondConstraint = {
3
+ min: 0,
4
+ max: 59,
5
+ };
6
+ const minuteConstraint = {
7
+ min: 0,
8
+ max: 59,
9
+ };
10
+ const hourConstraint = {
11
+ min: 0,
12
+ max: 23,
13
+ };
14
+ const dayConstraint = {
15
+ min: 1,
16
+ max: 31,
17
+ };
18
+ const monthConstraint = {
19
+ min: 1,
20
+ max: 12,
21
+ aliases: {
22
+ jan: '1',
23
+ feb: '2',
24
+ mar: '3',
25
+ apr: '4',
26
+ may: '5',
27
+ jun: '6',
28
+ jul: '7',
29
+ aug: '8',
30
+ sep: '9',
31
+ oct: '10',
32
+ nov: '11',
33
+ dec: '12',
34
+ },
35
+ };
36
+ const weekdayConstraint = {
37
+ min: 0,
38
+ max: 6,
39
+ aliases: {
40
+ '7': '0',
41
+ 'sun': '0',
42
+ 'mon': '1',
43
+ 'tue': '2',
44
+ 'wed': '3',
45
+ 'thu': '4',
46
+ 'fri': '5',
47
+ 'sat': '6',
48
+ },
49
+ };
50
+ const timeNicknames = {
51
+ '@yearly': '0 0 1 1 *',
52
+ '@annually': '0 0 1 1 *',
53
+ '@monthly': '0 0 1 1 *',
54
+ '@weekly': '0 0 * * 0',
55
+ '@daily': '0 0 * * *',
56
+ '@hourly': '0 * * * *',
57
+ '@minutely': '* * * * *',
58
+ };
59
+ function parseElement(element, constraint) {
60
+ const result = new Set();
61
+ // If returned set of numbers is empty, the scheduler class interpretes the emtpy set of numbers as all valid values of the constraint
62
+ if (element === '*') {
63
+ for (let i = constraint.min; i <= constraint.max; i = i + 1) {
64
+ result.add(i);
65
+ }
66
+ return result;
67
+ }
68
+ // If the element is a list, parse each element in the list.
69
+ const listElements = element.split(',');
70
+ if (listElements.length > 1) {
71
+ listElements.forEach((listElement) => {
72
+ const parsedListElement = parseElement(listElement, constraint);
73
+ parsedListElement.forEach((x) => result.add(x));
74
+ });
75
+ return result;
76
+ }
77
+ // Helper function to parse a single element, which includes checking for alias, valid number and constraint min and max.
78
+ const parseSingleElement = (singleElement) => {
79
+ var _a, _b;
80
+ singleElement =
81
+ (_b = (_a = constraint.aliases) === null || _a === void 0 ? void 0 : _a[singleElement.toLowerCase()]) !== null && _b !== void 0 ? _b : singleElement;
82
+ const parsedElement = parseInt(singleElement, 10);
83
+ if (Number.isNaN(parsedElement)) {
84
+ throw new Error(`Failed to parse ${element}: ${singleElement} is NaN.`);
85
+ }
86
+ if (parsedElement < constraint.min || parsedElement > constraint.max) {
87
+ throw new Error(`Failed to parse ${element}: ${singleElement} is outside of constraint range of ${constraint.min} - ${constraint.max}.`);
88
+ }
89
+ return parsedElement;
90
+ };
91
+ // Detect if the element is a range.
92
+ /* eslint-disable security/detect-unsafe-regex */
93
+ const rangeSegments = /^((([0-9a-zA-Z]+)-([0-9a-zA-Z]+))|\*)(\/([0-9]+))?$/.exec(element);
94
+ /* eslint-enable security/detect-unsafe-regex */
95
+ // If not, it must be a single element.
96
+ if (rangeSegments === null) {
97
+ result.add(parseSingleElement(element));
98
+ return result;
99
+ }
100
+ // If it is a range, get start and end of the range.
101
+ const parsedStart = rangeSegments[1] === '*'
102
+ ? constraint.min
103
+ : parseSingleElement(rangeSegments[3]);
104
+ const parsedEnd = rangeSegments[1] === '*'
105
+ ? constraint.max
106
+ : parseSingleElement(rangeSegments[4]);
107
+ if (parsedStart > parsedEnd) {
108
+ throw new Error(`Failed to parse ${element}: Invalid range (start: ${parsedStart}, end: ${parsedEnd}).`);
109
+ }
110
+ // Check whether there is a custom step defined for the range, defaulting to 1.
111
+ const step = rangeSegments[6];
112
+ let parsedStep = 1;
113
+ if (step !== undefined) {
114
+ parsedStep = parseInt(step, 10);
115
+ if (Number.isNaN(parsedStep)) {
116
+ throw new Error(`Failed to parse step: ${step} is NaN.`);
117
+ }
118
+ else if (parsedStep < 1) {
119
+ throw new Error(`Failed to parse step: Expected ${step} to be greater than 0.`);
120
+ }
121
+ }
122
+ // Go from start to end of the range by the given steps.
123
+ for (let i = parsedStart; i <= parsedEnd; i = i + parsedStep) {
124
+ result.add(i);
125
+ }
126
+ return result;
127
+ }
128
+ /** Parses a cron expression into a Cron instance. */
129
+ export function parseCronExpression(cronExpression) {
130
+ var _a;
131
+ if (typeof cronExpression !== 'string') {
132
+ throw new TypeError('Invalid cron expression: must be of type string.');
133
+ }
134
+ // Convert time nicknames.
135
+ cronExpression = (_a = timeNicknames[cronExpression.toLowerCase()]) !== null && _a !== void 0 ? _a : cronExpression;
136
+ const elements = cronExpression.split(' ');
137
+ if (elements.length < 5 || elements.length > 6) {
138
+ throw new Error('Invalid cron expression: expected 5 or 6 elements.');
139
+ }
140
+ const rawSeconds = elements.length === 6 ? elements[0] : '0';
141
+ const rawMinutes = elements.length === 6 ? elements[1] : elements[0];
142
+ const rawHours = elements.length === 6 ? elements[2] : elements[1];
143
+ const rawDays = elements.length === 6 ? elements[3] : elements[2];
144
+ const rawMonths = elements.length === 6 ? elements[4] : elements[3];
145
+ const rawWeekdays = elements.length === 6 ? elements[5] : elements[4];
146
+ return new Cron({
147
+ seconds: parseElement(rawSeconds, secondConstraint),
148
+ minutes: parseElement(rawMinutes, minuteConstraint),
149
+ hours: parseElement(rawHours, hourConstraint),
150
+ days: parseElement(rawDays, dayConstraint),
151
+ // months in cron are indexed by 1, but Cron expects indexes by 0, so we need to reduce all set values by one.
152
+ months: new Set(Array.from(parseElement(rawMonths, monthConstraint)).map((x) => x - 1)),
153
+ weekdays: parseElement(rawWeekdays, weekdayConstraint),
154
+ });
155
+ }
156
+ //# sourceMappingURL=cron-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cron-parser.js","sourceRoot":"","sources":["../src/cron-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAQhC,MAAM,gBAAgB,GAAgB;IACpC,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,EAAE;CACR,CAAA;AAED,MAAM,gBAAgB,GAAgB;IACpC,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,EAAE;CACR,CAAA;AAED,MAAM,cAAc,GAAgB;IAClC,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,EAAE;CACR,CAAA;AAED,MAAM,aAAa,GAAgB;IACjC,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,EAAE;CACR,CAAA;AAED,MAAM,eAAe,GAAgB;IACnC,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,EAAE;IACP,OAAO,EAAE;QACP,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,IAAI;QACT,GAAG,EAAE,IAAI;QACT,GAAG,EAAE,IAAI;KACV;CACF,CAAA;AAED,MAAM,iBAAiB,GAAgB;IACrC,GAAG,EAA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CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CACvE;QACD,QAAQ,EAAE,YAAY,CAAC,WAAW,EAAE,iBAAiB,CAAC;KACvD,CAAC,CAAA;AACJ,CAAC"}
package/dist/cron.js ADDED
@@ -0,0 +1,353 @@
1
+ import { extractDateElements, getDaysBetweenWeekdays, getDaysInMonth, } from './utils.js';
2
+ export class Cron {
3
+ constructor({ seconds, minutes, hours, days, months, weekdays, }) {
4
+ // Validate that there are values provided.
5
+ if (!seconds || seconds.size === 0)
6
+ throw new Error('There must be at least one allowed second.');
7
+ if (!minutes || minutes.size === 0)
8
+ throw new Error('There must be at least one allowed minute.');
9
+ if (!hours || hours.size === 0)
10
+ throw new Error('There must be at least one allowed hour.');
11
+ if (!months || months.size === 0)
12
+ throw new Error('There must be at least one allowed month.');
13
+ if ((!weekdays || weekdays.size === 0) && (!days || days.size === 0))
14
+ throw new Error('There must be at least one allowed day or weekday.');
15
+ // Convert set to array and sort in ascending order.
16
+ this.seconds = Array.from(seconds).sort((a, b) => a - b);
17
+ this.minutes = Array.from(minutes).sort((a, b) => a - b);
18
+ this.hours = Array.from(hours).sort((a, b) => a - b);
19
+ this.days = Array.from(days).sort((a, b) => a - b);
20
+ this.months = Array.from(months).sort((a, b) => a - b);
21
+ this.weekdays = Array.from(weekdays).sort((a, b) => a - b);
22
+ // Validate that all values are integers within the constraint.
23
+ const validateData = (name, data, constraint) => {
24
+ if (data.some((x) => typeof x !== 'number' ||
25
+ x % 1 !== 0 ||
26
+ x < constraint.min ||
27
+ x > constraint.max)) {
28
+ throw new Error(`${name} must only consist of integers which are within the range of ${constraint.min} and ${constraint.max}`);
29
+ }
30
+ };
31
+ validateData('seconds', this.seconds, { min: 0, max: 59 });
32
+ validateData('minutes', this.minutes, { min: 0, max: 59 });
33
+ validateData('hours', this.hours, { min: 0, max: 23 });
34
+ validateData('days', this.days, { min: 1, max: 31 });
35
+ validateData('months', this.months, { min: 0, max: 11 });
36
+ validateData('weekdays', this.weekdays, { min: 0, max: 6 });
37
+ // For each element, store a reversed copy in the reversed attribute for finding prev dates.
38
+ this.reversed = {
39
+ seconds: this.seconds.map((x) => x).reverse(),
40
+ minutes: this.minutes.map((x) => x).reverse(),
41
+ hours: this.hours.map((x) => x).reverse(),
42
+ days: this.days.map((x) => x).reverse(),
43
+ months: this.months.map((x) => x).reverse(),
44
+ weekdays: this.weekdays.map((x) => x).reverse(),
45
+ };
46
+ }
47
+ /**
48
+ * Find the next or previous hour, starting from the given start hour that matches the hour constraint.
49
+ * startHour itself might also be allowed.
50
+ */
51
+ findAllowedHour(dir, startHour) {
52
+ return dir === 'next'
53
+ ? this.hours.find((x) => x >= startHour)
54
+ : this.reversed.hours.find((x) => x <= startHour);
55
+ }
56
+ /**
57
+ * Find the next or previous minute, starting from the given start minute that matches the minute constraint.
58
+ * startMinute itself might also be allowed.
59
+ */
60
+ findAllowedMinute(dir, startMinute) {
61
+ return dir === 'next'
62
+ ? this.minutes.find((x) => x >= startMinute)
63
+ : this.reversed.minutes.find((x) => x <= startMinute);
64
+ }
65
+ /**
66
+ * Find the next or previous second, starting from the given start second that matches the second constraint.
67
+ * startSecond itself IS NOT allowed.
68
+ */
69
+ findAllowedSecond(dir, startSecond) {
70
+ return dir === 'next'
71
+ ? this.seconds.find((x) => x > startSecond)
72
+ : this.reversed.seconds.find((x) => x < startSecond);
73
+ }
74
+ /**
75
+ * Find the next or previous time, starting from the given start time that matches the hour, minute
76
+ * and second constraints. startTime itself might also be allowed.
77
+ */
78
+ findAllowedTime(dir, startTime) {
79
+ // Try to find an allowed hour.
80
+ let hour = this.findAllowedHour(dir, startTime.hour);
81
+ if (hour !== undefined) {
82
+ if (hour === startTime.hour) {
83
+ // We found an hour that is the start hour. Try to find an allowed minute.
84
+ let minute = this.findAllowedMinute(dir, startTime.minute);
85
+ if (minute !== undefined) {
86
+ if (minute === startTime.minute) {
87
+ // We found a minute that is the start minute. Try to find an allowed second.
88
+ const second = this.findAllowedSecond(dir, startTime.second);
89
+ if (second !== undefined) {
90
+ // We found a second within the start hour and minute.
91
+ return { hour, minute, second };
92
+ }
93
+ else {
94
+ // We did not find a valid second within the start minute. Try to find another minute.
95
+ minute = this.findAllowedMinute(dir, dir === 'next' ? startTime.minute + 1 : startTime.minute - 1);
96
+ if (minute !== undefined) {
97
+ // We found a minute which is not the start minute. Return that minute together with the hour and the first / last allowed second.
98
+ return {
99
+ hour,
100
+ minute,
101
+ second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],
102
+ };
103
+ }
104
+ }
105
+ }
106
+ else {
107
+ // We found a minute which is not the start minute. Return that minute together with the hour and the first / last allowed second.
108
+ return {
109
+ hour,
110
+ minute,
111
+ second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],
112
+ };
113
+ }
114
+ }
115
+ // We did not find an allowed minute / second combination inside the start hour. Try to find the next / previous allowed hour.
116
+ hour = this.findAllowedHour(dir, dir === 'next' ? startTime.hour + 1 : startTime.hour - 1);
117
+ if (hour !== undefined) {
118
+ // We found an allowed hour which is not the start hour. Return that hour together with the first / last allowed minutes / seconds.
119
+ return {
120
+ hour,
121
+ minute: dir === 'next' ? this.minutes[0] : this.reversed.minutes[0],
122
+ second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],
123
+ };
124
+ }
125
+ }
126
+ else {
127
+ // We found an allowed hour which is not the start hour. Return that hour together with the first / last allowed minutes / seconds.
128
+ return {
129
+ hour,
130
+ minute: dir === 'next' ? this.minutes[0] : this.reversed.minutes[0],
131
+ second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],
132
+ };
133
+ }
134
+ }
135
+ // No allowed time found.
136
+ return undefined;
137
+ }
138
+ /**
139
+ * Find the next or previous day in the given month, starting from the given startDay
140
+ * that matches either the day or the weekday constraint. startDay itself might also be allowed.
141
+ */
142
+ findAllowedDayInMonth(dir, year, month, startDay) {
143
+ var _a, _b;
144
+ if (startDay < 1)
145
+ throw new Error('startDay must not be smaller than 1.');
146
+ // If only days are restricted: allow day based on day constraint only.
147
+ // If only weekdays are restricted: allow day based on weekday constraint only.
148
+ // If both are restricted: allow day based on both day and weekday constraint. pick day that is closer to startDay.
149
+ // If none are restricted: return the day closest to startDay (respecting dir) that is allowed (or startDay itself).
150
+ const daysInMonth = getDaysInMonth(year, month);
151
+ const daysRestricted = this.days.length !== 31;
152
+ const weekdaysRestricted = this.weekdays.length !== 7;
153
+ if (!daysRestricted && !weekdaysRestricted) {
154
+ if (startDay > daysInMonth) {
155
+ return dir === 'next' ? undefined : daysInMonth;
156
+ }
157
+ return startDay;
158
+ }
159
+ // Try to find a day based on the days constraint.
160
+ let allowedDayByDays;
161
+ if (daysRestricted) {
162
+ allowedDayByDays =
163
+ dir === 'next'
164
+ ? this.days.find((x) => x >= startDay)
165
+ : this.reversed.days.find((x) => x <= startDay);
166
+ // Make sure the day does not exceed the amount of days in month.
167
+ if (allowedDayByDays !== undefined && allowedDayByDays > daysInMonth) {
168
+ allowedDayByDays = undefined;
169
+ }
170
+ }
171
+ // Try to find a day based on the weekday constraint.
172
+ let allowedDayByWeekdays;
173
+ if (weekdaysRestricted) {
174
+ const startWeekday = new Date(year, month, startDay).getDay();
175
+ const nearestAllowedWeekday = dir === 'next'
176
+ ? (_a = this.weekdays.find((x) => x >= startWeekday)) !== null && _a !== void 0 ? _a : this.weekdays[0]
177
+ : (_b = this.reversed.weekdays.find((x) => x <= startWeekday)) !== null && _b !== void 0 ? _b : this.reversed.weekdays[0];
178
+ if (nearestAllowedWeekday !== undefined) {
179
+ const daysBetweenWeekdays = dir === 'next'
180
+ ? getDaysBetweenWeekdays(startWeekday, nearestAllowedWeekday)
181
+ : getDaysBetweenWeekdays(nearestAllowedWeekday, startWeekday);
182
+ allowedDayByWeekdays =
183
+ dir === 'next'
184
+ ? startDay + daysBetweenWeekdays
185
+ : startDay - daysBetweenWeekdays;
186
+ // Make sure the day does not exceed the month boundaries.
187
+ if (allowedDayByWeekdays > daysInMonth || allowedDayByWeekdays < 1) {
188
+ allowedDayByWeekdays = undefined;
189
+ }
190
+ }
191
+ }
192
+ if (allowedDayByDays !== undefined && allowedDayByWeekdays !== undefined) {
193
+ // If a day is found both via the days and the weekdays constraint, pick the day
194
+ // that is closer to start date.
195
+ return dir === 'next'
196
+ ? Math.min(allowedDayByDays, allowedDayByWeekdays)
197
+ : Math.max(allowedDayByDays, allowedDayByWeekdays);
198
+ }
199
+ if (allowedDayByDays !== undefined) {
200
+ return allowedDayByDays;
201
+ }
202
+ if (allowedDayByWeekdays !== undefined) {
203
+ return allowedDayByWeekdays;
204
+ }
205
+ return undefined;
206
+ }
207
+ /** Gets the next date starting from the given start date or now. */
208
+ getNextDate(startDate = new Date()) {
209
+ const startDateElements = extractDateElements(startDate);
210
+ let minYear = startDateElements.year;
211
+ let startIndexMonth = this.months.findIndex((x) => x >= startDateElements.month);
212
+ if (startIndexMonth === -1) {
213
+ startIndexMonth = 0;
214
+ minYear++;
215
+ }
216
+ // We try every month within the next 5 years to make sure that we tried to
217
+ // find a matching date insidde a whole leap year.
218
+ const maxIterations = this.months.length * 5;
219
+ for (let i = 0; i < maxIterations; i++) {
220
+ // Get the next year and month.
221
+ const year = minYear + Math.floor((startIndexMonth + i) / this.months.length);
222
+ const month = this.months[(startIndexMonth + i) % this.months.length];
223
+ const isStartMonth = year === startDateElements.year && month === startDateElements.month;
224
+ // Find the next day.
225
+ let day = this.findAllowedDayInMonth('next', year, month, isStartMonth ? startDateElements.day : 1);
226
+ let isStartDay = isStartMonth && day === startDateElements.day;
227
+ // If we found a day and it is the start day, try to find a valid time beginning from the start date time.
228
+ if (day !== undefined && isStartDay) {
229
+ const nextTime = this.findAllowedTime('next', startDateElements);
230
+ if (nextTime !== undefined) {
231
+ return new Date(year, month, day, nextTime.hour, nextTime.minute, nextTime.second);
232
+ }
233
+ // If no valid time has been found for the start date, try the next day.
234
+ day = this.findAllowedDayInMonth('next', year, month, day + 1);
235
+ isStartDay = false;
236
+ }
237
+ // If we found a next day and it is not the start day, just use the next day with the first allowed values
238
+ // for hours, minutes and seconds.
239
+ if (day !== undefined && !isStartDay) {
240
+ return new Date(year, month, day, this.hours[0], this.minutes[0], this.seconds[0]);
241
+ }
242
+ // No allowed day has been found for this month. Continue to search in next month.
243
+ }
244
+ throw new Error('No valid next date was found.');
245
+ }
246
+ /** Gets the specified amount of future dates starting from the given start date or now. */
247
+ getNextDates(amount, startDate) {
248
+ const dates = [];
249
+ let nextDate;
250
+ for (let i = 0; i < amount; i++) {
251
+ nextDate = this.getNextDate(nextDate !== null && nextDate !== void 0 ? nextDate : startDate);
252
+ dates.push(nextDate);
253
+ }
254
+ return dates;
255
+ }
256
+ /**
257
+ * Get an ES6 compatible iterator which iterates over the next dates starting from startDate or now.
258
+ * The iterator runs until the optional endDate is reached or forever.
259
+ */
260
+ *getNextDatesIterator(startDate, endDate) {
261
+ let nextDate;
262
+ while (true) {
263
+ nextDate = this.getNextDate(startDate);
264
+ startDate = nextDate;
265
+ if (endDate && endDate.getTime() < nextDate.getTime()) {
266
+ return;
267
+ }
268
+ yield nextDate;
269
+ }
270
+ }
271
+ /** Gets the previous date starting from the given start date or now. */
272
+ getPrevDate(startDate = new Date()) {
273
+ const startDateElements = extractDateElements(startDate);
274
+ let maxYear = startDateElements.year;
275
+ let startIndexMonth = this.reversed.months.findIndex((x) => x <= startDateElements.month);
276
+ if (startIndexMonth === -1) {
277
+ startIndexMonth = 0;
278
+ maxYear--;
279
+ }
280
+ // We try every month within the past 5 years to make sure that we tried to
281
+ // find a matching date insidde a whole leap year.
282
+ const maxIterations = this.reversed.months.length * 5;
283
+ for (let i = 0; i < maxIterations; i++) {
284
+ // Get the next year and month.
285
+ const year = maxYear -
286
+ Math.floor((startIndexMonth + i) / this.reversed.months.length);
287
+ const month = this.reversed.months[(startIndexMonth + i) % this.reversed.months.length];
288
+ const isStartMonth = year === startDateElements.year && month === startDateElements.month;
289
+ // Find the previous day.
290
+ let day = this.findAllowedDayInMonth('prev', year, month, isStartMonth ? startDateElements.day : 31);
291
+ let isStartDay = isStartMonth && day === startDateElements.day;
292
+ // If we found a day and it is the start day, try to find a valid time beginning from the start date time.
293
+ if (day !== undefined && isStartDay) {
294
+ const prevTime = this.findAllowedTime('prev', startDateElements);
295
+ if (prevTime !== undefined) {
296
+ return new Date(year, month, day, prevTime.hour, prevTime.minute, prevTime.second);
297
+ }
298
+ // If no valid time has been found for the start date, try the previous day.
299
+ if (day > 1) {
300
+ day = this.findAllowedDayInMonth('prev', year, month, day - 1);
301
+ isStartDay = false;
302
+ }
303
+ }
304
+ // If we found a previous day and it is not the start day, just use the previous day with the first allowed values
305
+ // for hours, minutes and seconds (which will be the latest time due to using the reversed array).
306
+ if (day !== undefined && !isStartDay) {
307
+ return new Date(year, month, day, this.reversed.hours[0], this.reversed.minutes[0], this.reversed.seconds[0]);
308
+ }
309
+ // No allowed day has been found for this month. Continue to search in previous month.
310
+ }
311
+ throw new Error('No valid previous date was found.');
312
+ }
313
+ /** Gets the specified amount of previous dates starting from the given start date or now. */
314
+ getPrevDates(amount, startDate) {
315
+ const dates = [];
316
+ let prevDate;
317
+ for (let i = 0; i < amount; i++) {
318
+ prevDate = this.getPrevDate(prevDate !== null && prevDate !== void 0 ? prevDate : startDate);
319
+ dates.push(prevDate);
320
+ }
321
+ return dates;
322
+ }
323
+ /**
324
+ * Get an ES6 compatible iterator which iterates over the previous dates starting from startDate or now.
325
+ * The iterator runs until the optional endDate is reached or forever.
326
+ */
327
+ *getPrevDatesIterator(startDate, endDate) {
328
+ let prevDate;
329
+ while (true) {
330
+ prevDate = this.getPrevDate(startDate);
331
+ startDate = prevDate;
332
+ if (endDate && endDate.getTime() > prevDate.getTime()) {
333
+ return;
334
+ }
335
+ yield prevDate;
336
+ }
337
+ }
338
+ /** Returns true when there is a cron date at the given date. */
339
+ matchDate(date) {
340
+ const { second, minute, hour, day, month, weekday } = extractDateElements(date);
341
+ if (this.seconds.indexOf(second) === -1 ||
342
+ this.minutes.indexOf(minute) === -1 ||
343
+ this.hours.indexOf(hour) === -1 ||
344
+ this.months.indexOf(month) === -1) {
345
+ return false;
346
+ }
347
+ if (this.days.length !== 31 && this.weekdays.length !== 7) {
348
+ return (this.days.indexOf(day) !== -1 || this.weekdays.indexOf(weekday) !== -1);
349
+ }
350
+ return (this.days.indexOf(day) !== -1 && this.weekdays.indexOf(weekday) !== -1);
351
+ }
352
+ }
353
+ //# sourceMappingURL=cron.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cron.js","sourceRoot":"","sources":["../src/cron.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,GACf,MAAM,YAAY,CAAA;AAenB,MAAM,OAAO,IAAI;IAkBf,YAAmB,EACjB,OAAO,EACP,OAAO,EACP,KAAK,EACL,IAAI,EACJ,MAAM,EACN,QAAQ,GACQ;QAChB,2CAA2C;QAC3C,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAA;QAC/D,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAA;QAC/D,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;QAC7D,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;QAC9D,IAAI,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC;YAClE,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;QAEvE,oDAAoD;QACpD,IAAI,CAA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