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/dist/cronstrue.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
|
}
|
package/dist/cronstrue.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cronstrue",[],e):"object"==typeof exports?exports.cronstrue=e():t.cronstrue=e()}(globalThis,(()=>(()=>{"use strict";var t={6949(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.CronParser=void 0;var r=n(9515),o={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6},i={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12},a={4:"12",5:"6",6:"9999"},s=function(){function t(t,e,n){void 0===e&&(e=!0),void 0===n&&(n=!1),this.expression=t,this.dayOfWeekStartIndexZero=e,this.monthStartIndexZero=n}return t.prototype.parse=function(){var t,e,n=null!==(t=this.expression)&&void 0!==t?t:"";if("@reboot"===n)return e=["@reboot","","","","","",""];if(n.startsWith("@")){var r=this.parseSpecial(this.expression);e=this.extractParts(r)}else e=this.extractParts(this.expression);return this.normalize(e),this.validate(e),e},t.prototype.parseSpecial=function(t){var e={"@yearly":"0 0 1 JAN *","@annually":"0 0 1 JAN *","@monthly":"0 0 1 * *","@weekly":"0 0 * * SUN","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *"}[t];if(!e)throw new Error("Unknown special expression.");return e},t.prototype.extractParts=function(t){if(!this.expression)throw new Error("cron expression is empty");for(var e=t.trim().split(/[ ]+/),n=0;n<e.length;n++)if(e[n].includes(",")){var r=e[n].split(",").map((function(t){return t.trim()})).filter((function(t){return""!==t})).map((function(t){return isNaN(Number(t))?t:Number(t)})).filter((function(t){return null!==t&&""!==t}));0===r.length&&r.push("*"),r.sort((function(t,e){return null!==t&&null!==e?t-e:0})),e[n]=r.map((function(t){return null!==t?t.toString():""})).join(",")}if(e.length<5)throw new Error("Expression has only ".concat(e.length," part").concat(1==e.length?"":"s",". At least 5 parts are required."));if(5==e.length)e.unshift(""),e.push("");else if(6==e.length){/\d{4}$/.test(e[5])||"?"==e[4]||"?"==e[2]?e.unshift(""):e.push("")}else if(e.length>7)throw new Error("Expression has ".concat(e.length," parts; too many!"));return e},t.prototype.normalize=function(t){for(var e=this,n=0;n<t.length;n++)t[n]=t[n].toUpperCase();t[3]=t[3].replace("?","*"),t[5]=t[5].replace("?","*"),t[2]=t[2].replace("?","*");var r={0:"0/",1:"0/",2:"0/",3:"1/",6:"1/"};this.monthStartIndexZero||(r[4]="1/");for(var s=0,u=Object.keys(r).map(Number);s<u.length;s++){var c=u[s];0==t[c].indexOf(r[c])&&(t[c]=t[c].replace(r[c],"*/"))}this.dayOfWeekStartIndexZero&&(t[5]=t[5].split(",").map((function(t){return t.replace(/^0-7(?=\/|$)/,"0-6")})).join(",")),t[5]=t[5].replace(/(^\d+)|([^#/\s\d]\d+)/g,(function(t){var n=t.replace(/\D/,""),r=n;return e.dayOfWeekStartIndexZero?"7"==n&&(r="0"):r=(parseInt(n)-1).toString(),t.replace(n,r)})),t[5]=t[5].split(",").map((function(t){return"L"==t?"6":t})).join(",");if(t[3].indexOf("W")>-1&&(t[3].indexOf(",")>-1||/[-+]/.test(t[3]))&&!/^\d{1,2}W[+-]\d{1,2}$/.test(t[3]))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");for(var h in o)t[5]=t[5].replace(new RegExp(h,"gi"),o[h].toString());for(var f in t[5]=t[5].split(",").filter((function(t,e,n){return""===t||n.indexOf(t)===e})).join(","),t[4]=t[4].replace(/(^\d{1,2})|([^#/\s\d]\d{1,2})/g,(function(t){var n=t.replace(/\D/,""),r=n;return e.monthStartIndexZero&&(r=(parseInt(n)+1).toString()),t.replace(n,r)})),i)t[4]=t[4].replace(new RegExp(f,"gi"),i[f].toString());"0"==t[0]&&(t[0]=""),/\*|\-|\,|\//.test(t[2])||!/\*|\//.test(t[1])&&!/\*|\//.test(t[0])||(t[2]+="-".concat(t[2]));for(n=0;n<t.length;n++){-1!=t[n].indexOf(",")&&(t[n]=t[n].split(",").filter((function(t){return""!==t})).join(",")||"*"),"*/1"==t[n]&&(t[n]="*");var p=a[n];if(p&&t[n].indexOf("/")>-1&&!/^\*|\-|\,/.test(t[n])){var l=t[n].split("/");t[n]="".concat(l[0],"-").concat(p,"/").concat(l[1])}}},t.prototype.validate=function(t){var e="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(t[0],e),this.validateOnlyExpectedCharactersFound(t[1],e),this.validateOnlyExpectedCharactersFound(t[2],e),this.validateOnlyExpectedCharactersFound(t[3].replace(/^(\d{1,2}W)[+-]\d{1,2}$/,"$1"),"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(t[4],e),this.validateOnlyExpectedCharactersFound(t[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(t[6],e),this.validateAnyRanges(t)},t.prototype.validateAnyRanges=function(t){t.forEach((function(t){return r.default.stepRange(t)})),r.default.secondRange(t[0]),r.default.minuteRange(t[1]),r.default.hourRange(t[2]),r.default.dayOfMonthRange(t[3]),r.default.monthRange(t[4],this.monthStartIndexZero),r.default.dayOfWeekRange(t[5],this.dayOfWeekStartIndexZero)},t.prototype.validateOnlyExpectedCharactersFound=function(t,e){var n=t.match(new RegExp("[^".concat(e,"]+"),"gi"));if(n&&n.length)throw new Error("Expression contains invalid values: '".concat(n.toString(),"'"))},t}();e.CronParser=s},8333(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.ExpressionDescriptor=void 0;var o=n(1823),i=n(6949),a=new(n(9486).en),s=function(){function t(e,n){if(this.expression=e,this.options=n,this.expressionParts=[],!this.options.locale&&t.defaultLocale&&(this.options.locale=t.defaultLocale),!t.locales[this.options.locale]){var r=Object.keys(t.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(r,"'.")),this.options.locale=r}this.i18n=t.locales[this.options.locale],void 0===n.use24HourTimeFormat&&(n.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return t.toString=function(e,n){var r=void 0===n?{}:n,o=r.throwExceptionOnParseError,i=void 0===o||o,a=r.verbose,s=void 0!==a&&a,u=r.dayOfWeekStartIndexZero,c=void 0===u||u,h=r.monthStartIndexZero,f=void 0!==h&&h,p=r.use24HourTimeFormat,l=r.trimHoursLeadingZero,m=void 0!==l&&l,d=r.locale,y=void 0===d?null:d,g=r.logicalAndDayFields;return new t(e,{throwExceptionOnParseError:i,verbose:s,dayOfWeekStartIndexZero:c,monthStartIndexZero:f,use24HourTimeFormat:p,trimHoursLeadingZero:m,locale:y,logicalAndDayFields:void 0!==g&&g}).getFullDescription()},t.initialize=function(e,n){void 0===n&&(n="en"),t.specialCharacters=["/","-",",","*"],t.defaultLocale=n,e.load(t.locales)},t.prototype.getFullDescription=function(){var t,e,n="";try{var r=new i.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=r.parse(),"@reboot"===this.expressionParts[0])return(null===(e=(t=this.i18n).atReboot)||void 0===e?void 0:e.call(t))||a.atReboot();var o=this.getTimeOfDayDescription(),s=this.getDayOfMonthDescription(),u=this.getMonthDescription();n+=o+s+this.getDayOfWeekDescription()+u+this.getYearDescription(),n=(n=this.transformVerbosity(n,!!this.options.verbose)).charAt(0).toLocaleUpperCase()+n.substring(1)}catch(t){if(this.options.throwExceptionOnParseError)throw"".concat(t);n=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD()}return n},t.prototype.getTimeOfDayDescription=function(){var e=this.expressionParts[0],n=this.expressionParts[1],r=this.expressionParts[2],i="";if(o.StringUtilities.containsAny(n,t.specialCharacters)||o.StringUtilities.containsAny(r,t.specialCharacters)||o.StringUtilities.containsAny(e,t.specialCharacters))if(e||!(n.indexOf("-")>-1)||n.indexOf(",")>-1||n.indexOf("/")>-1||o.StringUtilities.containsAny(r,t.specialCharacters))if(!e&&r.indexOf(",")>-1&&-1==r.indexOf("-")&&-1==r.indexOf("/")&&!o.StringUtilities.containsAny(n,t.specialCharacters)){var a=r.split(",");i+=this.i18n.at();for(var s=0;s<a.length;s++)i&&(i+=" "),i+=this.formatTime(a[s],n,""),s<a.length-2&&(i+=","),s==a.length-2&&(i+=this.i18n.spaceAnd())}else{var u=this.getSecondsDescription(),c=this.getMinutesDescription(),h=this.getHoursDescription();if((i+=u)&&c&&(i+=", "),i+=c,c===h)return i;i&&h&&(i+=", "),i+=h}else{var f=n.split("-");i+=o.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(r,f[0],""),this.formatTime(r,f[1],""))}else i+=this.i18n.atSpace()+this.formatTime(r,n,e);return i},t.prototype.getSecondsDescription=function(){var t=this;return this.getSegmentDescription(this.expressionParts[0],{all:this.i18n.everySecond(),single:function(t){return t},increment:function(e){return o.StringUtilities.format(t.i18n.everyX0Seconds(e),e)},range:function(){return t.i18n.secondsX0ThroughX1PastTheMinute()},format:function(e){var n,r;return"0"==e?"":parseInt(e)<20?t.i18n.atX0SecondsPastTheMinute(e):(null===(r=(n=t.i18n).atX0SecondsPastTheMinuteGt20)||void 0===r?void 0:r.call(n))||t.i18n.atX0SecondsPastTheMinute(e)},bounds:{min:0,max:59}})},t.prototype.getMinutesDescription=function(){var t=this,e=this.expressionParts[0],n=this.expressionParts[2];return this.getSegmentDescription(this.expressionParts[1],{all:this.i18n.everyMinute(),single:function(t){return t},increment:function(e){return o.StringUtilities.format(t.i18n.everyX0Minutes(e),e)},range:function(){return t.i18n.minutesX0ThroughX1PastTheHour()},format:function(r){var o,i,a,s;return"0"==r&&-1==n.indexOf("/")&&""==e?t.i18n.everyHour():"0"==r?(null===(i=(o=t.i18n).onTheHour)||void 0===i?void 0:i.call(o))||t.i18n.atX0MinutesPastTheHour(r):parseInt(r)<20?t.i18n.atX0MinutesPastTheHour(r):(null===(s=(a=t.i18n).atX0MinutesPastTheHourGt20)||void 0===s?void 0:s.call(a))||t.i18n.atX0MinutesPastTheHour(r)},bounds:{min:0,max:59}})},t.prototype.getHoursDescription=function(){var t=this,e=this.expressionParts[2],n=0,r=[];e.split("/")[0].split(",").forEach((function(t){var e=t.split("-");2===e.length&&r.push({value:e[1],index:n+1}),n+=e.length}));var i=0;return this.getSegmentDescription(e,{all:this.i18n.everyHour(),single:function(e){var n=r.find((function(t){return t.value===e&&t.index===i}))&&"0"!==t.expressionParts[1];return i++,n?t.formatTime(e,"59",""):t.formatTime(e,"0","")},increment:function(e){return o.StringUtilities.format(t.i18n.everyX0Hours(e),e)},range:function(){return t.i18n.betweenX0AndX1()},format:function(){return t.i18n.atX0()},bounds:{min:0,max:23}})},t.prototype.getDayOfWeekDescription=function(e){var n=this;void 0===e&&(e=this.expressionParts[5]);var r=this.i18n.daysOfTheWeek(),i=null;if("*"==e)i="";else{var a=e.split(","),s=function(e,r){var o,i;return(null!==(o=n.getDayOfWeekDescription(e.join(",")))&&void 0!==o?o:"")+"".concat(n.i18n.spaceAnd()," ")+t.removeLeadingComma(null!==(i=n.getDayOfWeekDescription(r.join(",")))&&void 0!==i?i:"")},u=a.filter((function(t){return/[#L]/.test(t)})),c=a.filter((function(t){return!/[#L]/.test(t)}));if(c.length>0&&u.some((function(t){return t.indexOf("#")>-1})))return s(c,u);var h=a.filter((function(t){return t.indexOf("L")>-1})),f=a.filter((function(t){return-1===t.indexOf("L")}));if(h.length>0&&f.length>0)return s(f,h);var p="*"!=this.expressionParts[3]&&!this.options.logicalAndDayFields&&-1==e.indexOf(","),l=e.split("/"),m=l.length>1&&1!=parseInt(l[1]),d=this.getAndPrefix();i=this.getSegmentDescription(e,{all:this.i18n.commaEveryDay(),single:function(e,o){var i=e;e.indexOf("#")>-1?i=e.substring(0,e.indexOf("#")):e.indexOf("L")>-1&&(i=i.replace("L",""));var a=parseInt(i),s=n.i18n.daysOfTheWeekInCase?n.i18n.daysOfTheWeekInCase(o)[a]:r[a];if(e.indexOf("#")>-1){var u=parseInt(e.substring(e.indexOf("#")+1)),c=e.substring(0,e.indexOf("#")),h=t.ordinals[u-1];s=n.i18n[h](c)+" "+s}return s},increment:function(e){if(1==parseInt(e))return"";var r=n.i18n.commaEveryX0DaysOfTheWeek(e);return o.StringUtilities.format(p&&d?d+t.removeLeadingComma(r):r,e)},range:function(t){var e=t.substring(0,t.indexOf("-"));return!p||m&&d?n.i18n.commaX0ThroughX1(e):n.i18n.commaAndX0ThroughX1(e)},format:function(t){var e=null;if(t.indexOf("#")>-1){var r=t.substring(t.indexOf("#")+1),o=t.substring(0,t.indexOf("#"));e=n.i18n.commaOnThe(r,o).trim()+n.i18n.spaceX0OfTheMonth()}else if(t.indexOf("L")>-1)e=n.i18n.commaOnTheLastX0OfTheMonth(t.split(",")[0].replace("L",""));else{e="*"!=n.expressionParts[3]?n.options.logicalAndDayFields?n.i18n.commaOnlyOnX0(t):n.i18n.commaAndOnX0():n.i18n.commaOnlyOnX0(t)}return e}})}return i},t.prototype.getMonthDescription=function(){var t=this,e=this.i18n.monthsOfTheYear();return this.getSegmentDescription(this.expressionParts[4],{all:"",single:function(n,r){return r&&t.i18n.monthsOfTheYearInCase?t.i18n.monthsOfTheYearInCase(r)[parseInt(n)-1]:e[parseInt(n)-1]},increment:function(e){return 1==parseInt(e)?"":o.StringUtilities.format(t.i18n.commaEveryX0Months(e),e)},range:function(){var e,n;return(null===(n=(e=t.i18n).commaMonthX0ThroughMonthX1)||void 0===n?void 0:n.call(e))||t.i18n.commaX0ThroughX1()},format:function(){return t.i18n.commaOnlyInMonthX0?t.i18n.commaOnlyInMonthX0():t.i18n.commaOnlyInX0()}})},t.prototype.getAndPrefix=function(){var e=this.i18n.commaX0ThroughX1(),n=this.i18n.commaAndX0ThroughX1(),r=t.removeLeadingComma(e);return n==e||n.length<=r.length||n.slice(-r.length)!=r?null:n.slice(0,-r.length)},t.removeLeadingComma=function(t){return t.replace(/^[,،,、] ?/,"")},t.hasLeadingComma=function(t){return/^[,،,、]/.test(t)},t.prototype.getDayOfMonthDescription=function(e){var n,r,i,s,u=this;void 0===e&&(e=this.expressionParts[3]);var c=null,h=e,f=h.split(",");if(f.length>1){var p=function(t){return/^L-\d{1,2}$/.test(t)},l=f.filter((function(t){return p(t)})),m=f.filter((function(t){return!p(t)})).sort((function(t,e){return Number(t.indexOf("L")>-1)-Number(e.indexOf("L")>-1)}));if(l.length>0)return(m.length>0?[m.join(",")]:[]).concat(l).map((function(t){var e;return null!==(e=u.getDayOfMonthDescription(t))&&void 0!==e?e:""})).filter((function(t){return""!==t})).map((function(e,n){return 0===n?e:"".concat(u.i18n.spaceAnd()," ")+t.removeLeadingComma(e)})).join("");h=m.join(",")}switch(h){case"L":c=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":c=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var d=h.match(/^(?:(\d{1,2})W|W(\d{1,2}))(?:([+-])(\d{1,2}))?$/);if(d){var y=parseInt(d[1]||d[2]),g=1==y?this.i18n.firstWeekday():o.StringUtilities.format(this.i18n.weekdayNearestDayX0(),y.toString()),v=d[4];c=v?"-"==d[3]?o.StringUtilities.format((null===(r=(n=this.i18n).commaDaysBeforeTheX0OfTheMonth)||void 0===r?void 0:r.call(n,v))||a.commaDaysBeforeTheX0OfTheMonth(v),v,g):o.StringUtilities.format((null===(s=(i=this.i18n).commaDaysAfterTheX0OfTheMonth)||void 0===s?void 0:s.call(i,v))||a.commaDaysAfterTheX0OfTheMonth(v),v,g):o.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),g);break}var O=h.match(/L-(\d{1,2})/);if(O){var x=O[1];c=o.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(x),x);break}if("*"==h&&"*"!=this.expressionParts[5])return"";c=this.getSegmentDescription(h,{all:this.i18n.commaEveryDay(),single:function(t){return"L"==t?u.i18n.lastDay():u.i18n.dayX0?o.StringUtilities.format(u.i18n.dayX0(),t):t},increment:function(t){return"1"==t?u.i18n.commaEveryDay():u.i18n.commaEveryX0Days(t)},range:function(t){return u.i18n.commaBetweenDayX0AndX1OfTheMonth(t)},format:function(t){return"L"==t?u.i18n.commaOnTheLastDayOfTheMonth():u.i18n.commaOnDayX0OfTheMonth(t)}})}return c},t.prototype.getYearDescription=function(){var t=this;return this.getSegmentDescription(this.expressionParts[6],{all:"",single:function(t){return/^\d+$/.test(t)?new Date(parseInt(t),1).getFullYear().toString():t},increment:function(e){return o.StringUtilities.format(t.i18n.commaEveryX0Years(e),e)},range:function(){var e,n;return(null===(n=(e=t.i18n).commaYearX0ThroughYearX1)||void 0===n?void 0:n.call(e))||t.i18n.commaX0ThroughX1()},format:function(){return t.i18n.commaOnlyInYearX0?t.i18n.commaOnlyInYearX0():t.i18n.commaOnlyInX0()}})},t.prototype.getSegmentDescription=function(e,n){var i=r(r({},n),{bounds:void 0}),a=null,s=e.indexOf("/")>-1,u=e.indexOf("-")>-1,c=e.indexOf(",")>-1;if(e)if("*"===e)a=n.all;else if(s||u||c)if(c){for(var h=e.split(","),f="",p=this.i18n.spaceAnd(),l=0;l<h.length;l++)if(l>0&&h.length>2&&(f+=",",l<h.length-1&&(f+=" ")),l>0&&h.length>1&&(l==h.length-1||2==h.length)&&(f+=","==p&&h.length>2?" ":"".concat(p," ")),h[l].indexOf("/")>-1||h[l].indexOf("-")>-1){var m=h[l].indexOf("-")>-1&&-1==h[l].indexOf("/"),d=this.getSegmentDescription(h[l],m?r(r({},i),{range:this.i18n.commaX0ThroughX1}):i);(m||l>0)&&(d=t.removeLeadingComma(d)),f+=d}else if(s){var y=this.getSegmentDescription(h[l],i);l>0&&y&&(y=t.removeLeadingComma(y)),f+=y}else f+=n.single(h[l]);a=s?f:o.StringUtilities.format(n.format(e),f)}else if(s){h=e.split("/");if(a=o.StringUtilities.format(n.increment(h[1]),h[1]),h[0].indexOf("-")>-1){var g=this.generateRangeSegmentDescription(h[0],n);t.hasLeadingComma(g)||(a+=", "),a+=g}else if(-1==h[0].indexOf("*")){var v=o.StringUtilities.format(n.format(h[0]),n.single(h[0]));v=t.removeLeadingComma(v),a+=o.StringUtilities.format(this.i18n.commaStartingX0(),v)}a+=this.getWrappingIncrementDescription(e,n)}else u&&(a=this.generateRangeSegmentDescription(e,n));else a=o.StringUtilities.format(n.format(e),n.single(e));else a="";return a},t.prototype.getWrappingIncrementDescription=function(t,e){var n=e.bounds;if(!this.options.verbose||!n)return"";var o=t.split("/"),i=o[0],a=o[1],s=parseInt(a),u=n.max-n.min+1,c="*"===i,h=Number.isInteger(s)&&s>1;if(!c||!h||h&&u%s==0)return"";for(var f=[],p=n.min;p<=n.max;p+=s)f.push(p);if(f.length<2)return"";var l=this.getSegmentDescription(f.join(","),r(r({},e),{bounds:void 0}));return l?", ".concat(l):""},t.prototype.generateRangeSegmentDescription=function(t,e){var n=t.split("-");return o.StringUtilities.format(e.range(t),e.single(n[0],1),e.single(n[1],2))},t.prototype.formatTime=function(t,e,n){var r=parseInt(t),o=parseInt(e),i="",a=!1;this.options.use24HourTimeFormat||(i=(a=!(!this.i18n.setPeriodBeforeTime||!this.i18n.setPeriodBeforeTime()))?"".concat(this.getPeriod(r)," "):" ".concat(this.getPeriod(r)),r>12&&(r-=12),0===r&&(r=12));var s="";n&&(s=":".concat(("00"+n).substring(n.length)));var u=r.toString(),c=("00"+u).substring(u.length),h=o.toString(),f=("00"+h).substring(h.length),p=this.options.trimHoursLeadingZero?u:c;return"".concat(a?i:"").concat(p,":").concat(f).concat(s).concat(a?"":i)},t.prototype.transformVerbosity=function(t,e){if(!e&&(t=(t=(t=(t=t.replace(new RegExp(", ".concat(this.i18n.everyMinute(),"(?!\\s*[\\p{L}\\p{N}])"),"gu"),"")).replace(new RegExp(", ".concat(this.i18n.everyHour(),"(?!\\s*[\\p{L}\\p{N}])"),"gu"),"")).replace(new RegExp("".concat(this.i18n.commaEveryDay(),"(?!\\s*[\\p{L}\\p{N}])"),"gu"),"")).replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var n=0,r=Object.entries(this.i18n.conciseVerbosityReplacements());n<r.length;n++){var o=r[n],i=o[0],a=o[1];t=t.replace(new RegExp(i,"g"),a)}return t},t.prototype.getPeriod=function(t){var e,n,r,o;return t>=12?(null===(n=(e=this.i18n).pm)||void 0===n?void 0:n.call(e))||a.pm():(null===(o=(r=this.i18n).am)||void 0===o?void 0:o.call(r))||a.am()},t.locales={},t.ordinals=["first","second","third","fourth","fifth"],t}();e.ExpressionDescriptor=s},3747(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.enLocaleLoader=void 0;var r=n(9486),o=function(){function t(){}return t.prototype.load=function(t){t.en=new r.en},t}();e.enLocaleLoader=o},9486(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.en=void 0;var n=function(t){return 1===Number(t)},r=function(){function t(){}return t.prototype.use24HourTimeFormatByDefault=function(){return!1},t.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},t.prototype.everyMinute=function(){return"every minute"},t.prototype.everyHour=function(){return"every hour"},t.prototype.atSpace=function(){return"At "},t.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},t.prototype.at=function(){return"At"},t.prototype.spaceAnd=function(){return" and"},t.prototype.everySecond=function(){return"every second"},t.prototype.everyX0Seconds=function(t){return n(t)?"every %s second":"every %s seconds"},t.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},t.prototype.atX0SecondsPastTheMinute=function(t){return n(t)?"at %s second past the minute":"at %s seconds past the minute"},t.prototype.everyX0Minutes=function(t){return n(t)?"every %s minute":"every %s minutes"},t.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},t.prototype.atX0MinutesPastTheHour=function(t){return n(t)?"at %s minute past the hour":"at %s minutes past the hour"},t.prototype.everyX0Hours=function(t){return n(t)?"every %s hour":"every %s hours"},t.prototype.betweenX0AndX1=function(){return"between %s and %s"},t.prototype.atX0=function(){return"at %s"},t.prototype.commaEveryDay=function(){return", every day"},t.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},t.prototype.commaX0ThroughX1=function(){return", %s through %s"},t.prototype.commaAndX0ThroughX1=function(){return", and %s through %s"},t.prototype.first=function(){return"first"},t.prototype.second=function(){return"second"},t.prototype.third=function(){return"third"},t.prototype.fourth=function(){return"fourth"},t.prototype.fifth=function(){return"fifth"},t.prototype.commaOnThe=function(){return", on the "},t.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},t.prototype.lastDay=function(){return"the last day"},t.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},t.prototype.commaOnlyOnX0=function(){return", only on %s"},t.prototype.commaAndOnX0=function(){return", and on %s"},t.prototype.commaEveryX0Months=function(){return", every %s months"},t.prototype.commaOnlyInX0=function(){return", only in %s"},t.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},t.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},t.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(t){return n(t)?", %s day before the last day of the month":", %s days before the last day of the month"},t.prototype.firstWeekday=function(){return"first weekday"},t.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},t.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},t.prototype.commaDaysBeforeTheX0OfTheMonth=function(t){return n(t)?", %s day before the %s of the month":", %s days before the %s of the month"},t.prototype.commaDaysAfterTheX0OfTheMonth=function(t){return n(t)?", %s day after the %s of the month":", %s days after the %s of the month"},t.prototype.commaEveryX0Days=function(){return", every %s days in a month"},t.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},t.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},t.prototype.commaEveryHour=function(){return", every hour"},t.prototype.commaEveryX0Years=function(t){return n(t)?", every %s year":", every %s years"},t.prototype.commaStartingX0=function(){return", starting %s"},t.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},t.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},t.prototype.am=function(){return"AM"},t.prototype.pm=function(){return"PM"},t.prototype.atReboot=function(){return"Run once, at startup"},t.prototype.onTheHour=function(){return"on the hour"},t}();e.en=r},9515(t,e){function n(t,e){if(!t)throw new Error(e)}function r(t){var e=[];if(!isNaN(parseInt(t,10))){e.push(parseInt(t,10));var n=t.match(/^\d+-(-?\d+)/);n&&e.push(parseInt(n[1],10))}return e}function o(t,e,o,i){for(var a=0,s=t.split(",");a<s.length;a++)for(var u=0,c=r(s[a]);u<c.length;u++){var h=c[u];n(h>=e&&h<=o,i)}}Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(){}return t.stepRange=function(t){for(var e=0,r=t.split(",");e<r.length;e++){var o=r[e].split("/")[1];n(void 0===o||!/^0+$/.test(o),"step value must be greater than 0")}},t.secondRange=function(t){o(t,0,59,"seconds part must be >= 0 and <= 59")},t.minuteRange=function(t){o(t,0,59,"minutes part must be >= 0 and <= 59")},t.hourRange=function(t){o(t,0,23,"hours part must be >= 0 and <= 23")},t.dayOfMonthRange=function(t){o(t,1,31,"DOM part must be >= 1 and <= 31")},t.monthRange=function(t,e){o(t,1,12,e?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")},t.dayOfWeekRange=function(t,e){for(var r=0,i=t.split(",");r<i.length;r++){var a=i[r];if(a.indexOf("#")>-1){var s=a.substring(a.indexOf("#")+1);n(/^[1-5]$/.test(s),"DOW nth weekday must be >= 1 and <= 5")}}o(t,0,6,e?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")},t}();e.default=i},1823(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.StringUtilities=void 0;var n=function(){function t(){}return t.format=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return t.replace(/%s/g,(function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return e.shift()}))},t.containsAny=function(t,e){return e.some((function(e){return t.indexOf(e)>-1}))},t}();e.StringUtilities=n}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}var r={};return(()=>{var t=r;Object.defineProperty(t,"__esModule",{value:!0}),t.toString=void 0;var e=n(8333),o=n(3747);e.ExpressionDescriptor.initialize(new o.enLocaleLoader),t.default=e.ExpressionDescriptor;var i=e.ExpressionDescriptor.toString;t.toString=i})(),r})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cronstrue",[],t):"object"==typeof exports?exports.cronstrue=t():e.cronstrue=t()}(globalThis,(()=>(()=>{"use strict";var e={6949(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.CronParser=void 0;var r=n(9515),i={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6},o={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12},a={4:"12",5:"6",6:"9999"},s=function(){function e(e,t,n){void 0===t&&(t=!0),void 0===n&&(n=!1),this.expression=e,this.dayOfWeekStartIndexZero=t,this.monthStartIndexZero=n}return e.prototype.parse=function(){var e,t,n=null!==(e=this.expression)&&void 0!==e?e:"";if("@reboot"===n)return t=["@reboot","","","","","",""];if(n.startsWith("@")){var r=this.parseSpecial(this.expression);t=this.extractParts(r)}else t=this.extractParts(this.expression);this.normalize(t),this.validate(t);for(var i=function(e){return e.indexOf(",")>-1&&e.split(",").indexOf("*")>-1},o=0,a=[[3,5],[5,3]];o<a.length;o++){var s=a[o],u=s[0],c=s[1];i(t[u])&&"*"!==t[u][0]&&"*"!==t[c][0]&&(t[c]="*")}for(var h=0;h<t.length;h++)i(t[h])&&(t[h]="*");return t},e.prototype.parseSpecial=function(e){var t={"@yearly":"0 0 1 JAN *","@annually":"0 0 1 JAN *","@monthly":"0 0 1 * *","@weekly":"0 0 * * SUN","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *"}[e];if(!t)throw new Error("Unknown special expression.");return t},e.prototype.extractParts=function(e){if(!this.expression)throw new Error("cron expression is empty");for(var t=e.trim().split(/[ ]+/),n=0;n<t.length;n++)if(t[n].includes(",")){var r=t[n].split(",").map((function(e){return e.trim()})).filter((function(e){return""!==e})).map((function(e){return isNaN(Number(e))?e:Number(e)})).filter((function(e){return null!==e&&""!==e}));0===r.length&&r.push("*"),-1===r.indexOf("*")&&r.sort((function(e,t){return null!==e&&null!==t?e-t:0})),t[n]=r.map((function(e){return null!==e?e.toString():""})).join(",")}if(t.length<5)throw new Error("Expression has only ".concat(t.length," part").concat(1==t.length?"":"s",". At least 5 parts are required."));if(5==t.length)t.unshift(""),t.push("");else if(6==t.length){/\d{4}$/.test(t[5])||"?"==t[4]||"?"==t[2]?t.unshift(""):t.push("")}else if(t.length>7)throw new Error("Expression has ".concat(t.length," parts; too many!"));return t},e.prototype.normalize=function(e){for(var t=this,n=0;n<e.length;n++)e[n]=e[n].toUpperCase();e[3]=e[3].replace("?","*"),e[5]=e[5].replace("?","*"),e[2]=e[2].replace("?","*");var r={0:"0/",1:"0/",2:"0/",3:"1/",6:"1/"};this.monthStartIndexZero||(r[4]="1/");for(var s=0,u=Object.keys(r).map(Number);s<u.length;s++){var c=u[s];0==e[c].indexOf(r[c])&&(e[c]=e[c].replace(r[c],"*/"))}this.dayOfWeekStartIndexZero&&(e[5]=e[5].split(",").map((function(e){return e.replace(/^0-7(?=\/|$)/,"0-6")})).join(",")),e[5]=e[5].replace(/(^\d+)|([^#/\s\d]\d+)/g,(function(e){var n=e.replace(/\D/,""),r=n;return t.dayOfWeekStartIndexZero?"7"==n&&(r="0"):r=(parseInt(n)-1).toString(),e.replace(n,r)})),e[5]=e[5].split(",").map((function(e){return"L"==e?"6":e})).join(",");if(e[3].indexOf("W")>-1&&(e[3].indexOf(",")>-1||/[-+]/.test(e[3]))&&!/^\d{1,2}W[+-]\d{1,2}$/.test(e[3]))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");for(var h in i)e[5]=e[5].replace(new RegExp(h,"gi"),i[h].toString());for(var f in e[5]=e[5].split(",").filter((function(e,t,n){return""===e||n.indexOf(e)===t})).join(","),e[4]=e[4].replace(/(^\d{1,2})|([^#/\s\d]\d{1,2})/g,(function(e){var n=e.replace(/\D/,""),r=n;return t.monthStartIndexZero&&(r=(parseInt(n)+1).toString()),e.replace(n,r)})),o)e[4]=e[4].replace(new RegExp(f,"gi"),o[f].toString());"0"==e[0]&&(e[0]=""),/\*|\-|\,|\//.test(e[2])||!/\*|\//.test(e[1])&&!/\*|\//.test(e[0])||(e[2]+="-".concat(e[2]));for(n=0;n<e.length;n++){-1!=e[n].indexOf(",")&&(e[n]=e[n].split(",").filter((function(e){return""!==e})).join(",")||"*"),"*/1"==e[n]&&(e[n]="*");var p=a[n];if(p&&e[n].indexOf("/")>-1&&!/^\*|\-|\,/.test(e[n])){var l=e[n].split("/");e[n]="".concat(l[0],"-").concat(p,"/").concat(l[1])}}},e.prototype.validate=function(e){var t="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(e[0],t),this.validateOnlyExpectedCharactersFound(e[1],t),this.validateOnlyExpectedCharactersFound(e[2],t),this.validateOnlyExpectedCharactersFound(e[3].replace(/^(\d{1,2}W)[+-]\d{1,2}$/,"$1"),"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(e[4],t),this.validateOnlyExpectedCharactersFound(e[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(e[6],t),this.validateAnyRanges(e)},e.prototype.validateAnyRanges=function(e){e.forEach((function(e){return r.default.stepRange(e)})),r.default.secondRange(e[0]),r.default.minuteRange(e[1]),r.default.hourRange(e[2]),r.default.dayOfMonthRange(e[3]),r.default.monthRange(e[4],this.monthStartIndexZero),r.default.dayOfWeekRange(e[5],this.dayOfWeekStartIndexZero)},e.prototype.validateOnlyExpectedCharactersFound=function(e,t){var n=e.match(new RegExp("[^".concat(t,"]+"),"gi"));if(n&&n.length)throw new Error("Expression contains invalid values: '".concat(n.toString(),"'"))},e}();t.CronParser=s},8333(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.ExpressionDescriptor=void 0;var i=n(1823),o=n(6949),a=new(n(9486).en),s=function(){function e(t,n){if(this.expression=t,this.options=n,this.expressionParts=[],!this.options.locale&&e.defaultLocale&&(this.options.locale=e.defaultLocale),!e.locales[this.options.locale]){var r=Object.keys(e.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(r,"'.")),this.options.locale=r}this.i18n=e.locales[this.options.locale],void 0===n.use24HourTimeFormat&&(n.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return e.toString=function(t,n){var r=void 0===n?{}:n,i=r.throwExceptionOnParseError,o=void 0===i||i,a=r.verbose,s=void 0!==a&&a,u=r.dayOfWeekStartIndexZero,c=void 0===u||u,h=r.monthStartIndexZero,f=void 0!==h&&h,p=r.use24HourTimeFormat,l=r.trimHoursLeadingZero,d=void 0!==l&&l,m=r.locale,y=void 0===m?null:m,g=r.logicalAndDayFields;return new e(t,{throwExceptionOnParseError:o,verbose:s,dayOfWeekStartIndexZero:c,monthStartIndexZero:f,use24HourTimeFormat:p,trimHoursLeadingZero:d,locale:y,logicalAndDayFields:void 0!==g&&g}).getFullDescription()},e.initialize=function(t,n){void 0===n&&(n="en"),e.specialCharacters=["/","-",",","*"],e.defaultLocale=n,t.load(e.locales)},e.prototype.getFullDescription=function(){var e,t,n="";try{var r=new o.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=r.parse(),"@reboot"===this.expressionParts[0])return(null===(t=(e=this.i18n).atReboot)||void 0===t?void 0:t.call(e))||a.atReboot();var i=this.getTimeOfDayDescription(),s=this.getDayOfMonthDescription(),u=this.getMonthDescription();n+=i+s+this.getDayOfWeekDescription()+u+this.getYearDescription(),n=(n=this.transformVerbosity(n,!!this.options.verbose)).charAt(0).toLocaleUpperCase()+n.substring(1)}catch(e){if(this.options.throwExceptionOnParseError)throw"".concat(e);n=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD()}return n},e.prototype.getTimeOfDayDescription=function(){var t=this.expressionParts[0],n=this.expressionParts[1],r=this.expressionParts[2],o="";if(i.StringUtilities.containsAny(n,e.specialCharacters)||i.StringUtilities.containsAny(r,e.specialCharacters)||i.StringUtilities.containsAny(t,e.specialCharacters))if(t||!(n.indexOf("-")>-1)||n.indexOf(",")>-1||n.indexOf("/")>-1||i.StringUtilities.containsAny(r,e.specialCharacters))if(!t&&r.indexOf(",")>-1&&-1==r.indexOf("-")&&-1==r.indexOf("/")&&!i.StringUtilities.containsAny(n,e.specialCharacters)){var a=r.split(",");o+=this.i18n.at();for(var s=0;s<a.length;s++)o&&(o+=" "),o+=this.formatTime(a[s],n,""),s<a.length-2&&(o+=","),s==a.length-2&&(o+=this.i18n.spaceAnd())}else{var u=this.getSecondsDescription(),c=this.getMinutesDescription(),h=this.getHoursDescription();if((o+=u)&&c&&(o+=", "),o+=c,c===h)return o;o&&h&&(o+=", "),o+=h}else{var f=n.split("-");o+=i.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(r,f[0],""),this.formatTime(r,f[1],""))}else o+=this.i18n.atSpace()+this.formatTime(r,n,t);return o},e.prototype.getSecondsDescription=function(){var e=this;return this.getSegmentDescription(this.expressionParts[0],{all:this.i18n.everySecond(),single:function(e){return e},increment:function(t){return i.StringUtilities.format(e.i18n.everyX0Seconds(t),t)},range:function(){return e.i18n.secondsX0ThroughX1PastTheMinute()},format:function(t){var n,r;return"0"==t?"":parseInt(t)<20?e.i18n.atX0SecondsPastTheMinute(t):(null===(r=(n=e.i18n).atX0SecondsPastTheMinuteGt20)||void 0===r?void 0:r.call(n))||e.i18n.atX0SecondsPastTheMinute(t)},bounds:{min:0,max:59}})},e.prototype.getMinutesDescription=function(){var e=this,t=this.expressionParts[0],n=this.expressionParts[2];return this.getSegmentDescription(this.expressionParts[1],{all:this.i18n.everyMinute(),single:function(e){return e},increment:function(t){return i.StringUtilities.format(e.i18n.everyX0Minutes(t),t)},range:function(){return e.i18n.minutesX0ThroughX1PastTheHour()},format:function(r){var i,o,a,s;return"0"==r&&-1==n.indexOf("/")&&""==t?e.i18n.everyHour():"0"==r?(null===(o=(i=e.i18n).onTheHour)||void 0===o?void 0:o.call(i))||e.i18n.atX0MinutesPastTheHour(r):parseInt(r)<20?e.i18n.atX0MinutesPastTheHour(r):(null===(s=(a=e.i18n).atX0MinutesPastTheHourGt20)||void 0===s?void 0:s.call(a))||e.i18n.atX0MinutesPastTheHour(r)},bounds:{min:0,max:59}})},e.prototype.getHoursDescription=function(){var e=this,t=this.expressionParts[2],n=0,r=[];t.split("/")[0].split(",").forEach((function(e){var t=e.split("-");2===t.length&&r.push({value:t[1],index:n+1}),n+=t.length}));var o=0;return this.getSegmentDescription(t,{all:this.i18n.everyHour(),single:function(t){var n=r.find((function(e){return e.value===t&&e.index===o}))&&"0"!==e.expressionParts[1];return o++,n?e.formatTime(t,"59",""):e.formatTime(t,"0","")},increment:function(t){return i.StringUtilities.format(e.i18n.everyX0Hours(t),t)},range:function(){return e.i18n.betweenX0AndX1()},format:function(){return e.i18n.atX0()},bounds:{min:0,max:23}})},e.prototype.getDayOfWeekDescription=function(t){var n=this;void 0===t&&(t=this.expressionParts[5]);var r=this.i18n.daysOfTheWeek(),o=null;if("*"==t)o="";else{var a=t.split(","),s=function(t,r){var i,o;return(null!==(i=n.getDayOfWeekDescription(t.join(",")))&&void 0!==i?i:"")+"".concat(n.i18n.spaceAnd()," ")+e.removeLeadingComma(null!==(o=n.getDayOfWeekDescription(r.join(",")))&&void 0!==o?o:"")},u=a.filter((function(e){return/[#L]/.test(e)})),c=a.filter((function(e){return!/[#L]/.test(e)}));if(c.length>0&&u.some((function(e){return e.indexOf("#")>-1})))return s(c,u);var h=a.filter((function(e){return e.indexOf("L")>-1})),f=a.filter((function(e){return-1===e.indexOf("L")}));if(h.length>0&&f.length>0)return s(f,h);var p="*"!=this.expressionParts[3]&&!this.options.logicalAndDayFields&&-1==t.indexOf(","),l=t.split("/"),d=l.length>1&&1!=parseInt(l[1]),m=this.getAndPrefix();o=this.getSegmentDescription(t,{all:this.i18n.commaEveryDay(),single:function(t,i){var o=t;t.indexOf("#")>-1?o=t.substring(0,t.indexOf("#")):t.indexOf("L")>-1&&(o=o.replace("L",""));var a=parseInt(o),s=n.i18n.daysOfTheWeekInCase?n.i18n.daysOfTheWeekInCase(i)[a]:r[a];if(t.indexOf("#")>-1){var u=parseInt(t.substring(t.indexOf("#")+1)),c=t.substring(0,t.indexOf("#")),h=e.ordinals[u-1];s=n.i18n[h](c)+" "+s}return s},increment:function(t){if(1==parseInt(t))return"";var r=n.i18n.commaEveryX0DaysOfTheWeek(t);return i.StringUtilities.format(p&&m?m+e.removeLeadingComma(r):r,t)},range:function(e){var t=e.substring(0,e.indexOf("-"));return!p||d&&m?n.i18n.commaX0ThroughX1(t):n.i18n.commaAndX0ThroughX1(t)},format:function(e){var t=null;if(e.indexOf("#")>-1){var r=e.substring(e.indexOf("#")+1),i=e.substring(0,e.indexOf("#"));t=n.i18n.commaOnThe(r,i).trim()+n.i18n.spaceX0OfTheMonth()}else if(e.indexOf("L")>-1)t=n.i18n.commaOnTheLastX0OfTheMonth(e.split(",")[0].replace("L",""));else{t="*"!=n.expressionParts[3]?n.options.logicalAndDayFields?n.i18n.commaOnlyOnX0(e):n.i18n.commaAndOnX0():n.i18n.commaOnlyOnX0(e)}return t}})}return o},e.prototype.getMonthDescription=function(){var e=this,t=this.i18n.monthsOfTheYear();return this.getSegmentDescription(this.expressionParts[4],{all:"",single:function(n,r){return r&&e.i18n.monthsOfTheYearInCase?e.i18n.monthsOfTheYearInCase(r)[parseInt(n)-1]:t[parseInt(n)-1]},increment:function(t){return 1==parseInt(t)?"":i.StringUtilities.format(e.i18n.commaEveryX0Months(t),t)},range:function(){var t,n;return(null===(n=(t=e.i18n).commaMonthX0ThroughMonthX1)||void 0===n?void 0:n.call(t))||e.i18n.commaX0ThroughX1()},format:function(){return e.i18n.commaOnlyInMonthX0?e.i18n.commaOnlyInMonthX0():e.i18n.commaOnlyInX0()}})},e.prototype.getAndPrefix=function(){var t=this.i18n.commaX0ThroughX1(),n=this.i18n.commaAndX0ThroughX1(),r=e.removeLeadingComma(t);return n==t||n.length<=r.length||n.slice(-r.length)!=r?null:n.slice(0,-r.length)},e.removeLeadingComma=function(e){return e.replace(/^[,،,、] ?/,"")},e.hasLeadingComma=function(e){return/^[,،,、]/.test(e)},e.prototype.getDayOfMonthDescription=function(t){var n,r,o,s,u=this;void 0===t&&(t=this.expressionParts[3]);var c=null,h=t,f=h.split(",");if(f.length>1){var p=function(e){return/^L-\d{1,2}$/.test(e)},l=f.filter((function(e){return p(e)})),d=f.filter((function(e){return!p(e)})).sort((function(e,t){return Number(e.indexOf("L")>-1)-Number(t.indexOf("L")>-1)}));if(l.length>0)return(d.length>0?[d.join(",")]:[]).concat(l).map((function(e){var t;return null!==(t=u.getDayOfMonthDescription(e))&&void 0!==t?t:""})).filter((function(e){return""!==e})).map((function(t,n){return 0===n?t:"".concat(u.i18n.spaceAnd()," ")+e.removeLeadingComma(t)})).join("");h=d.join(",")}switch(h){case"L":c=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":c=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var m=h.match(/^(?:(\d{1,2})W|W(\d{1,2}))(?:([+-])(\d{1,2}))?$/);if(m){var y=parseInt(m[1]||m[2]),g=1==y?this.i18n.firstWeekday():i.StringUtilities.format(this.i18n.weekdayNearestDayX0(),y.toString()),v=m[4];c=v?"-"==m[3]?i.StringUtilities.format((null===(r=(n=this.i18n).commaDaysBeforeTheX0OfTheMonth)||void 0===r?void 0:r.call(n,v))||a.commaDaysBeforeTheX0OfTheMonth(v),v,g):i.StringUtilities.format((null===(s=(o=this.i18n).commaDaysAfterTheX0OfTheMonth)||void 0===s?void 0:s.call(o,v))||a.commaDaysAfterTheX0OfTheMonth(v),v,g):i.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),g);break}var O=h.match(/L-(\d{1,2})/);if(O){var x=O[1];c=i.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(x),x);break}if("*"==h&&"*"!=this.expressionParts[5])return"";c=this.getSegmentDescription(h,{all:this.i18n.commaEveryDay(),single:function(e){return"L"==e?u.i18n.lastDay():u.i18n.dayX0?i.StringUtilities.format(u.i18n.dayX0(),e):e},increment:function(e){return"1"==e?u.i18n.commaEveryDay():u.i18n.commaEveryX0Days(e)},range:function(e){return u.i18n.commaBetweenDayX0AndX1OfTheMonth(e)},format:function(e){return"L"==e?u.i18n.commaOnTheLastDayOfTheMonth():u.i18n.commaOnDayX0OfTheMonth(e)}})}return c},e.prototype.getYearDescription=function(){var e=this;return this.getSegmentDescription(this.expressionParts[6],{all:"",single:function(e){return/^\d+$/.test(e)?new Date(parseInt(e),1).getFullYear().toString():e},increment:function(t){return i.StringUtilities.format(e.i18n.commaEveryX0Years(t),t)},range:function(){var t,n;return(null===(n=(t=e.i18n).commaYearX0ThroughYearX1)||void 0===n?void 0:n.call(t))||e.i18n.commaX0ThroughX1()},format:function(){return e.i18n.commaOnlyInYearX0?e.i18n.commaOnlyInYearX0():e.i18n.commaOnlyInX0()}})},e.prototype.getSegmentDescription=function(t,n){var o=r(r({},n),{bounds:void 0}),a=null,s=t.indexOf("/")>-1,u=t.indexOf("-")>-1,c=t.indexOf(",")>-1;if(t)if("*"===t)a=n.all;else if(s||u||c)if(c){for(var h=t.split(","),f="",p=this.i18n.spaceAnd(),l=0;l<h.length;l++)if(l>0&&h.length>2&&(f+=",",l<h.length-1&&(f+=" ")),l>0&&h.length>1&&(l==h.length-1||2==h.length)&&(f+=","==p&&h.length>2?" ":"".concat(p," ")),h[l].indexOf("/")>-1||h[l].indexOf("-")>-1){var d=h[l].indexOf("-")>-1&&-1==h[l].indexOf("/"),m=this.getSegmentDescription(h[l],d?r(r({},o),{range:this.i18n.commaX0ThroughX1}):o);(d||l>0)&&(m=e.removeLeadingComma(m)),f+=m}else if(s){var y=this.getSegmentDescription(h[l],o);l>0&&y&&(y=e.removeLeadingComma(y)),f+=y}else f+=n.single(h[l]);a=s?f:i.StringUtilities.format(n.format(t),f)}else if(s){h=t.split("/");if(a=i.StringUtilities.format(n.increment(h[1]),h[1]),h[0].indexOf("-")>-1){var g=this.generateRangeSegmentDescription(h[0],n);e.hasLeadingComma(g)||(a+=", "),a+=g}else if(-1==h[0].indexOf("*")){var v=i.StringUtilities.format(n.format(h[0]),n.single(h[0]));v=e.removeLeadingComma(v),a+=i.StringUtilities.format(this.i18n.commaStartingX0(),v)}a+=this.getWrappingIncrementDescription(t,n)}else u&&(a=this.generateRangeSegmentDescription(t,n));else a=i.StringUtilities.format(n.format(t),n.single(t));else a="";return a},e.prototype.getWrappingIncrementDescription=function(e,t){var n=t.bounds;if(!this.options.verbose||!n)return"";var i=e.split("/"),o=i[0],a=i[1],s=parseInt(a),u=n.max-n.min+1,c="*"===o,h=Number.isInteger(s)&&s>1;if(!c||!h||h&&u%s==0)return"";for(var f=[],p=n.min;p<=n.max;p+=s)f.push(p);if(f.length<2)return"";var l=this.getSegmentDescription(f.join(","),r(r({},t),{bounds:void 0}));return l?", ".concat(l):""},e.prototype.generateRangeSegmentDescription=function(e,t){var n=e.split("-");return i.StringUtilities.format(t.range(e),t.single(n[0],1),t.single(n[1],2))},e.prototype.formatTime=function(e,t,n){var r=parseInt(e),i=parseInt(t),o="",a=!1;this.options.use24HourTimeFormat||(o=(a=!(!this.i18n.setPeriodBeforeTime||!this.i18n.setPeriodBeforeTime()))?"".concat(this.getPeriod(r)," "):" ".concat(this.getPeriod(r)),r>12&&(r-=12),0===r&&(r=12));var s="";n&&(s=":".concat(("00"+n).substring(n.length)));var u=r.toString(),c=("00"+u).substring(u.length),h=i.toString(),f=("00"+h).substring(h.length),p=this.options.trimHoursLeadingZero?u:c;return"".concat(a?o:"").concat(p,":").concat(f).concat(s).concat(a?"":o)},e.prototype.transformVerbosity=function(e,t){if(!t&&(e=(e=(e=(e=e.replace(new RegExp(", ".concat(this.i18n.everyMinute(),"(?!\\s*[\\p{L}\\p{N}])"),"gu"),"")).replace(new RegExp(", ".concat(this.i18n.everyHour(),"(?!\\s*[\\p{L}\\p{N}])"),"gu"),"")).replace(new RegExp("".concat(this.i18n.commaEveryDay(),"(?!\\s*[\\p{L}\\p{N}])"),"gu"),"")).replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var n=0,r=Object.entries(this.i18n.conciseVerbosityReplacements());n<r.length;n++){var i=r[n],o=i[0],a=i[1];e=e.replace(new RegExp(o,"g"),a)}return e},e.prototype.getPeriod=function(e){var t,n,r,i;return e>=12?(null===(n=(t=this.i18n).pm)||void 0===n?void 0:n.call(t))||a.pm():(null===(i=(r=this.i18n).am)||void 0===i?void 0:i.call(r))||a.am()},e.locales={},e.ordinals=["first","second","third","fourth","fifth"],e}();t.ExpressionDescriptor=s},3747(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.enLocaleLoader=void 0;var r=n(9486),i=function(){function e(){}return e.prototype.load=function(e){e.en=new r.en},e}();t.enLocaleLoader=i},9486(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.en=void 0;var n=function(e){return 1===Number(e)},r=function(){function e(){}return e.prototype.use24HourTimeFormatByDefault=function(){return!1},e.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},e.prototype.everyMinute=function(){return"every minute"},e.prototype.everyHour=function(){return"every hour"},e.prototype.atSpace=function(){return"At "},e.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},e.prototype.at=function(){return"At"},e.prototype.spaceAnd=function(){return" and"},e.prototype.everySecond=function(){return"every second"},e.prototype.everyX0Seconds=function(e){return n(e)?"every %s second":"every %s seconds"},e.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},e.prototype.atX0SecondsPastTheMinute=function(e){return n(e)?"at %s second past the minute":"at %s seconds past the minute"},e.prototype.everyX0Minutes=function(e){return n(e)?"every %s minute":"every %s minutes"},e.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},e.prototype.atX0MinutesPastTheHour=function(e){return n(e)?"at %s minute past the hour":"at %s minutes past the hour"},e.prototype.everyX0Hours=function(e){return n(e)?"every %s hour":"every %s hours"},e.prototype.betweenX0AndX1=function(){return"between %s and %s"},e.prototype.atX0=function(){return"at %s"},e.prototype.commaEveryDay=function(){return", every day"},e.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},e.prototype.commaX0ThroughX1=function(){return", %s through %s"},e.prototype.commaAndX0ThroughX1=function(){return", and %s through %s"},e.prototype.first=function(){return"first"},e.prototype.second=function(){return"second"},e.prototype.third=function(){return"third"},e.prototype.fourth=function(){return"fourth"},e.prototype.fifth=function(){return"fifth"},e.prototype.commaOnThe=function(){return", on the "},e.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},e.prototype.lastDay=function(){return"the last day"},e.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},e.prototype.commaOnlyOnX0=function(){return", only on %s"},e.prototype.commaAndOnX0=function(){return", and on %s"},e.prototype.commaEveryX0Months=function(){return", every %s months"},e.prototype.commaOnlyInX0=function(){return", only in %s"},e.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},e.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},e.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(e){return n(e)?", %s day before the last day of the month":", %s days before the last day of the month"},e.prototype.firstWeekday=function(){return"first weekday"},e.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},e.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},e.prototype.commaDaysBeforeTheX0OfTheMonth=function(e){return n(e)?", %s day before the %s of the month":", %s days before the %s of the month"},e.prototype.commaDaysAfterTheX0OfTheMonth=function(e){return n(e)?", %s day after the %s of the month":", %s days after the %s of the month"},e.prototype.commaEveryX0Days=function(){return", every %s days in a month"},e.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},e.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},e.prototype.commaEveryHour=function(){return", every hour"},e.prototype.commaEveryX0Years=function(e){return n(e)?", every %s year":", every %s years"},e.prototype.commaStartingX0=function(){return", starting %s"},e.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},e.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},e.prototype.am=function(){return"AM"},e.prototype.pm=function(){return"PM"},e.prototype.atReboot=function(){return"Run once, at startup"},e.prototype.onTheHour=function(){return"on the hour"},e}();t.en=r},9515(e,t){function n(e,t){if(!e)throw new Error(t)}function r(e){var t=[];if(!isNaN(parseInt(e,10))){t.push(parseInt(e,10));var n=e.match(/^\d+-(-?\d+)/);n&&t.push(parseInt(n[1],10))}return t}function i(e,t,i,o){for(var a=0,s=e.split(",");a<s.length;a++)for(var u=0,c=r(s[a]);u<c.length;u++){var h=c[u];n(h>=t&&h<=i,o)}}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(){}return e.stepRange=function(e){for(var t=0,r=e.split(",");t<r.length;t++){var i=r[t].split("/")[1];n(void 0===i||!/^0+$/.test(i),"step value must be greater than 0")}},e.secondRange=function(e){i(e,0,59,"seconds part must be >= 0 and <= 59")},e.minuteRange=function(e){i(e,0,59,"minutes part must be >= 0 and <= 59")},e.hourRange=function(e){i(e,0,23,"hours part must be >= 0 and <= 23")},e.dayOfMonthRange=function(e){i(e,1,31,"DOM part must be >= 1 and <= 31")},e.monthRange=function(e,t){i(e,1,12,t?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")},e.dayOfWeekRange=function(e,t){for(var r=0,o=e.split(",");r<o.length;r++){var a=o[r];if(a.indexOf("#")>-1){var s=a.substring(a.indexOf("#")+1);n(/^[1-5]$/.test(s),"DOW nth weekday must be >= 1 and <= 5")}}i(e,0,6,t?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")},e}();t.default=o},1823(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.StringUtilities=void 0;var n=function(){function e(){}return e.format=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return e.replace(/%s/g,(function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return t.shift()}))},e.containsAny=function(e,t){return t.some((function(t){return e.indexOf(t)>-1}))},e}();t.StringUtilities=n}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.toString=void 0;var t=n(8333),i=n(3747);t.ExpressionDescriptor.initialize(new i.enLocaleLoader),e.default=t.ExpressionDescriptor;var o=t.ExpressionDescriptor.toString;e.toString=o})(),r})()));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cronstrue",
|
|
3
3
|
"title": "cRonstrue",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.49.0",
|
|
5
5
|
"description": "Convert cron expressions into human readable descriptions",
|
|
6
6
|
"author": "Brady Holt",
|
|
7
7
|
"license": "MIT",
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
"cron for humans",
|
|
22
22
|
"cron translated",
|
|
23
23
|
"cron english",
|
|
24
|
-
"cron schedule",
|
|
25
|
-
"cron english",
|
|
26
24
|
"cron schedule"
|
|
27
25
|
],
|
|
28
26
|
"main": "dist/cronstrue.js",
|