diff --git a/dist-legacy/croner.cjs b/dist-legacy/croner.cjs index be660e6..37492b2 100644 --- a/dist-legacy/croner.cjs +++ b/dist-legacy/croner.cjs @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Cron=e():t.Cron=e()}(this,(function(){return(()=>{"use strict";var t={d:(e,s)=>{for(var r in s)t.o(s,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:s[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>a});const s=Math.pow(2,31)-1;function r(t){throw new TypeError("Cron parser: "+t)}function n(t,e){for(let s=0;s=0;)s(r[n][0],t,r[n][2],0),n--;n++}for(;!t.daysOfWeek[this.getDate().getDay()];)this.days+=1},o.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds)},i.prototype.parse=function(){"string"!=typeof this.pattern&&this.pattern.constructor!==String&&r("Pattern has to be of type string.");let t,e,s,n,o,i=this.pattern.trim().replace(/\s+/g," ").split(" "),a=/[^/*0-9,-]+/;for(6!==i.length&&r("invalid configuration format ('"+this.pattern+"'), exacly five space separated parts required."),e=0;e1)for(n=0;n=u.length)&&r("Value out of range: '"+e+"'"),i>a&&r("From value is larger than to value: '"+e+"'"),n=i;n<=a;n++)u[n+s]=1;else if(-1!==e.indexOf("/"))for(o=e.split("/"),2!==o.length&&r("Syntax error, illegal stepping: '"+e+"'"),"*"!==o[0]&&r("Syntax error, left part of / needs to be * : '"+e+"'"),l=parseInt(o[1],10),isNaN(l)&&r("Syntax error, illegal stepping: (NaN)"),0===l&&r("Syntax error, illegal stepping: 0"),l>u.length&&r("Syntax error, steps cannot be greater than maximum value of part ("+u.length+")"),n=0;n=u.length)&&r(t+" value out of range: '"+e+"'"),u[n]=1;else for(n=0;n=s?void 0:e},a.prototype.validateOpts=function(t){return t.startAt&&(t.startAt.constructor!==Date?t.startAt=new Date(Date.parse(t.startAt)-1):t.startAt=new Date(t.startAt.getTime()-1),isNaN(t.startAt)&&r("Provided value for startAt could not be parsed as date.")),t.stopAt&&(t.stopAt.constructor!==Date&&(t.stopAt=new Date(Date.parse(t.stopAt))),isNaN(t.stopAt)&&r("Provided value for stopAt could not be parsed as date.")),t},a.prototype.msToNext=function(t){t=t||new Date;let e=this._next(t);return e?this._next(t)-t.getTime():e},a.prototype.schedule=function(t,e){let r,n=this,o=n.maxDelay||s;if(e||(e=t,t={}),t.paused=void 0!==t.paused&&t.paused,t.kill=t.kill||this.schedulerDefaults.kill,t.rest=t.rest||0,t.maxRuns||0===t.maxRuns||(t.maxRuns=this.schedulerDefaults.maxRuns),n.opts=n.validateOpts(t||{}),r=this.msToNext(t.previous),void 0!==r)return r>o&&(r=o),t.currentTimeout=setTimeout((function(){r!==o&&(t.paused||(t.maxRuns--,e()),t.previous=new Date),n.schedule(t,e)}),r),{stop:function(){t.kill=!0,t.currentTimeout&&clearTimeout(t.currentTimeout)},pause:function(){return(t.paused=!0)&&!t.kill},resume:function(){return!(t.paused=!1)&&!t.kill}}},e.default})()})); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Cron=e():t.Cron=e()}(this,(function(){return(()=>{"use strict";var t={d:(e,s)=>{for(var r in s)t.o(s,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:s[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>l});const s=Math.pow(2,31)-1;function r(t){throw new TypeError("Cron parser: "+t)}function n(t,e){for(let s=0;s=0;)s(r[n][0],t,r[n][2],0),n--;n++}for(;!t.daysOfWeek[this.getDate().getDay()];)this.days+=1},o.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds)},i.prototype.parse=function(){"string"!=typeof this.pattern&&this.pattern.constructor!==String&&r("Pattern has to be of type string.");let t,e,s,n,o,i=this.pattern.trim().replace(/\s+/g," ").split(" "),a=/[^/*0-9,-]+/;for(6!==i.length&&r("invalid configuration format ('"+this.pattern+"'), exacly five space separated parts required."),e=0;e1)for(n=0;n=u.length)&&r("Value out of range: '"+e+"'"),i>a&&r("From value is larger than to value: '"+e+"'"),n=i;n<=a;n++)u[n+s]=1;else if(-1!==e.indexOf("/"))for(o=e.split("/"),2!==o.length&&r("Syntax error, illegal stepping: '"+e+"'"),"*"!==o[0]&&r("Syntax error, left part of / needs to be * : '"+e+"'"),l=parseInt(o[1],10),isNaN(l)&&r("Syntax error, illegal stepping: (NaN)"),0===l&&r("Syntax error, illegal stepping: 0"),l>u.length&&r("Syntax error, steps cannot be greater than maximum value of part ("+u.length+")"),n=0;n=u.length)&&r(t+" value out of range: '"+e+"'"),u[n]=1;else for(n=0;n=s?void 0:e},a.prototype.validateOpts=function(t){return t.startAt&&(t.startAt.constructor!==Date?t.startAt=new Date(Date.parse(t.startAt)-1):t.startAt=new Date(t.startAt.getTime()-1),isNaN(t.startAt)&&r("Provided value for startAt could not be parsed as date.")),t.stopAt&&(t.stopAt.constructor!==Date&&(t.stopAt=new Date(Date.parse(t.stopAt))),isNaN(t.stopAt)&&r("Provided value for stopAt could not be parsed as date.")),t},a.prototype.msToNext=function(t){t=t||new Date;let e=this._next(t);return e?this._next(t)-t.getTime():e},a.prototype.schedule=function(t,e){let r,n=this,o=n.maxDelay||s;if(e||(e=t,t={}),t.paused=void 0!==t.paused&&t.paused,t.kill=t.kill||this.schedulerDefaults.kill,t.rest=t.rest||0,t.maxRuns||0===t.maxRuns||(t.maxRuns=this.schedulerDefaults.maxRuns),n.opts=n.validateOpts(t||{}),r=this.msToNext(t.previous),void 0!==r)return r>o&&(r=o),t.currentTimeout=setTimeout((function(){r!==o&&(t.paused||(t.maxRuns--,e()),t.previous=new Date),n.schedule(t,e)}),r),{stop:function(){t.kill=!0,t.currentTimeout&&clearTimeout(t.currentTimeout)},pause:function(){return(t.paused=!0)&&!t.kill},resume:function(){return!(t.paused=!1)&&!t.kill}}};const l=a;return e.default})()})); \ No newline at end of file diff --git a/dist/croner.min.js b/dist/croner.min.js index be660e6..37492b2 100644 --- a/dist/croner.min.js +++ b/dist/croner.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Cron=e():t.Cron=e()}(this,(function(){return(()=>{"use strict";var t={d:(e,s)=>{for(var r in s)t.o(s,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:s[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>a});const s=Math.pow(2,31)-1;function r(t){throw new TypeError("Cron parser: "+t)}function n(t,e){for(let s=0;s=0;)s(r[n][0],t,r[n][2],0),n--;n++}for(;!t.daysOfWeek[this.getDate().getDay()];)this.days+=1},o.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds)},i.prototype.parse=function(){"string"!=typeof this.pattern&&this.pattern.constructor!==String&&r("Pattern has to be of type string.");let t,e,s,n,o,i=this.pattern.trim().replace(/\s+/g," ").split(" "),a=/[^/*0-9,-]+/;for(6!==i.length&&r("invalid configuration format ('"+this.pattern+"'), exacly five space separated parts required."),e=0;e1)for(n=0;n=u.length)&&r("Value out of range: '"+e+"'"),i>a&&r("From value is larger than to value: '"+e+"'"),n=i;n<=a;n++)u[n+s]=1;else if(-1!==e.indexOf("/"))for(o=e.split("/"),2!==o.length&&r("Syntax error, illegal stepping: '"+e+"'"),"*"!==o[0]&&r("Syntax error, left part of / needs to be * : '"+e+"'"),l=parseInt(o[1],10),isNaN(l)&&r("Syntax error, illegal stepping: (NaN)"),0===l&&r("Syntax error, illegal stepping: 0"),l>u.length&&r("Syntax error, steps cannot be greater than maximum value of part ("+u.length+")"),n=0;n=u.length)&&r(t+" value out of range: '"+e+"'"),u[n]=1;else for(n=0;n=s?void 0:e},a.prototype.validateOpts=function(t){return t.startAt&&(t.startAt.constructor!==Date?t.startAt=new Date(Date.parse(t.startAt)-1):t.startAt=new Date(t.startAt.getTime()-1),isNaN(t.startAt)&&r("Provided value for startAt could not be parsed as date.")),t.stopAt&&(t.stopAt.constructor!==Date&&(t.stopAt=new Date(Date.parse(t.stopAt))),isNaN(t.stopAt)&&r("Provided value for stopAt could not be parsed as date.")),t},a.prototype.msToNext=function(t){t=t||new Date;let e=this._next(t);return e?this._next(t)-t.getTime():e},a.prototype.schedule=function(t,e){let r,n=this,o=n.maxDelay||s;if(e||(e=t,t={}),t.paused=void 0!==t.paused&&t.paused,t.kill=t.kill||this.schedulerDefaults.kill,t.rest=t.rest||0,t.maxRuns||0===t.maxRuns||(t.maxRuns=this.schedulerDefaults.maxRuns),n.opts=n.validateOpts(t||{}),r=this.msToNext(t.previous),void 0!==r)return r>o&&(r=o),t.currentTimeout=setTimeout((function(){r!==o&&(t.paused||(t.maxRuns--,e()),t.previous=new Date),n.schedule(t,e)}),r),{stop:function(){t.kill=!0,t.currentTimeout&&clearTimeout(t.currentTimeout)},pause:function(){return(t.paused=!0)&&!t.kill},resume:function(){return!(t.paused=!1)&&!t.kill}}},e.default})()})); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Cron=e():t.Cron=e()}(this,(function(){return(()=>{"use strict";var t={d:(e,s)=>{for(var r in s)t.o(s,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:s[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>l});const s=Math.pow(2,31)-1;function r(t){throw new TypeError("Cron parser: "+t)}function n(t,e){for(let s=0;s=0;)s(r[n][0],t,r[n][2],0),n--;n++}for(;!t.daysOfWeek[this.getDate().getDay()];)this.days+=1},o.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds)},i.prototype.parse=function(){"string"!=typeof this.pattern&&this.pattern.constructor!==String&&r("Pattern has to be of type string.");let t,e,s,n,o,i=this.pattern.trim().replace(/\s+/g," ").split(" "),a=/[^/*0-9,-]+/;for(6!==i.length&&r("invalid configuration format ('"+this.pattern+"'), exacly five space separated parts required."),e=0;e1)for(n=0;n=u.length)&&r("Value out of range: '"+e+"'"),i>a&&r("From value is larger than to value: '"+e+"'"),n=i;n<=a;n++)u[n+s]=1;else if(-1!==e.indexOf("/"))for(o=e.split("/"),2!==o.length&&r("Syntax error, illegal stepping: '"+e+"'"),"*"!==o[0]&&r("Syntax error, left part of / needs to be * : '"+e+"'"),l=parseInt(o[1],10),isNaN(l)&&r("Syntax error, illegal stepping: (NaN)"),0===l&&r("Syntax error, illegal stepping: 0"),l>u.length&&r("Syntax error, steps cannot be greater than maximum value of part ("+u.length+")"),n=0;n=u.length)&&r(t+" value out of range: '"+e+"'"),u[n]=1;else for(n=0;n=s?void 0:e},a.prototype.validateOpts=function(t){return t.startAt&&(t.startAt.constructor!==Date?t.startAt=new Date(Date.parse(t.startAt)-1):t.startAt=new Date(t.startAt.getTime()-1),isNaN(t.startAt)&&r("Provided value for startAt could not be parsed as date.")),t.stopAt&&(t.stopAt.constructor!==Date&&(t.stopAt=new Date(Date.parse(t.stopAt))),isNaN(t.stopAt)&&r("Provided value for stopAt could not be parsed as date.")),t},a.prototype.msToNext=function(t){t=t||new Date;let e=this._next(t);return e?this._next(t)-t.getTime():e},a.prototype.schedule=function(t,e){let r,n=this,o=n.maxDelay||s;if(e||(e=t,t={}),t.paused=void 0!==t.paused&&t.paused,t.kill=t.kill||this.schedulerDefaults.kill,t.rest=t.rest||0,t.maxRuns||0===t.maxRuns||(t.maxRuns=this.schedulerDefaults.maxRuns),n.opts=n.validateOpts(t||{}),r=this.msToNext(t.previous),void 0!==r)return r>o&&(r=o),t.currentTimeout=setTimeout((function(){r!==o&&(t.paused||(t.maxRuns--,e()),t.previous=new Date),n.schedule(t,e)}),r),{stop:function(){t.kill=!0,t.currentTimeout&&clearTimeout(t.currentTimeout)},pause:function(){return(t.paused=!0)&&!t.kill},resume:function(){return!(t.paused=!1)&&!t.kill}}};const l=a;return e.default})()})); \ No newline at end of file diff --git a/dist/croner.min.mjs b/dist/croner.min.mjs index 1d857ba..7603e60 100644 --- a/dist/croner.min.mjs +++ b/dist/croner.min.mjs @@ -1 +1 @@ -var t={d:(e,s)=>{for(var r in s)t.o(s,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:s[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{P:()=>i,Z:()=>i});const s=Math.pow(2,31)-1;function r(t){throw new TypeError("Cron parser: "+t)}function n(t,e){for(let s=0;s=0;)s(r[n][0],t,r[n][2],0),n--;n++}for(;!t.daysOfWeek[this.getDate().getDay()];)this.days+=1},a.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds)},o.prototype.parse=function(){"string"!=typeof this.pattern&&this.pattern.constructor!==String&&r("Pattern has to be of type string.");let t,e,s,n,a,o=this.pattern.trim().replace(/\s+/g," ").split(" "),i=/[^/*0-9,-]+/;for(6!==o.length&&r("invalid configuration format ('"+this.pattern+"'), exacly five space separated parts required."),e=0;e1)for(n=0;n=u.length)&&r("Value out of range: '"+e+"'"),o>i&&r("From value is larger than to value: '"+e+"'"),n=o;n<=i;n++)u[n+s]=1;else if(-1!==e.indexOf("/"))for(a=e.split("/"),2!==a.length&&r("Syntax error, illegal stepping: '"+e+"'"),"*"!==a[0]&&r("Syntax error, left part of / needs to be * : '"+e+"'"),l=parseInt(a[1],10),isNaN(l)&&r("Syntax error, illegal stepping: (NaN)"),0===l&&r("Syntax error, illegal stepping: 0"),l>u.length&&r("Syntax error, steps cannot be greater than maximum value of part ("+u.length+")"),n=0;n=u.length)&&r(t+" value out of range: '"+e+"'"),u[n]=1;else for(n=0;n=s?void 0:e},i.prototype.validateOpts=function(t){return t.startAt&&(t.startAt.constructor!==Date?t.startAt=new Date(Date.parse(t.startAt)-1):t.startAt=new Date(t.startAt.getTime()-1),isNaN(t.startAt)&&r("Provided value for startAt could not be parsed as date.")),t.stopAt&&(t.stopAt.constructor!==Date&&(t.stopAt=new Date(Date.parse(t.stopAt))),isNaN(t.stopAt)&&r("Provided value for stopAt could not be parsed as date.")),t},i.prototype.msToNext=function(t){t=t||new Date;let e=this._next(t);return e?this._next(t)-t.getTime():e},i.prototype.schedule=function(t,e){let r,n=this,a=n.maxDelay||s;if(e||(e=t,t={}),t.paused=void 0!==t.paused&&t.paused,t.kill=t.kill||this.schedulerDefaults.kill,t.rest=t.rest||0,t.maxRuns||0===t.maxRuns||(t.maxRuns=this.schedulerDefaults.maxRuns),n.opts=n.validateOpts(t||{}),r=this.msToNext(t.previous),void 0!==r)return r>a&&(r=a),t.currentTimeout=setTimeout((function(){r!==a&&(t.paused||(t.maxRuns--,e()),t.previous=new Date),n.schedule(t,e)}),r),{stop:function(){t.kill=!0,t.currentTimeout&&clearTimeout(t.currentTimeout)},pause:function(){return(t.paused=!0)&&!t.kill},resume:function(){return!(t.paused=!1)&&!t.kill}}};var l=e.P,u=e.Z;export{l as Cron,u as default}; \ No newline at end of file +var t={d:(e,s)=>{for(var r in s)t.o(s,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:s[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{Z:()=>l,P:()=>i});const s=Math.pow(2,31)-1;function r(t){throw new TypeError("Cron parser: "+t)}function n(t,e){for(let s=0;s=0;)s(r[n][0],t,r[n][2],0),n--;n++}for(;!t.daysOfWeek[this.getDate().getDay()];)this.days+=1},a.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds)},o.prototype.parse=function(){"string"!=typeof this.pattern&&this.pattern.constructor!==String&&r("Pattern has to be of type string.");let t,e,s,n,a,o=this.pattern.trim().replace(/\s+/g," ").split(" "),i=/[^/*0-9,-]+/;for(6!==o.length&&r("invalid configuration format ('"+this.pattern+"'), exacly five space separated parts required."),e=0;e1)for(n=0;n=u.length)&&r("Value out of range: '"+e+"'"),o>i&&r("From value is larger than to value: '"+e+"'"),n=o;n<=i;n++)u[n+s]=1;else if(-1!==e.indexOf("/"))for(a=e.split("/"),2!==a.length&&r("Syntax error, illegal stepping: '"+e+"'"),"*"!==a[0]&&r("Syntax error, left part of / needs to be * : '"+e+"'"),l=parseInt(a[1],10),isNaN(l)&&r("Syntax error, illegal stepping: (NaN)"),0===l&&r("Syntax error, illegal stepping: 0"),l>u.length&&r("Syntax error, steps cannot be greater than maximum value of part ("+u.length+")"),n=0;n=u.length)&&r(t+" value out of range: '"+e+"'"),u[n]=1;else for(n=0;n=s?void 0:e},i.prototype.validateOpts=function(t){return t.startAt&&(t.startAt.constructor!==Date?t.startAt=new Date(Date.parse(t.startAt)-1):t.startAt=new Date(t.startAt.getTime()-1),isNaN(t.startAt)&&r("Provided value for startAt could not be parsed as date.")),t.stopAt&&(t.stopAt.constructor!==Date&&(t.stopAt=new Date(Date.parse(t.stopAt))),isNaN(t.stopAt)&&r("Provided value for stopAt could not be parsed as date.")),t},i.prototype.msToNext=function(t){t=t||new Date;let e=this._next(t);return e?this._next(t)-t.getTime():e},i.prototype.schedule=function(t,e){let r,n=this,a=n.maxDelay||s;if(e||(e=t,t={}),t.paused=void 0!==t.paused&&t.paused,t.kill=t.kill||this.schedulerDefaults.kill,t.rest=t.rest||0,t.maxRuns||0===t.maxRuns||(t.maxRuns=this.schedulerDefaults.maxRuns),n.opts=n.validateOpts(t||{}),r=this.msToNext(t.previous),void 0!==r)return r>a&&(r=a),t.currentTimeout=setTimeout((function(){r!==a&&(t.paused||(t.maxRuns--,e()),t.previous=new Date),n.schedule(t,e)}),r),{stop:function(){t.kill=!0,t.currentTimeout&&clearTimeout(t.currentTimeout)},pause:function(){return(t.paused=!0)&&!t.kill},resume:function(){return!(t.paused=!1)&&!t.kill}}};const l=i;var u=e.P,p=e.Z;export{u as Cron,p as default}; \ No newline at end of file diff --git a/package.json b/package.json index bcc2cfc..6a89ecc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "croner", - "version": "3.0.38", + "version": "3.0.39", "description": "Isomorphic JavaScript cron parser and scheduler.", "author": "Hexagon ", "contributors": [ diff --git a/src/croner.js b/src/croner.js index b41cfa6..c42cd3f 100644 --- a/src/croner.js +++ b/src/croner.js @@ -676,4 +676,6 @@ Cron.prototype.schedule = function (opts, func) { }; }; -export { Cron, Cron as default}; \ No newline at end of file + +export default Cron; +export { Cron }; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index f0fb5f0..801149b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "allowJs": true, "declaration": true, "emitDeclarationOnly": true, + "esModuleInterop": true, "outDir": "types" } } \ No newline at end of file diff --git a/types/croner.d.ts b/types/croner.d.ts index 03b787d..bd05abf 100644 --- a/types/croner.d.ts +++ b/types/croner.d.ts @@ -1,3 +1,4 @@ +export default Cron; export type CronPatternPart = "seconds" | "minutes" | "hours" | "days" | "months" | "daysOfWeek"; export type CronIndexOffset = 0 | -1; export type CronNextResult = Date | undefined; @@ -154,4 +155,3 @@ declare class CronPattern { */ partToArray(type: CronPatternPart, conf: string, valueIndexOffset: CronIndexOffset): void; } -export { Cron as default };