croner 10.0.0-dev.8 → 10.0.0
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 +12 -12
- package/package.json +11 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Trigger functions or evaluate cron expressions in JavaScript or TypeScript. No d
|
|
|
10
10
|
|
|
11
11
|
* Trigger functions in JavaScript using [Cron](https://en.wikipedia.org/wiki/Cron#CRON_expression) syntax.
|
|
12
12
|
* Evaluate cron expressions and get a list of upcoming run times.
|
|
13
|
-
*
|
|
13
|
+
* Supports seconds and year fields, `L` (last), `W` (weekday), `#` (nth occurrence), and `+` (AND logic).
|
|
14
14
|
* Works in Node.js >=18.0 (both require and import), Deno >=2.0 and Bun >=1.0.0.
|
|
15
15
|
* Works in browsers as standalone, UMD or ES-module.
|
|
16
16
|
* Target different [time zones](https://croner.56k.guru/usage/examples/#time-zone).
|
|
@@ -171,7 +171,7 @@ job.name // Optional job name, populated if a name were passed to options
|
|
|
171
171
|
|
|
172
172
|
#### Pattern
|
|
173
173
|
|
|
174
|
-
Croner
|
|
174
|
+
Croner uses [Vixie Cron](https://en.wikipedia.org/wiki/Cron#CRON_expression) based expressions with the following powerful extensions:
|
|
175
175
|
|
|
176
176
|
```javascript
|
|
177
177
|
// ┌──────────────── (optional) second (0 - 59)
|
|
@@ -186,34 +186,34 @@ Croner is fully compliant with the [Open Cron Pattern Specification (OCPS)](http
|
|
|
186
186
|
// * * * * * * *
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
-
* **
|
|
189
|
+
* **Optional second and year fields** for enhanced precision:
|
|
190
190
|
- 6-field format: `SECOND MINUTE HOUR DAY-OF-MONTH MONTH DAY-OF-WEEK`
|
|
191
191
|
- 7-field format: `SECOND MINUTE HOUR DAY-OF-MONTH MONTH DAY-OF-WEEK YEAR`
|
|
192
192
|
- Supported year range: 1-9999
|
|
193
193
|
|
|
194
|
-
* **
|
|
194
|
+
* **Advanced calendar modifiers**:
|
|
195
195
|
- *L*: Last day of month or last occurrence of a weekday. `L` in day-of-month = last day of month; `5#L` or `FRI#L` = last Friday of the month.
|
|
196
196
|
- *W*: Nearest weekday. `15W` triggers on the weekday closest to the 15th (moves to Friday if 15th is Saturday, Monday if 15th is Sunday). Won't cross month boundaries.
|
|
197
197
|
- *#*: Nth occurrence of a weekday. `5#2` = second Friday; `MON#1` = first Monday of the month.
|
|
198
198
|
|
|
199
|
-
* **
|
|
199
|
+
* **Enhanced logical control**:
|
|
200
200
|
- *+*: Explicit AND logic modifier. Prefix the day-of-week field with `+` to require both day-of-month AND day-of-week to match. Example: `0 12 1 * +MON` only triggers when the 1st is also a Monday.
|
|
201
201
|
- *?*: Wildcard alias (behaves identically to `*`). **Non-portable**: Its use is discouraged in patterns intended for cross-system use. Supported in all fields for compatibility, but primarily meaningful in day-of-month and day-of-week fields.
|
|
202
202
|
- Proper DST handling: Jobs scheduled during DST gaps are skipped; jobs in DST overlaps run once at first occurrence.
|
|
203
203
|
|
|
204
204
|
* Croner allows you to pass a JavaScript Date object or an ISO 8601 formatted string as a pattern. The scheduled function will trigger at the specified date/time and only once. If you use a timezone different from the local timezone, you should pass the ISO 8601 local time in the target location and specify the timezone using the options (2nd parameter).
|
|
205
205
|
|
|
206
|
-
* By default, Croner uses OR logic for day-of-month and day-of-week
|
|
206
|
+
* By default, Croner uses OR logic for day-of-month and day-of-week. Example: `0 20 1 * MON` triggers on the 1st of the month OR on Mondays. Use the `+` modifier (`0 20 1 * +MON`) or `{ domAndDow: true }` for AND logic. For more information, see issue [#53](https://github.com/Hexagon/croner/issues/53).
|
|
207
207
|
|
|
208
208
|
| Field | Required | Allowed values | Allowed special characters | Remarks |
|
|
209
209
|
|--------------|----------|----------------|----------------------------|---------------------------------------|
|
|
210
|
-
| Seconds | Optional | 0-59 | * , - / ? |
|
|
210
|
+
| Seconds | Optional | 0-59 | * , - / ? | Optional, defaults to 0 |
|
|
211
211
|
| Minutes | Yes | 0-59 | * , - / ? | |
|
|
212
212
|
| Hours | Yes | 0-23 | * , - / ? | |
|
|
213
213
|
| Day of Month | Yes | 1-31 | * , - / ? L W | L = last day, W = nearest weekday |
|
|
214
214
|
| Month | Yes | 1-12 or JAN-DEC| * , - / ? | |
|
|
215
|
-
| Day of Week | Yes | 0-7 or SUN-MON | * , - / ? L # + | 0 and 7 = Sunday (standard mode)<br>1-7 = Sunday-Saturday (Quartz mode with `alternativeWeekdays: true`)<br># = nth occurrence (e.g. MON#2)<br>+ = AND logic modifier
|
|
216
|
-
| Year | Optional | 1-9999 | * , - / |
|
|
215
|
+
| Day of Week | Yes | 0-7 or SUN-MON | * , - / ? L # + | 0 and 7 = Sunday (standard mode)<br>1-7 = Sunday-Saturday (Quartz mode with `alternativeWeekdays: true`)<br># = nth occurrence (e.g. MON#2)<br>+ = AND logic modifier |
|
|
216
|
+
| Year | Optional | 1-9999 | * , - / | Optional, defaults to * |
|
|
217
217
|
|
|
218
218
|
> **Note**
|
|
219
219
|
> Weekday and month names are case-insensitive. Both `MON` and `mon` work.
|
|
@@ -223,7 +223,7 @@ Croner is fully compliant with the [Open Cron Pattern Specification (OCPS)](http
|
|
|
223
223
|
> The `+` modifier (OCPS 1.4) enforces AND logic: `0 12 1 * +MON` only runs when the 1st is also a Monday.
|
|
224
224
|
> **Quartz mode**: Enable `alternativeWeekdays: true` to use Quartz-style weekday numbering (1=Sunday, 2=Monday, ..., 7=Saturday) instead of the standard format (0=Sunday, 1=Monday, ..., 6=Saturday). This is useful for compatibility with Quartz cron expressions.
|
|
225
225
|
|
|
226
|
-
**
|
|
226
|
+
**Predefined schedule nicknames** are supported:
|
|
227
227
|
|
|
228
228
|
| Nickname | Description |
|
|
229
229
|
| -------- | ----------- |
|
|
@@ -259,8 +259,8 @@ For example, some popular alternatives include large datetime libraries as depen
|
|
|
259
259
|
| Controls (stop/resume) | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
260
260
|
| Range (0-13) | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
261
261
|
| Stepping (*/5) | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
262
|
-
| Seconds field
|
|
263
|
-
| Year field
|
|
262
|
+
| Seconds field | ✓ | | | | |
|
|
263
|
+
| Year field | ✓ | | | | |
|
|
264
264
|
| Last day of month (L) | ✓ | ✓ | | | |
|
|
265
265
|
| Nth weekday of month (#) | ✓ | ✓ | | | |
|
|
266
266
|
| Nearest weekday (W) | ✓ | ✓ | | | |
|
package/package.json
CHANGED
|
@@ -16,6 +16,16 @@
|
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/hexagon/croner/issues"
|
|
18
18
|
},
|
|
19
|
+
"funding": [
|
|
20
|
+
{
|
|
21
|
+
"type": "other",
|
|
22
|
+
"url": "https://paypal.me/hexagonpp"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "github",
|
|
26
|
+
"url": "https://github.com/sponsors/hexagon"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
19
29
|
"files": [
|
|
20
30
|
"dist/*.js",
|
|
21
31
|
"dist/*.cjs",
|
|
@@ -59,5 +69,5 @@
|
|
|
59
69
|
}
|
|
60
70
|
},
|
|
61
71
|
"license": "MIT",
|
|
62
|
-
"version": "10.0.0
|
|
72
|
+
"version": "10.0.0"
|
|
63
73
|
}
|