You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the introduction of TypeScript in version 3 and alignment with UNIX cron patterns, a few changes have been made:
57
+
v4 dropped Node v16 and renamed the `job.running` property:
58
58
59
59
<details>
60
60
<summary>Migrating from v3 to v4</summary>
61
61
62
62
### Dropped Node version
63
63
64
-
Node v16 is no longer supported. Upgrade your Node installation to Node v18 (LTS) or above
64
+
Node v16 is no longer supported. Upgrade your Node installation to Node v18 or above
65
65
66
66
### Property renamed and now read-only
67
67
68
68
You can no longer set the `running` property (now `isActive`). It is read-only. To start or stop a cron job, use `job.start()` and `job.stop()`.
69
69
70
70
</details>
71
71
72
+
v3 introduced TypeScript and tighter Unix cron pattern alignment:
73
+
72
74
<details>
73
75
<summary>Migrating from v2 to v3</summary>
74
76
@@ -125,7 +127,7 @@ const job = CronJob.from({
125
127
126
128
For more advanced examples, check the [examples directory](https://github.com/kelektiv/node-cron/tree/main/examples).
127
129
128
-
## Cron Patterns
130
+
## ⏰ Cron Patterns
129
131
130
132
Cron patterns are the backbone of this library. Familiarize yourself with the syntax:
131
133
@@ -155,13 +157,7 @@ day of week 0-7 (0 or 7 is Sunday, or use names)
155
157
> Names can also be used for the 'month' and 'day of week' fields. Use the first three letters of the particular day or month (case does not matter). Ranges and lists of names are allowed.
156
158
> Examples: "mon,wed,fri", "jan-mar".
157
159
158
-
## Gotchas
159
-
160
-
- Both JS `Date` and Luxon `DateTime` objects don't guarantee millisecond precision due to computation delays. This module excludes millisecond precision for standard cron syntax but allows execution date specification through JS `Date` or Luxon `DateTime` objects. However, specifying a precise future execution time, such as adding a millisecond to the current time, may not always work due to these computation delays. It's observed that delays less than 4-5 ms might lead to inconsistencies. While we could limit all date granularity to seconds, we've chosen to allow greater precision but advise users of potential issues.
161
-
162
-
- Using arrow functions for `onTick` binds them to the parent's `this` context. As a result, they won't have access to the cronjob's `this` context. You can read a little more in issue [#47 (comment)](https://github.com/kelektiv/node-cron/issues/47#issuecomment-459762775).
163
-
164
-
## API
160
+
## 📖 API
165
161
166
162
### Standalone Functions
167
163
@@ -262,6 +258,12 @@ day of week 0-7 (0 or 7 is Sunday, or use names)
262
258
263
259
-`utcOffset`: [OPTIONAL] - Analogous to `utcOffset` from `CronJob` parameters.
264
260
261
+
## 💢 Gotchas
262
+
263
+
- Both JS `Date` and Luxon `DateTime` objects don't guarantee millisecond precision due to computation delays. This module excludes millisecond precision for standard cron syntax but allows execution date specification through JS `Date` or Luxon `DateTime` objects. However, specifying a precise future execution time, such as adding a millisecond to the current time, may not always work due to these computation delays. It's observed that delays less than 4-5 ms might lead to inconsistencies. While we could limit all date granularity to seconds, we've chosen to allow greater precision but advise users of potential issues.
264
+
265
+
- Using arrow functions for `onTick` binds them to the parent's `this` context. As a result, they won't have access to the cronjob's `this` context. You can read a little more in issue [#47 (comment)](https://github.com/kelektiv/node-cron/issues/47#issuecomment-459762775).
266
+
265
267
## 🤝 Community
266
268
267
269
Join the [Discord server](https://discord.gg/yyKns29zch)! Here you can discuss issues and get help in a more casual forum than GitHub.
@@ -280,6 +282,6 @@ This is a community effort project. In the truest sense, this project started as
280
282
281
283
Special thanks to [Hiroki Horiuchi](https://github.com/horiuchi), [Lundarl Gholoi](https://github.com/winup) and [koooge](https://github.com/koooge) for their work on the [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped) typings before they were imported in v2.4.0.
0 commit comments