Comparing version 4.0.52 to 4.0.53
@@ -1,1 +0,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,r)=>{for(var s in r)t.o(r,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:r[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>i});function r(t,e){if(this.timezone=e,t&&t instanceof Date)this.fromDate(t);else if(void 0===t)this.fromDate(new Date);else if(t&&"string"==typeof t)this.fromString(t);else{if(!(t instanceof r))throw new TypeError("CronDate: Invalid type passed as parameter to CronDate constructor");this.fromCronDate(t)}}function s(t){this.pattern=t,this.seconds=Array(60).fill(0),this.minutes=Array(60).fill(0),this.hours=Array(24).fill(0),this.days=Array(31).fill(0),this.months=Array(12).fill(0),this.daysOfWeek=Array(8).fill(0),this.parse()}r.prototype.fromDate=function(t){let e=t.getTime();this.timezone&&(t=function(t,e){return new Date(t.toLocaleString("en-US",{timeZone:e}))}(t,this.timezone));let r=t.getTime();this.UTCmsOffset=r-e,this.milliseconds=t.getMilliseconds(),this.seconds=t.getSeconds(),this.minutes=t.getMinutes(),this.hours=t.getHours(),this.days=t.getDate(),this.months=t.getMonth(),this.years=t.getFullYear()},r.prototype.fromCronDate=function(t){this.UTCmsOffset=t.UTCmsOffset,this.timezone=t.timezone;let e=new Date(t.years,t.months,t.days,t.hours,t.minutes,t.seconds,t.milliseconds);this.milliseconds=e.getMilliseconds(),this.seconds=e.getSeconds(),this.minutes=e.getMinutes(),this.hours=e.getHours(),this.days=e.getDate(),this.months=e.getMonth(),this.years=e.getFullYear()},r.prototype.fromString=function(t){let e=Date.parse(t);if(isNaN(e))throw new TypeError("CronDate: Provided string value for CronDate could not be parsed as date.");this.fromDate(new Date(e))},r.prototype.increment=function(t,e){e||(this.seconds+=1);let s=this.getTime();this.milliseconds=0;let o=this,n=function(t,e,r,s){for(let n=void 0===s?o[t]+r:0+r;n<e[t].length;n++)if(e[t][n])return o[t]=n-r,!0;return!1},i=function(){for(;h>=0;)n(a[h][0],t,a[h][2],0),h--},a=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]],h=0;for(;h<5;)n(a[h][0],t,a[h][2])||(this[a[h][1]]++,i()),h++;for(;!t.daysOfWeek[this.getDate().getDay()];)this.days+=1,h=2,i();return s!=o.getTime()?(o=new r(o),this.years>=4e3?null:o.increment(t,!0)):this},r.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds-this.UTCmsOffset)},r.prototype.getTime=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds-this.UTCmsOffset).getTime()},s.prototype.parse=function(){if("string"!=typeof this.pattern&&this.pattern.constructor!==String)throw new TypeError("CronPattern: Pattern has to be of type string.");let t,e,r=this.pattern.trim().replace(/\s+/g," ").split(" "),s=/[^/*0-9,-]+/;if(r.length<5||r.length>6)throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exacly five or six space separated parts required.");for(5===r.length&&r.unshift("0"),e=0;e<r.length;e++)if(t=r[e].trim(),s.test(t))throw new TypeError("CronPattern: configuration entry "+(e+1)+" ("+t+") contains illegal characters.");this.partToArray("seconds",r[0],0),this.partToArray("minutes",r[1],0),this.partToArray("hours",r[2],0),this.partToArray("days",r[3],-1),this.partToArray("months",r[4],-1),this.partToArray("daysOfWeek",r[5],0),this.daysOfWeek[7]&&(this.daysOfWeek[0]=1)},s.prototype.partToArray=function(t,e,r){let s,o,n,i,a,h=this[t];if("*"!==e)if(o=e.split(","),o.length>1)for(s=0;s<o.length;s++)this.partToArray(t,o[s],r);else if(-1!==e.indexOf("-")){if(o=e.split("-"),2!==o.length)throw new TypeError("CronPattern: Syntax error, illegal range: '"+e+"'");if(n=parseInt(o[0],10)+r,i=parseInt(o[1],10)+r,isNaN(n))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(i))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(n<0||i>=h.length)throw new TypeError("CronPattern: Value out of range: '"+e+"'");if(n>i)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(s=n;s<=i;s++)h[s+r]=1}else if(-1!==e.indexOf("/")){if(o=e.split("/"),2!==o.length)throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+e+"'");if("*"!==o[0])throw new TypeError("CronPattern: Syntax error, left part of / needs to be * : '"+e+"'");if(a=parseInt(o[1],10),isNaN(a))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(0===a)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(a>h.length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+h.length+")");for(s=0;s<h.length;s+=a)h[s+r]=1}else{if(s=parseInt(e,10)+r,s<0||s>=h.length)throw new TypeError("CronPattern: "+t+" value out of range: '"+e+"'");h[s]=1}else for(s=0;s<h.length;s++)h[s]=1};const o=Math.pow(2,31)-1;function n(t,e,r){let o=this;return this instanceof n?(o.pattern=new s(t),o.schedulerDefaults={maxRuns:1/0,kill:!1,paused:!1},"function"==typeof e&&(r=e,e=void 0),void 0===e&&(e={}),e.paused=void 0===e.paused?o.schedulerDefaults.paused:e.paused,e.maxRuns=void 0===e.maxRuns?o.schedulerDefaults.maxRuns:e.maxRuns,e.kill=this.schedulerDefaults.kill,o.opts=o.validateOpts(e),void 0!==r&&this.schedule(r),this):new n(t,e,r)}n.prototype.next=function(t){let e=this._next(t);return e?e.getDate():null},n.prototype.previous=function(){return this.opts.previous?this.opts.previous.getDate():null},n.prototype._next=function(t){t=new r(t,this.opts.timezone),this.opts.startAt&&t&&t.getTime()<this.opts.startAt.getTime()&&(t=new r(this.opts.startAt,this.opts.timezone));let e=new r(t,this.opts.timezone).increment(this.pattern);return null===e||this.opts.maxRuns<=0||this.opts.kill||this.opts.stopAt&&e.getTime()>=this.opts.stopAt.getTime()?null:e},n.prototype.validateOpts=function(t){return t.startAt&&(t.startAt=new r(t.startAt,t.timezone)),t.stopAt&&(t.stopAt=new r(t.stopAt,t.timezone)),t},n.prototype.msToNext=function(t){t=t||new r(void 0,this.opts.timezone);let e=this._next(t);return e?e.getTime()-t.getTime():null},n.prototype.stop=function(){this.opts.kill=!0,this.opts.currentTimeout&&clearTimeout(this.opts.currentTimeout)},n.prototype.pause=function(){return(this.opts.paused=!0)&&!this.opts.kill},n.prototype.resume=function(){return!(this.opts.paused=!1)&&!this.opts.kill},n.prototype.schedule=function(t){let e=this,s=this.msToNext(e.opts.previous),n=e.maxDelay||o;return s>n&&(s=n),null!==s&&(e.opts.currentTimeout=setTimeout((function(){s!==n&&(e.opts.paused||(e.opts.maxRuns--,t()),e.opts.previous=new r(void 0,e.opts.timezone)),e.schedule(t)}),s)),this};const i=n;return e.default})()})); | ||
!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,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>i});function r(t,e){if(this.timezone=e,t&&t instanceof Date)this.fromDate(t);else if(void 0===t)this.fromDate(new Date);else if(t&&"string"==typeof t)this.fromString(t);else{if(!(t instanceof r))throw new TypeError("CronDate: Invalid type ("+typeof t+") passed as parameter to CronDate constructor");this.fromCronDate(t)}}function o(t){this.pattern=t,this.seconds=Array(60).fill(0),this.minutes=Array(60).fill(0),this.hours=Array(24).fill(0),this.days=Array(31).fill(0),this.months=Array(12).fill(0),this.daysOfWeek=Array(8).fill(0),this.parse()}r.prototype.fromDate=function(t){let e=t.getTime();this.timezone&&(t=function(t,e){return new Date(t.toLocaleString("en-US",{timeZone:e}))}(t,this.timezone));let r=t.getTime();this.UTCmsOffset=r-e,this.milliseconds=t.getMilliseconds(),this.seconds=t.getSeconds(),this.minutes=t.getMinutes(),this.hours=t.getHours(),this.days=t.getDate(),this.months=t.getMonth(),this.years=t.getFullYear()},r.prototype.fromCronDate=function(t){this.UTCmsOffset=t.UTCmsOffset,this.timezone=t.timezone;let e=new Date(t.years,t.months,t.days,t.hours,t.minutes,t.seconds,t.milliseconds);this.milliseconds=e.getMilliseconds(),this.seconds=e.getSeconds(),this.minutes=e.getMinutes(),this.hours=e.getHours(),this.days=e.getDate(),this.months=e.getMonth(),this.years=e.getFullYear()},r.prototype.fromString=function(t){let e=Date.parse(t);if(isNaN(e))throw new TypeError("CronDate: Provided string value for CronDate could not be parsed as date.");this.fromDate(new Date(e))},r.prototype.increment=function(t,e){e||(this.seconds+=1);let o=this.getTime();this.milliseconds=0;let n=this,s=function(t,e,r,o){for(let s=void 0===o?n[t]+r:0+r;s<e[t].length;s++)if(e[t][s])return n[t]=s-r,!0;return!1},i=function(){for(;h>=0;)s(a[h][0],t,a[h][2],0),h--},a=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]],h=0;for(;h<5;)s(a[h][0],t,a[h][2])||(this[a[h][1]]++,i()),h++;for(;!t.daysOfWeek[this.getDate().getDay()];)this.days+=1,h=2,i();return o!=n.getTime()?(n=new r(n),this.years>=4e3?null:n.increment(t,!0)):this},r.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds-this.UTCmsOffset)},r.prototype.getTime=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,this.milliseconds-this.UTCmsOffset).getTime()},o.prototype.parse=function(){if("string"!=typeof this.pattern&&this.pattern.constructor!==String)throw new TypeError("CronPattern: Pattern has to be of type string.");let t,e,r=this.pattern.trim().replace(/\s+/g," ").split(" "),o=/[^/*0-9,-]+/;if(r.length<5||r.length>6)throw new TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exacly five or six space separated parts required.");for(5===r.length&&r.unshift("0"),e=0;e<r.length;e++)if(t=r[e].trim(),o.test(t))throw new TypeError("CronPattern: configuration entry "+(e+1)+" ("+t+") contains illegal characters.");this.partToArray("seconds",r[0],0),this.partToArray("minutes",r[1],0),this.partToArray("hours",r[2],0),this.partToArray("days",r[3],-1),this.partToArray("months",r[4],-1),this.partToArray("daysOfWeek",r[5],0),this.daysOfWeek[7]&&(this.daysOfWeek[0]=1)},o.prototype.partToArray=function(t,e,r){let o,n,s,i,a,h=this[t];if("*"!==e)if(n=e.split(","),n.length>1)for(o=0;o<n.length;o++)this.partToArray(t,n[o],r);else if(-1!==e.indexOf("-")){if(n=e.split("-"),2!==n.length)throw new TypeError("CronPattern: Syntax error, illegal range: '"+e+"'");if(s=parseInt(n[0],10)+r,i=parseInt(n[1],10)+r,isNaN(s))throw new TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(i))throw new TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(s<0||i>=h.length)throw new TypeError("CronPattern: Value out of range: '"+e+"'");if(s>i)throw new TypeError("CronPattern: From value is larger than to value: '"+e+"'");for(o=s;o<=i;o++)h[o+r]=1}else if(-1!==e.indexOf("/")){if(n=e.split("/"),2!==n.length)throw new TypeError("CronPattern: Syntax error, illegal stepping: '"+e+"'");if("*"!==n[0])throw new TypeError("CronPattern: Syntax error, left part of / needs to be * : '"+e+"'");if(a=parseInt(n[1],10),isNaN(a))throw new TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(0===a)throw new TypeError("CronPattern: Syntax error, illegal stepping: 0");if(a>h.length)throw new TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+h.length+")");for(o=0;o<h.length;o+=a)h[o+r]=1}else{if(o=parseInt(e,10)+r,o<0||o>=h.length)throw new TypeError("CronPattern: "+t+" value out of range: '"+e+"'");h[o]=1}else for(o=0;o<h.length;o++)h[o]=1};const n=Math.pow(2,31)-1;function s(t,e,r){return this instanceof s?(this.pattern=new o(t),"function"==typeof e&&(r=e,e=void 0),this.options=this.processOptions(e),void 0!==r&&this.schedule(r),this):new s(t,e,r)}s.prototype.processOptions=function(t){return void 0===t&&(t={}),t.paused=void 0!==t.paused&&t.paused,t.maxRuns=void 0===t.maxRuns?1/0:t.maxRuns,t.kill=!1,t.startAt&&(t.startAt=new r(t.startAt,t.timezone)),t.stopAt&&(t.stopAt=new r(t.stopAt,t.timezone)),t},s.prototype.next=function(t){let e=this._next(t);return e?e.getDate():null},s.prototype.previous=function(){return this.previousrun?this.previousrun.getDate():null},s.prototype._next=function(t){t=new r(t,this.options.timezone),this.options.startAt&&t&&t.getTime()<this.options.startAt.getTime()&&(t=new r(this.options.startAt,this.options.timezone));let e=new r(t,this.options.timezone).increment(this.pattern);return null===e||this.options.maxRuns<=0||this.options.kill||this.options.stopAt&&e.getTime()>=this.options.stopAt.getTime()?null:e},s.prototype.msToNext=function(t){t=t||new r(void 0,this.options.timezone);let e=this._next(t);return e?e.getTime()-t.getTime():null},s.prototype.stop=function(){this.options.kill=!0,this.currentTimeout&&clearTimeout(this.currentTimeout)},s.prototype.pause=function(){return(this.options.paused=!0)&&!this.options.kill},s.prototype.resume=function(){return!(this.options.paused=!1)&&!this.options.kill},s.prototype.schedule=function(t){let e=this,o=this.msToNext(e.previousrun),s=e.maxDelay||n;return o>s&&(o=s),null!==o&&(e.currentTimeout=setTimeout((function(){o!==s&&(e.options.paused||(e.options.maxRuns--,t()),e.previousrun=new r(void 0,e.options.timezone)),e.schedule(t)}),o)),this};const i=s;return e.default})()})); |
{ | ||
"name": "croner", | ||
"version": "4.0.52", | ||
"description": "Isomorphic JavaScript cron parser and scheduler.", | ||
"version": "4.0.53", | ||
"description": "Trigger functions in javascript using Cron syntax. No deps. All features.", | ||
"author": "Hexagon <github.com/hexagon>", | ||
@@ -28,3 +28,3 @@ "contributors": [ | ||
"scripts": { | ||
"test": "npm run test:mocha", | ||
"test": "npm run test:coverage", | ||
"test:dist": "mocha", | ||
@@ -31,0 +31,0 @@ "test:coverage": "c8 --reporter=text mocha test/test.croner.js", |
@@ -9,5 +9,5 @@ # Croner | ||
* Find first date of next month, find date of next tuesday, etc. | ||
* Schedule in other timezone than default. | ||
* Supports Node.js from 4.0 to current. Both require (commonjs) and import (module). | ||
* Supports browser use ([UMD](https://github.com/umdjs/umd) (standalone, requirejs etc.), [ES-module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)) | ||
* *Experimental:* Schedule in other timezone than default. | ||
@@ -14,0 +14,0 @@ Documented with [JSDoc](https://jsdoc.app/) for intellisense, and include [TypeScript](https://www.typescriptlang.org/) typings. |
@@ -38,6 +38,4 @@ /* ------------------------------------------------------------------------------------ | ||
* @property {boolean} [paused] - Job is paused | ||
* @property {boolean} [kill] - Job is about to be killed | ||
* @property {boolean} [kill] - Job is about to be killed or killed | ||
* @property {number} [maxRuns] - Maximum nuber of executions | ||
* @property {number} [currentTimeout] - Internal: setTimeout "id" | ||
* @property {CronNextResult} [previous] - Previous run time | ||
* @property {string | Date} [startAt] - When to start running | ||
@@ -103,9 +101,2 @@ * @property {string | Date} [stopAt] - When to stop running | ||
/** @type {CronOptions} */ | ||
self.schedulerDefaults = { | ||
maxRuns: Infinity, | ||
kill: false, | ||
paused: false | ||
}; | ||
// Make options optional | ||
@@ -117,16 +108,5 @@ if( typeof options === "function" ) { | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
/** @type {CronOptions} */ | ||
this.options = this.processOptions(options); | ||
// Keep options, or set defaults | ||
options.paused = (options.paused === void 0) ? self.schedulerDefaults.paused : options.paused; | ||
options.maxRuns = (options.maxRuns === void 0) ? self.schedulerDefaults.maxRuns : options.maxRuns; | ||
options.kill = this.schedulerDefaults.kill; | ||
/** | ||
* Store and validate options | ||
* @type {CronOptions} | ||
*/ | ||
self.opts = self.validateOpts(options); | ||
/** | ||
@@ -144,2 +124,30 @@ * Allow shorthand scheduling | ||
/** | ||
* | ||
* @param {CronOptions} options | ||
* @returns {CronOptions} | ||
*/ | ||
Cron.prototype.processOptions = function (options) { | ||
// If no options are passed, create empty object | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
// Keep options, or set defaults | ||
options.paused = (options.paused === void 0) ? false : options.paused; | ||
options.maxRuns = (options.maxRuns === void 0) ? Infinity : options.maxRuns; | ||
options.kill = false; | ||
// startAt is set, validate it | ||
if( options.startAt ) { | ||
options.startAt = new CronDate(options.startAt, options.timezone); | ||
} | ||
if( options.stopAt ) { | ||
options.stopAt = new CronDate(options.stopAt, options.timezone); | ||
} | ||
return options; | ||
}; | ||
/** | ||
* Find next runtime, based on supplied date. Strips milliseconds. | ||
@@ -161,3 +169,3 @@ * | ||
Cron.prototype.previous = function () { | ||
return this.opts.previous ? this.opts.previous.getDate() : null; | ||
return this.previousrun ? this.previousrun.getDate() : null; | ||
}; | ||
@@ -170,21 +178,21 @@ | ||
* @param {Date} prev - Input pattern | ||
* @returns {CronNextResult | null} - Next run time | ||
* @returns {CronDate | null} - Next run time | ||
*/ | ||
Cron.prototype._next = function (prev) { | ||
prev = new CronDate(prev, this.opts.timezone); | ||
prev = new CronDate(prev, this.options.timezone); | ||
// Previous run should never be before startAt | ||
if( this.opts.startAt && prev && prev.getTime() < this.opts.startAt.getTime() ) { | ||
prev = new CronDate(this.opts.startAt, this.opts.timezone); | ||
if( this.options.startAt && prev && prev.getTime() < this.options.startAt.getTime() ) { | ||
prev = new CronDate(this.options.startAt, this.options.timezone); | ||
} | ||
// Calculate next run | ||
let nextRun = new CronDate(prev, this.opts.timezone).increment(this.pattern); | ||
let nextRun = new CronDate(prev, this.options.timezone).increment(this.pattern); | ||
// Check for stop condition | ||
if ((nextRun === null) || | ||
(this.opts.maxRuns <= 0) || | ||
(this.opts.kill) || | ||
(this.opts.stopAt && nextRun.getTime() >= this.opts.stopAt.getTime() )) { | ||
(this.options.maxRuns <= 0) || | ||
(this.options.kill) || | ||
(this.options.stopAt && nextRun.getTime() >= this.options.stopAt.getTime() )) { | ||
return null; | ||
@@ -199,19 +207,2 @@ } else { | ||
/** | ||
* Validate (and cleans) options. Raises error on failure. | ||
* | ||
* @param {CronOptions} opts - Input options | ||
* @returns {CronOptions} - Clean and validated options. | ||
*/ | ||
Cron.prototype.validateOpts = function (opts) { | ||
// startAt is set, validate it | ||
if( opts.startAt ) { | ||
opts.startAt = new CronDate(opts.startAt, opts.timezone); | ||
} | ||
if( opts.stopAt ) { | ||
opts.stopAt = new CronDate(opts.stopAt, opts.timezone); | ||
} | ||
return opts; | ||
}; | ||
/** | ||
* Returns number of milliseconds to next run | ||
@@ -223,3 +214,3 @@ * | ||
Cron.prototype.msToNext = function (prev) { | ||
prev = prev || new CronDate(void 0, this.opts.timezone); | ||
prev = prev || new CronDate(void 0, this.options.timezone); | ||
let next = this._next(prev); | ||
@@ -238,6 +229,6 @@ if( next ) { | ||
Cron.prototype.stop = function () { | ||
this.opts.kill = true; | ||
this.options.kill = true; | ||
// Stop any awaiting call | ||
if( this.opts.currentTimeout ) { | ||
clearTimeout( this.opts.currentTimeout ); | ||
if( this.currentTimeout ) { | ||
clearTimeout( this.currentTimeout ); | ||
} | ||
@@ -253,3 +244,3 @@ }; | ||
Cron.prototype.pause = function () { | ||
return (this.opts.paused = true) && !this.opts.kill; | ||
return (this.options.paused = true) && !this.options.kill; | ||
}; | ||
@@ -264,3 +255,3 @@ | ||
Cron.prototype.resume = function () { | ||
return !(this.opts.paused = false) && !this.opts.kill; | ||
return !(this.options.paused = false) && !this.options.kill; | ||
}; | ||
@@ -280,3 +271,3 @@ | ||
// Get ms to next run | ||
waitMs = this.msToNext(self.opts.previous), | ||
waitMs = this.msToNext(self.previousrun), | ||
@@ -294,3 +285,3 @@ // Prioritize context before closure, | ||
if ( waitMs !== null ) { | ||
self.opts.currentTimeout = setTimeout(function () { | ||
self.currentTimeout = setTimeout(function () { | ||
@@ -300,11 +291,11 @@ // Are we running? If waitMs is maxed out, this is a blank run | ||
if ( !self.opts.paused ) { | ||
self.opts.maxRuns--; | ||
if ( !self.options.paused ) { | ||
self.options.maxRuns--; | ||
func(); | ||
} | ||
self.opts.previous = new CronDate(void 0, self.opts.timezone); | ||
self.previousrun = new CronDate(void 0, self.options.timezone); | ||
} | ||
// Recurse | ||
// Recurseg | ||
self.schedule(func); | ||
@@ -311,0 +302,0 @@ |
@@ -13,3 +13,3 @@ import convertTZ from "./timezone.js"; | ||
this.timezone = timezone; | ||
if (date && date instanceof Date) { | ||
@@ -24,3 +24,3 @@ this.fromDate(date); | ||
} else { | ||
throw new TypeError("CronDate: Invalid type passed as parameter to CronDate constructor"); | ||
throw new TypeError("CronDate: Invalid type (" + typeof date + ") passed as parameter to CronDate constructor"); | ||
} | ||
@@ -27,0 +27,0 @@ } |
@@ -12,3 +12,3 @@ export default Cron; | ||
/** | ||
* - Job is about to be killed | ||
* - Job is about to be killed or killed | ||
*/ | ||
@@ -21,10 +21,2 @@ kill?: boolean; | ||
/** | ||
* - Internal: setTimeout "id" | ||
*/ | ||
currentTimeout?: number; | ||
/** | ||
* - Previous run time | ||
*/ | ||
previous?: CronNextResult; | ||
/** | ||
* - When to start running | ||
@@ -100,8 +92,9 @@ */ | ||
/** @type {CronOptions} */ | ||
schedulerDefaults: CronOptions; | ||
options: CronOptions; | ||
/** | ||
* Store and validate options | ||
* @type {CronOptions} | ||
* | ||
* @param {CronOptions} options | ||
* @returns {CronOptions} | ||
*/ | ||
opts: CronOptions; | ||
processOptions(options: CronOptions): CronOptions; | ||
/** | ||
@@ -122,9 +115,2 @@ * Find next runtime, based on supplied date. Strips milliseconds. | ||
/** | ||
* Validate (and cleans) options. Raises error on failure. | ||
* | ||
* @param {CronOptions} opts - Input options | ||
* @returns {CronOptions} - Clean and validated options. | ||
*/ | ||
validateOpts(opts: CronOptions): CronOptions; | ||
/** | ||
* Returns number of milliseconds to next run | ||
@@ -131,0 +117,0 @@ * |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81562
1578