cronstrue 3.49.0 → 3.51.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/dist/cronstrue-i18n.js +14 -3
- package/dist/cronstrue-i18n.min.js +1 -1
- package/dist/cronstrue.js +14 -3
- package/dist/cronstrue.min.js +1 -1
- package/i18n.d.ts +1 -1
- package/package.json +20 -1
package/dist/cronstrue.js
CHANGED
|
@@ -563,6 +563,17 @@ var ExpressionDescriptor = (function () {
|
|
|
563
563
|
return format;
|
|
564
564
|
},
|
|
565
565
|
});
|
|
566
|
+
var firstItem = dayOfWeekItems[0];
|
|
567
|
+
var isListWithStep = dayOfWeekItems.length > 1 && dayOfWeekExpression.indexOf("/") > -1;
|
|
568
|
+
var firstStep = firstItem.split("/")[1];
|
|
569
|
+
if (isListWithStep &&
|
|
570
|
+
andPrefix_1 &&
|
|
571
|
+
description &&
|
|
572
|
+
this.expressionParts[3] != "*" &&
|
|
573
|
+
!this.options.logicalAndDayFields &&
|
|
574
|
+
(firstStep === undefined ? firstItem.indexOf("-") > -1 : parseInt(firstStep) != 1)) {
|
|
575
|
+
description = andPrefix_1 + ExpressionDescriptor.removeLeadingComma(description);
|
|
576
|
+
}
|
|
566
577
|
}
|
|
567
578
|
return description;
|
|
568
579
|
};
|
|
@@ -721,9 +732,9 @@ var ExpressionDescriptor = (function () {
|
|
|
721
732
|
descriptionContent += conjunction == "," && segments.length > 2 ? " " : "".concat(conjunction, " ");
|
|
722
733
|
}
|
|
723
734
|
if (segments[i].indexOf("/") > -1 || segments[i].indexOf("-") > -1) {
|
|
724
|
-
var
|
|
725
|
-
var currentDescriptionContent = this.getSegmentDescription(segments[i],
|
|
726
|
-
if (
|
|
735
|
+
var isBareRange = !doesExpressionContainIncrement && segments[i].indexOf("-") > -1 && segments[i].indexOf("/") == -1;
|
|
736
|
+
var currentDescriptionContent = this.getSegmentDescription(segments[i], isBareRange ? __assign(__assign({}, itemDescribers), { range: this.i18n.commaX0ThroughX1 }) : itemDescribers);
|
|
737
|
+
if (isBareRange || i > 0) {
|
|
727
738
|
currentDescriptionContent = ExpressionDescriptor.removeLeadingComma(currentDescriptionContent);
|
|
728
739
|
}
|
|
729
740
|
descriptionContent += currentDescriptionContent;
|
package/dist/cronstrue.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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})()));
|
|
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}});var y=a[0],g=a.length>1&&t.indexOf("/")>-1,v=y.split("/")[1];g&&m&&o&&"*"!=this.expressionParts[3]&&!this.options.logicalAndDayFields&&(void 0===v?y.indexOf("-")>-1:1!=parseInt(v))&&(o=m+e.removeLeadingComma(o))}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=!s&&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/i18n.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cronstrue",
|
|
3
3
|
"title": "cRonstrue",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.51.0",
|
|
5
5
|
"description": "Convert cron expressions into human readable descriptions",
|
|
6
6
|
"author": "Brady Holt",
|
|
7
7
|
"license": "MIT",
|
|
@@ -28,6 +28,25 @@
|
|
|
28
28
|
"cronstrue": "bin/cli.js"
|
|
29
29
|
},
|
|
30
30
|
"typings": "dist/cronstrue.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/cronstrue.d.ts",
|
|
34
|
+
"default": "./dist/cronstrue.js"
|
|
35
|
+
},
|
|
36
|
+
"./i18n": {
|
|
37
|
+
"types": "./i18n.d.ts",
|
|
38
|
+
"default": "./i18n.js"
|
|
39
|
+
},
|
|
40
|
+
"./locales/*.js": "./locales/*.js",
|
|
41
|
+
"./locales/*": "./locales/*.js",
|
|
42
|
+
"./dist/*.js": "./dist/*.js",
|
|
43
|
+
"./dist/*.d.ts": "./dist/*.d.ts",
|
|
44
|
+
"./dist/*": "./dist/*.js",
|
|
45
|
+
"./bin/*.js": "./bin/*.js",
|
|
46
|
+
"./bin/*": "./bin/*.js",
|
|
47
|
+
"./package.json": "./package.json",
|
|
48
|
+
"./*": "./*"
|
|
49
|
+
},
|
|
31
50
|
"files": [
|
|
32
51
|
"dist/",
|
|
33
52
|
"locales/",
|