cronstrue 3.14.0 → 3.18.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 CHANGED
@@ -105,18 +105,8 @@ By default, only the English translation (`en`) is included when you import and
105
105
  ### CLI Usage
106
106
 
107
107
  ```sh
108
- $ npm install -g cronstrue
109
-
110
- $ cronstrue 1 2 3 4 5
111
- At 02:01 AM, on day 3 of the month, and on Friday, only in April
112
-
113
- $ cronstrue 1 2 3
114
- Error: too few arguments (3): 1 2 3
115
- Usage (5 args): cronstrue minute hour day-of-month month day-of-week
116
- or
117
- Usage (6 args): cronstrue second minute hour day-of-month month day-of-week
118
- or
119
- Usage (7 args): cronstrue second minute hour day-of-month month day-of-week year
108
+ npx cronstrue "*/5 * * * *"
109
+ Every 5 minutes
120
110
  ```
121
111
 
122
112
  ## Options
@@ -228,25 +218,36 @@ The following locales can be passed in for the `locale` option. Thank you to th
228
218
 
229
219
  This library does not do full validation of cron expressions and assumes the expression passed in is valid. If you need to validate an expression consider using a library like [cron-parser](https://www.npmjs.com/package/cron-parser). Example validation with cron-parser:
230
220
 
231
- ```
232
- const cronParser = require("cron-parser");
233
- const cronstrue = require("cronstrue");
221
+ ```javascript
222
+ import { CronExpressionParser } from "cron-parser";
223
+ import cronstrue from "cronstrue";
234
224
 
235
225
  const expression = "* * * * * *";
236
226
 
237
- // Validate expression first
238
- let isCronValid = true;
239
- try { cronParser.parseExpression(expression) } catch(e) { isCronValid = false; }
227
+ const isCronValid = (() => {
228
+ try {
229
+ CronExpressionParser.parse(expression);
230
+ return true;
231
+ } catch {
232
+ return false;
233
+ }
234
+ })();
240
235
 
241
- // If valid, then pass into cRonstrue
242
236
  if (isCronValid) {
243
- console.log(cronstrue.toString("* * * * *"));
237
+ console.log(cronstrue.toString(expression));
244
238
  }
245
239
  ```
246
240
 
247
241
  2. Can cRonstrue output the next occurrence of the cron expression?
248
242
 
249
- No, cRonstrue does not support this. This library simply describes a cron expression that is passed in.
243
+ No, cRonstrue does not support this. This library simply describes a cron expression that is passed in. You can do with with a library like [croner](https://www.npmjs.com/package/croner). Example:
244
+
245
+ ```javascript
246
+ import { Cron } from 'croner';
247
+ const job = new Cron('0 9 * * 1-5');
248
+ console.log(job.nextRun()); // next Date
249
+ console.log(job.nextRuns(5)); // next 5 Dates
250
+ ```
250
251
 
251
252
  ## Sponsors
252
253
 
@@ -364,7 +364,9 @@ var ExpressionDescriptor = (function () {
364
364
  var hourParts = hourExpression.split(",");
365
365
  description += this.i18n.at();
366
366
  for (var i = 0; i < hourParts.length; i++) {
367
- description += " ";
367
+ if (description) {
368
+ description += " ";
369
+ }
368
370
  description += this.formatTime(hourParts[i], minuteExpression, "");
369
371
  if (i < hourParts.length - 2) {
370
372
  description += ",";
@@ -652,6 +654,7 @@ var ExpressionDescriptor = (function () {
652
654
  else if (doesExpressionContainMultipleValues) {
653
655
  var segments = expression.split(",");
654
656
  var descriptionContent = "";
657
+ var conjunction = this.i18n.spaceAnd();
655
658
  for (var i = 0; i < segments.length; i++) {
656
659
  if (i > 0 && segments.length > 2) {
657
660
  descriptionContent += ",";
@@ -660,7 +663,7 @@ var ExpressionDescriptor = (function () {
660
663
  }
661
664
  }
662
665
  if (i > 0 && segments.length > 1 && (i == segments.length - 1 || segments.length == 2)) {
663
- descriptionContent += "".concat(this.i18n.spaceAnd(), " ");
666
+ descriptionContent += conjunction == "," && segments.length > 2 ? " " : "".concat(conjunction, " ");
664
667
  }
665
668
  if (segments[i].indexOf("/") > -1 || segments[i].indexOf("-") > -1) {
666
669
  var isSegmentRangeWithoutIncrement = segments[i].indexOf("-") > -1 && segments[i].indexOf("/") == -1;
@@ -791,7 +794,7 @@ exports.ExpressionDescriptor = ExpressionDescriptor;
791
794
 
792
795
 
793
796
  Object.defineProperty(exports, "__esModule", ({ value: true }));
794
- exports.sr = exports.hr = exports.bg = exports.my = exports.vi = exports.ar = exports.th = exports.af = exports.hu = exports.be = exports.ca = exports.fa = exports.sw = exports.sl = exports.fi = exports.sk = exports.cs = exports.he = exports.ja = exports.zh_TW = exports.zh_CN = exports.uk = exports.tr = exports.ru = exports.ro = exports.pt_PT = exports.pt_BR = exports.pl = exports.sv = exports.nb = exports.nl = exports.ko = exports.id = exports.it = exports.fr = exports.es = exports.de = exports.da = exports.en = void 0;
797
+ exports.sr = exports.hr = exports.bg = exports.my = exports.vi = exports.ar = exports.th = exports.af = exports.hu = exports.be = exports.ca = exports.fa = exports.sw = exports.sl = exports.fi = exports.sk = exports.cs = exports.he = exports.ja = exports.zh_TW = exports.zh_CN = exports.uk = exports.tr = exports.ru = exports.ro = exports.pt_PT = exports.pt_BR = exports.pl = exports.sv = exports.nn = exports.nb = exports.nl = exports.ko = exports.id = exports.it = exports.fr = exports.es = exports.de = exports.da = exports.en = void 0;
795
798
  var en_1 = __webpack_require__(486);
796
799
  Object.defineProperty(exports, "en", ({ enumerable: true, get: function () { return en_1.en; } }));
797
800
  var da_1 = __webpack_require__(506);
@@ -812,6 +815,8 @@ var nl_1 = __webpack_require__(647);
812
815
  Object.defineProperty(exports, "nl", ({ enumerable: true, get: function () { return nl_1.nl; } }));
813
816
  var nb_1 = __webpack_require__(957);
814
817
  Object.defineProperty(exports, "nb", ({ enumerable: true, get: function () { return nb_1.nb; } }));
818
+ var nn_1 = __webpack_require__(633);
819
+ Object.defineProperty(exports, "nn", ({ enumerable: true, get: function () { return nn_1.nn; } }));
815
820
  var sv_1 = __webpack_require__(544);
816
821
  Object.defineProperty(exports, "sv", ({ enumerable: true, get: function () { return sv_1.sv; } }));
817
822
  var pl_1 = __webpack_require__(905);
@@ -4547,16 +4552,16 @@ var ko = (function () {
4547
4552
  return "1시간마다";
4548
4553
  };
4549
4554
  ko.prototype.atSpace = function () {
4550
- return "시간 ";
4555
+ return "";
4551
4556
  };
4552
4557
  ko.prototype.everyMinuteBetweenX0AndX1 = function () {
4553
4558
  return "매분 %s~%s";
4554
4559
  };
4555
4560
  ko.prototype.at = function () {
4556
- return "시간";
4561
+ return "";
4557
4562
  };
4558
4563
  ko.prototype.spaceAnd = function () {
4559
- return "";
4564
+ return ",";
4560
4565
  };
4561
4566
  ko.prototype.everySecond = function () {
4562
4567
  return "1초마다";
@@ -4583,7 +4588,7 @@ var ko = (function () {
4583
4588
  return "%s시간마다";
4584
4589
  };
4585
4590
  ko.prototype.betweenX0AndX1 = function () {
4586
- return "%s에서 %s 사이";
4591
+ return "%s부터 %s까지";
4587
4592
  };
4588
4593
  ko.prototype.atX0 = function () {
4589
4594
  return "%s에서";
@@ -4595,10 +4600,10 @@ var ko = (function () {
4595
4600
  return ", 주 중 %s일마다";
4596
4601
  };
4597
4602
  ko.prototype.commaX0ThroughX1 = function () {
4598
- return ", %s에서 %s까지";
4603
+ return ", %s부터 %s까지";
4599
4604
  };
4600
4605
  ko.prototype.commaAndX0ThroughX1 = function () {
4601
- return ", %s에서 %s까지";
4606
+ return ", %s부터 %s까지";
4602
4607
  };
4603
4608
  ko.prototype.first = function () {
4604
4609
  return "첫 번째";
@@ -4631,7 +4636,7 @@ var ko = (function () {
4631
4636
  return ", %s에만";
4632
4637
  };
4633
4638
  ko.prototype.commaAndOnX0 = function () {
4634
- return ", %s에";
4639
+ return ", %s에";
4635
4640
  };
4636
4641
  ko.prototype.commaEveryX0Months = function () {
4637
4642
  return ", %s개월마다";
@@ -5259,6 +5264,194 @@ var nl = (function () {
5259
5264
  exports.nl = nl;
5260
5265
 
5261
5266
 
5267
+ /***/ },
5268
+
5269
+ /***/ 633
5270
+ (__unused_webpack_module, exports) {
5271
+
5272
+
5273
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
5274
+ exports.nn = void 0;
5275
+ var nn = (function () {
5276
+ function nn() {
5277
+ }
5278
+ nn.prototype.atX0SecondsPastTheMinuteGt20 = function () {
5279
+ return null;
5280
+ };
5281
+ nn.prototype.atX0MinutesPastTheHourGt20 = function () {
5282
+ return null;
5283
+ };
5284
+ nn.prototype.commaMonthX0ThroughMonthX1 = function () {
5285
+ return null;
5286
+ };
5287
+ nn.prototype.commaYearX0ThroughYearX1 = function () {
5288
+ return null;
5289
+ };
5290
+ nn.prototype.use24HourTimeFormatByDefault = function () {
5291
+ return true;
5292
+ };
5293
+ nn.prototype.anErrorOccuredWhenGeneratingTheExpressionD = function () {
5294
+ return "Ein feil oppstod ved generering av uttrykksskildring. Sjekk cron-syntaksen.";
5295
+ };
5296
+ nn.prototype.at = function () {
5297
+ return "Kl.";
5298
+ };
5299
+ nn.prototype.atSpace = function () {
5300
+ return "Kl.";
5301
+ };
5302
+ nn.prototype.atX0 = function () {
5303
+ return "på %s";
5304
+ };
5305
+ nn.prototype.atX0MinutesPastTheHour = function () {
5306
+ return "på %s minutt etter timen";
5307
+ };
5308
+ nn.prototype.atX0SecondsPastTheMinute = function () {
5309
+ return "på %s sekund etter minuttet";
5310
+ };
5311
+ nn.prototype.betweenX0AndX1 = function () {
5312
+ return "mellom %s og %s";
5313
+ };
5314
+ nn.prototype.commaBetweenDayX0AndX1OfTheMonth = function () {
5315
+ return ", mellom dag %s og %s av månaden";
5316
+ };
5317
+ nn.prototype.commaEveryDay = function () {
5318
+ return ", kvar dag";
5319
+ };
5320
+ nn.prototype.commaEveryX0Days = function () {
5321
+ return ", kvar %s dag";
5322
+ };
5323
+ nn.prototype.commaEveryX0DaysOfTheWeek = function () {
5324
+ return ", kvar %s vekedag";
5325
+ };
5326
+ nn.prototype.commaEveryX0Months = function () {
5327
+ return ", kvar %s månad";
5328
+ };
5329
+ nn.prototype.commaEveryX0Years = function () {
5330
+ return ", kvart %s år";
5331
+ };
5332
+ nn.prototype.commaOnDayX0OfTheMonth = function () {
5333
+ return ", på dag %s av månaden";
5334
+ };
5335
+ nn.prototype.commaOnlyInX0 = function () {
5336
+ return ", berre i %s";
5337
+ };
5338
+ nn.prototype.commaOnlyOnX0 = function () {
5339
+ return ", på %s";
5340
+ };
5341
+ nn.prototype.commaAndOnX0 = function () {
5342
+ return ", og på %s";
5343
+ };
5344
+ nn.prototype.commaOnThe = function () {
5345
+ return ", på ";
5346
+ };
5347
+ nn.prototype.commaOnTheLastDayOfTheMonth = function () {
5348
+ return ", på den siste dagen i månaden";
5349
+ };
5350
+ nn.prototype.commaOnTheLastWeekdayOfTheMonth = function () {
5351
+ return ", den siste vekedagen i månaden";
5352
+ };
5353
+ nn.prototype.commaDaysBeforeTheLastDayOfTheMonth = function () {
5354
+ return ", %s dagar før den siste dagen i månaden";
5355
+ };
5356
+ nn.prototype.commaOnTheLastX0OfTheMonth = function () {
5357
+ return ", på den siste %s av månaden";
5358
+ };
5359
+ nn.prototype.commaOnTheX0OfTheMonth = function () {
5360
+ return ", på den %s av månaden";
5361
+ };
5362
+ nn.prototype.commaX0ThroughX1 = function () {
5363
+ return ", %s til og med %s";
5364
+ };
5365
+ nn.prototype.commaAndX0ThroughX1 = function () {
5366
+ return ", og %s til og med %s";
5367
+ };
5368
+ nn.prototype.everyHour = function () {
5369
+ return "kvar time";
5370
+ };
5371
+ nn.prototype.everyMinute = function () {
5372
+ return "kvart minutt";
5373
+ };
5374
+ nn.prototype.everyMinuteBetweenX0AndX1 = function () {
5375
+ return "Kvart minutt mellom %s og %s";
5376
+ };
5377
+ nn.prototype.everySecond = function () {
5378
+ return "kvart sekund";
5379
+ };
5380
+ nn.prototype.everyX0Hours = function () {
5381
+ return "kvar %s time";
5382
+ };
5383
+ nn.prototype.everyX0Minutes = function () {
5384
+ return "kvart %s minutt";
5385
+ };
5386
+ nn.prototype.everyX0Seconds = function () {
5387
+ return "kvart %s sekund";
5388
+ };
5389
+ nn.prototype.fifth = function () {
5390
+ return "femte";
5391
+ };
5392
+ nn.prototype.first = function () {
5393
+ return "første";
5394
+ };
5395
+ nn.prototype.firstWeekday = function () {
5396
+ return "første vekedag";
5397
+ };
5398
+ nn.prototype.fourth = function () {
5399
+ return "fjerde";
5400
+ };
5401
+ nn.prototype.minutesX0ThroughX1PastTheHour = function () {
5402
+ return "minutta frå %s til og med %s etter timen";
5403
+ };
5404
+ nn.prototype.second = function () {
5405
+ return "andre";
5406
+ };
5407
+ nn.prototype.secondsX0ThroughX1PastTheMinute = function () {
5408
+ return "sekunda frå %s til og med %s etter minuttet";
5409
+ };
5410
+ nn.prototype.spaceAnd = function () {
5411
+ return " og";
5412
+ };
5413
+ nn.prototype.spaceX0OfTheMonth = function () {
5414
+ return " %s i månaden";
5415
+ };
5416
+ nn.prototype.lastDay = function () {
5417
+ return "den siste dagen";
5418
+ };
5419
+ nn.prototype.third = function () {
5420
+ return "tredje";
5421
+ };
5422
+ nn.prototype.weekdayNearestDayX0 = function () {
5423
+ return "vekedag nærmast dag %s";
5424
+ };
5425
+ nn.prototype.commaStartingX0 = function () {
5426
+ return ", startar %s";
5427
+ };
5428
+ nn.prototype.daysOfTheWeek = function () {
5429
+ return ["sundag", "måndag", "tysdag", "onsdag", "torsdag", "fredag", "laurdag"];
5430
+ };
5431
+ nn.prototype.monthsOfTheYear = function () {
5432
+ return [
5433
+ "januar",
5434
+ "februar",
5435
+ "mars",
5436
+ "april",
5437
+ "mai",
5438
+ "juni",
5439
+ "juli",
5440
+ "august",
5441
+ "september",
5442
+ "oktober",
5443
+ "november",
5444
+ "desember",
5445
+ ];
5446
+ };
5447
+ nn.prototype.onTheHour = function () {
5448
+ return "på timen";
5449
+ };
5450
+ return nn;
5451
+ }());
5452
+ exports.nn = nn;
5453
+
5454
+
5262
5455
  /***/ },
5263
5456
 
5264
5457
  /***/ 905