cronstrue 3.47.0 → 3.49.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 +76 -60
- package/dist/cronstrue-i18n.js +18 -1
- package/dist/cronstrue-i18n.min.js +1 -1
- package/dist/cronstrue.js +18 -1
- package/dist/cronstrue.min.js +1 -1
- package/package.json +1 -3
package/README.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
# cRonstrue
|
|
1
|
+
# cRonstrue
|
|
2
|
+
|
|
3
|
+
[](https://github.com/bradymholt/cRonstrue/actions/workflows/build.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/cronstrue)
|
|
5
|
+
[](https://www.npmjs.com/package/cronstrue)
|
|
6
|
+
[](https://bundlejs.com/?q=cronstrue)
|
|
7
|
+
[](https://www.npmjs.com/package/cronstrue)
|
|
8
|
+
[](https://github.com/bradymholt/cRonstrue/blob/main/LICENSE)
|
|
2
9
|
|
|
3
10
|
<img align="left" src="https://user-images.githubusercontent.com/759811/210273710-b13913e2-0a71-4d9d-94da-1fe538b8a73e.gif"/>
|
|
4
11
|
|
|
@@ -10,19 +17,25 @@
|
|
|
10
17
|
|
|
11
18
|
cRonstrue is a JavaScript library that parses a cron expression and outputs a human readable description of the cron schedule. For example, given the expression "*/5 * * * *" it will output "Every 5 minutes".
|
|
12
19
|
|
|
13
|
-
|
|
20
|
+
```js
|
|
21
|
+
cronstrue.toString("*/5 * * * *"); // "Every 5 minutes"
|
|
22
|
+
cronstrue.toString("0 23 ? * MON-FRI"); // "At 11:00 PM, Monday through Friday"
|
|
23
|
+
cronstrue.toString("0 9 * * 1", { locale: "fr" }); // "À 09:00, uniquement le lundi"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**[Try it in the live demo →](https://bradymholt.github.io/cRonstrue/)**
|
|
27
|
+
|
|
28
|
+
This library was ported from the original C# implementation called [cron-expression-descriptor](https://github.com/bradymholt/cron-expression-descriptor) and is also available in [Java, Python, Ruby, Go, PHP, Rust, Swift and more](https://github.com/bradymholt/cron-expression-descriptor#ports).
|
|
14
29
|
|
|
15
30
|
## Features
|
|
16
31
|
- Zero dependencies
|
|
32
|
+
- TypeScript type definitions included
|
|
17
33
|
- Supports all cron expression special characters including * / , - ? L W, #
|
|
18
34
|
- Supports 5, 6 (w/ seconds or year), or 7 (w/ seconds and year) part cron expressions
|
|
19
|
-
- [Quartz Job Scheduler](
|
|
20
|
-
- Supports time specification _nicknames_ (@yearly, @annually, @monthly, @weekly, @daily)
|
|
35
|
+
- [Quartz Job Scheduler](https://www.quartz-scheduler.org/) cron expressions are supported
|
|
36
|
+
- Supports time specification _nicknames_ (@yearly, @annually, @monthly, @weekly, @daily, @midnight, @hourly, @reboot)
|
|
21
37
|
- i18n support with 40+ languages
|
|
22
|
-
|
|
23
|
-
## Demo
|
|
24
|
-
|
|
25
|
-
A demo is available [here](http://bradymholt.github.io/cRonstrue/#cronstrue-demo).
|
|
38
|
+
- CLI: `npx cronstrue "*/5 * * * *"`
|
|
26
39
|
|
|
27
40
|
## Installation
|
|
28
41
|
cRonstrue is exported as an [UMD](https://github.com/umdjs/umd) module so it will work in an [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD), [CommonJS](http://wiki.commonjs.org/wiki/CommonJS) or browser global context.
|
|
@@ -66,7 +79,7 @@ A simple way to load the library in a browser is by using the [unpkg](https://un
|
|
|
66
79
|
<script src="https://unpkg.com/cronstrue@latest/dist/cronstrue.min.js" async></script>
|
|
67
80
|
```
|
|
68
81
|
|
|
69
|
-
Using the "latest" tag will result in a 302 redirect to the latest version tag so it is recommended to use a specific version tag such as https://unpkg.com/cronstrue@
|
|
82
|
+
Using the "latest" tag will result in a 302 redirect to the latest version tag so it is recommended to use a specific version tag such as https://unpkg.com/cronstrue@3.48.0/dist/cronstrue.min.js to avoid this redirect.
|
|
70
83
|
|
|
71
84
|
## Usage
|
|
72
85
|
|
|
@@ -128,7 +141,7 @@ To use the i18n support cRonstrue provides, you can either import all the suppor
|
|
|
128
141
|
|
|
129
142
|
### All Locales
|
|
130
143
|
|
|
131
|
-
You can import all locales at once with `cronstrue/i18n`. This approach has the advantage of only having to load one module and having access to all supported locales. The tradeoff with this approach is a larger module (~
|
|
144
|
+
You can import all locales at once with `cronstrue/i18n`. This approach has the advantage of only having to load one module and having access to all supported locales. The tradeoff with this approach is a larger module (~190k, minified) that will take longer to load, particularly when sending down to a browser.
|
|
132
145
|
|
|
133
146
|
```js
|
|
134
147
|
// Node / CommonJS
|
|
@@ -138,7 +151,7 @@ const cronstrue = require('cronstrue/i18n');
|
|
|
138
151
|
import cronstrue from 'cronstrue/i18n';
|
|
139
152
|
|
|
140
153
|
// Browser
|
|
141
|
-
<script src="https://unpkg.com/cronstrue@latest/cronstrue-i18n.min.js" async></script>
|
|
154
|
+
<script src="https://unpkg.com/cronstrue@latest/dist/cronstrue-i18n.min.js" async></script>
|
|
142
155
|
|
|
143
156
|
cronstrue.toString("*/5 * * * *", { locale: "fr" }); // => Toutes les 5 minutes
|
|
144
157
|
cronstrue.toString("*/5 * * * *", { locale: "es" }); // => Cada 5 minutos
|
|
@@ -146,7 +159,7 @@ cronstrue.toString("*/5 * * * *", { locale: "es" }); // => Cada 5 minutos
|
|
|
146
159
|
|
|
147
160
|
### Individual Locales
|
|
148
161
|
|
|
149
|
-
You can also load the main cronstrue module and then load individual locale modules you want to have access to. This works well when you have one or more locales you know you need access to and want to minimize load time, particularly when sending down to a browser. The main cronstrue module is about
|
|
162
|
+
You can also load the main cronstrue module and then load individual locale modules you want to have access to. This works well when you have one or more locales you know you need access to and want to minimize load time, particularly when sending down to a browser. The main cronstrue module is about 26k (minified) and each locale is about 5k (minified) in size.
|
|
150
163
|
|
|
151
164
|
```js
|
|
152
165
|
// Node / CommonJS
|
|
@@ -172,47 +185,50 @@ cronstrue.toString("*/5 * * * *", { locale: "es" }); // => Cada 5 minutos
|
|
|
172
185
|
|
|
173
186
|
The following locales can be passed in for the `locale` option. Thank you to the author (shown below) of each translation!
|
|
174
187
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
188
|
+
| Code | Language | Translated by |
|
|
189
|
+
| --- | --- | --- |
|
|
190
|
+
| `en` | English | [Brady Holt](https://github.com/bradymholt) |
|
|
191
|
+
| `af` | Afrikaans | [Michael van Niekerk](https://github.com/mvniekerk) |
|
|
192
|
+
| `ar` | Arabic | [Mohamed Nehad Shalabi](https://github.com/mohamednehad450) |
|
|
193
|
+
| `az` | Azerbaijani | [Jamal Kamaladdin](https://github.com/jamalkamaladdin) |
|
|
194
|
+
| `be` | Belarusian | [Kirill Mikulich](https://github.com/KirillMikulich) |
|
|
195
|
+
| `bg` | Bulgarian | [kamenf](https://github.com/kamenf) |
|
|
196
|
+
| `ca` | Catalan | [Francisco Javier Barrena](https://github.com/fjbarrena) |
|
|
197
|
+
| `cs` | Czech | [hanbar](https://github.com/hanbar) |
|
|
198
|
+
| `da` | Danish | [Rasmus Melchior Jacobsen](https://github.com/rmja) |
|
|
199
|
+
| `de` | German | [Michael Schuler](https://github.com/mschuler) |
|
|
200
|
+
| `es` | Spanish | [Ivan Santos](https://github.com/ivansg) |
|
|
201
|
+
| `fa` | Farsi | [A. Bahrami](https://github.com/alirezakoo) |
|
|
202
|
+
| `fi` | Finnish | [Mikael Rosenberg](https://github.com/MR77FI) |
|
|
203
|
+
| `fr` | French | [Arnaud TAMAILLON](https://github.com/Greybird) |
|
|
204
|
+
| `he` | Hebrew | [Ilan Firsov](https://github.com/IlanF) |
|
|
205
|
+
| `hr` | Croatian | [Rok Šekoranja](https://github.com/Rookxc) |
|
|
206
|
+
| `hu` | Hungarian | [Orcsity Norbert](https://github.com/Northber), Szabó Dániel |
|
|
207
|
+
| `id` | Indonesian | [Hasan Basri](https://github.com/hasanbasri1993) |
|
|
208
|
+
| `it` | Italian | [rinaldihno](https://github.com/rinaldihno) |
|
|
209
|
+
| `ja` | Japanese | [Alin Sarivan](https://github.com/asarivan) |
|
|
210
|
+
| `ko` | Korean | [Ion Mincu](https://github.com/ionmincu) |
|
|
211
|
+
| `my` | Malay (Malaysia) | [Ikhwan Abdullah](https://github.com/leychay) |
|
|
212
|
+
| `nb` | Norwegian (Bokmål) | [Siarhei Khalipski](https://github.com/KhalipskiSiarhei) |
|
|
213
|
+
| `nn` | Norwegian (Nynorsk) | [Arvind](https://github.com/arvindfroi) |
|
|
214
|
+
| `nl` | Dutch | [TotalMace](https://github.com/TotalMace) |
|
|
215
|
+
| `pl` | Polish | [foka](https://github.com/foka) |
|
|
216
|
+
| `pt_BR` | Portuguese (Brazil) | [Renato Lima](https://github.com/natenho) |
|
|
217
|
+
| `pt_PT` | Portuguese (Portugal) | [POFerro](https://github.com/POFerro) |
|
|
218
|
+
| `ro` | Romanian | [Illegitimis](https://github.com/illegitimis) |
|
|
219
|
+
| `ru` | Russian | [LbISS](https://github.com/LbISS) |
|
|
220
|
+
| `sk` | Slovak | [hanbar](https://github.com/hanbar) |
|
|
221
|
+
| `sl` | Slovenian | [Jani Bevk](https://github.com/jenzy) |
|
|
222
|
+
| `sw` | Swahili | [Leylow Lujuo](https://github.com/leyluj) |
|
|
223
|
+
| `sv` | Swedish | [roobin](https://github.com/roobin) |
|
|
224
|
+
| `sr` | Serbian | [Miloš Paunović](https://github.com/MilosPaunovic) |
|
|
225
|
+
| `tg` | Tajik | [Ismoil Vakhidov](https://github.com/ismoil77) |
|
|
226
|
+
| `th` | Thai | [Teerapat Prommarak](https://github.com/xeusteerapat) |
|
|
227
|
+
| `tr` | Turkish | [Mustafa SADEDİL](https://github.com/sadedil) |
|
|
228
|
+
| `uk` | Ukrainian | [Taras](https://github.com/tbudurovych) |
|
|
229
|
+
| `vi` | Vietnamese | [Nguyen Tan Phap](https://github.com/rikkapro0128) |
|
|
230
|
+
| `zh_CN` | Chinese (Simplified) | [Star Peng](https://github.com/starpeng) |
|
|
231
|
+
| `zh_TW` | Chinese (Traditional) | [Ricky Chiang](https://github.com/metavige) |
|
|
216
232
|
|
|
217
233
|
## Frequently Asked Questions
|
|
218
234
|
|
|
@@ -242,7 +258,7 @@ The following locales can be passed in for the `locale` option. Thank you to th
|
|
|
242
258
|
|
|
243
259
|
2. Can cRonstrue output the next occurrence of the cron expression?
|
|
244
260
|
|
|
245
|
-
No, cRonstrue does not support this. This library simply describes a cron expression that is passed in. You can do
|
|
261
|
+
No, cRonstrue does not support this. This library simply describes a cron expression that is passed in. You can do this with a library like [croner](https://www.npmjs.com/package/croner). Example:
|
|
246
262
|
|
|
247
263
|
```javascript
|
|
248
264
|
import { Cron } from 'croner';
|
|
@@ -255,12 +271,12 @@ The following locales can be passed in for the `locale` option. Thank you to th
|
|
|
255
271
|
|
|
256
272
|
Thank you to the following sponsors of this project!
|
|
257
273
|
|
|
258
|
-
<a href="https://github.com/microsoft"><img src="https://github.com/microsoft.png" width="50px" alt="
|
|
259
|
-
<a href="https://github.com/github"><img src="https://github.com/github.png" width="50px" alt="
|
|
260
|
-
<a href="https://github.com/DevUtilsApp"><img src="https://github.com/DevUtilsApp.png" width="50px" alt="
|
|
261
|
-
<a href="https://github.com/getsentry"><img src="https://github.com/getsentry.png" width="50px" alt="
|
|
262
|
-
<a href="https://github.com/KevinWang15"><img src="https://github.com/KevinWang15.png" width="50px" alt="
|
|
263
|
-
<a href="https://github.com/timheuer"><img src="https://github.com/timheuer.png" width="50px" alt="
|
|
274
|
+
<a href="https://github.com/microsoft"><img src="https://github.com/microsoft.png" width="50px" alt="microsoft" style="max-width: 100%;"></a>
|
|
275
|
+
<a href="https://github.com/github"><img src="https://github.com/github.png" width="50px" alt="github" style="max-width: 100%;"></a>
|
|
276
|
+
<a href="https://github.com/DevUtilsApp"><img src="https://github.com/DevUtilsApp.png" width="50px" alt="DevUtilsApp" style="max-width: 100%;"></a>
|
|
277
|
+
<a href="https://github.com/getsentry"><img src="https://github.com/getsentry.png" width="50px" alt="getsentry" style="max-width: 100%;"></a>
|
|
278
|
+
<a href="https://github.com/KevinWang15"><img src="https://github.com/KevinWang15.png" width="50px" alt="KevinWang15" style="max-width: 100%;"></a>
|
|
279
|
+
<a href="https://github.com/timheuer"><img src="https://github.com/timheuer.png" width="50px" alt="timheuer" style="max-width: 100%;"></a>
|
|
264
280
|
|
|
265
281
|
|
|
266
282
|
## License
|
package/dist/cronstrue-i18n.js
CHANGED
|
@@ -60,6 +60,21 @@ var CronParser = (function () {
|
|
|
60
60
|
}
|
|
61
61
|
this.normalize(parsed);
|
|
62
62
|
this.validate(parsed);
|
|
63
|
+
var hasWildcardItem = function (part) { return part.indexOf(",") > -1 && part.split(",").indexOf("*") > -1; };
|
|
64
|
+
for (var _i = 0, _b = [
|
|
65
|
+
[3, 5],
|
|
66
|
+
[5, 3],
|
|
67
|
+
]; _i < _b.length; _i++) {
|
|
68
|
+
var _c = _b[_i], part = _c[0], otherPart = _c[1];
|
|
69
|
+
if (hasWildcardItem(parsed[part]) && parsed[part][0] !== "*" && parsed[otherPart][0] !== "*") {
|
|
70
|
+
parsed[otherPart] = "*";
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
for (var i = 0; i < parsed.length; i++) {
|
|
74
|
+
if (hasWildcardItem(parsed[i])) {
|
|
75
|
+
parsed[i] = "*";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
63
78
|
return parsed;
|
|
64
79
|
};
|
|
65
80
|
CronParser.prototype.parseSpecial = function (expression) {
|
|
@@ -94,7 +109,9 @@ var CronParser = (function () {
|
|
|
94
109
|
if (arrayElement.length === 0) {
|
|
95
110
|
arrayElement.push("*");
|
|
96
111
|
}
|
|
97
|
-
arrayElement.
|
|
112
|
+
if (arrayElement.indexOf("*") === -1) {
|
|
113
|
+
arrayElement.sort(function (a, b) { return (a !== null && b !== null ? a - b : 0); });
|
|
114
|
+
}
|
|
98
115
|
parsed[i] = arrayElement.map(function (item) { return (item !== null ? item.toString() : ""); }).join(",");
|
|
99
116
|
}
|
|
100
117
|
}
|