Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

croner

Package Overview
Dependencies
Maintainers
1
Versions
228
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

croner - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

7

lib/croner.js

@@ -270,5 +270,2 @@ /* ------------------------------------------------------------------------------------

// Then, handle steps
if (conf.indexOf("/"))
// Check if we need to split

@@ -338,3 +335,3 @@ confParts = conf.split(",");

if (steps == 0) {
if (steps === 0) {
raise("Syntax error, illegal stepping: 0");

@@ -344,3 +341,3 @@ }

if (steps > arr.length) {
raise("Syntax error, steps cannot be greater than maximum value of part ("+arr.length+")")
raise("Syntax error, steps cannot be greater than maximum value of part ("+arr.length+")");
}

@@ -347,0 +344,0 @@

// Licenced under MIT - croner - ©2016 Hexagon <github.com/hexagon>
(function(){"use strict";function c(a){throw new TypeError("Cron parser: "+a)}function d(){return new Date((new Date).setMilliseconds(0))}function e(a,b){for(var c=0;c<a.length;c++)a[c]=b;return a}function f(a){this.seconds=a.getSeconds()+1,this.minutes=a.getMinutes(),this.hours=a.getHours(),this.days=a.getDate(),this.months=a.getMonth(),this.years=a.getFullYear()}function g(a){this.pattern=a,this.seconds=e(Array(60),0),this.minutes=e(Array(60),0),this.hours=e(Array(24),0),this.days=e(Array(31),0),this.months=e(Array(12),0),this.daysOfWeek=e(Array(8),0),this.parse()}function h(a,b,c){var d=this;return this instanceof h?(d.pattern=new g(a),d.schedulerDefaults={stopAt:1/0,maxRuns:1/0,kill:!1},"function"==typeof b&&(c=b,b={}),"undefined"==typeof c?d:this.schedule(b,c)):new h(a,b,c)}var a=this,b=Math.pow(2,31)-1;f.prototype.findNext=function(a,b,c,d){for(var e=void 0===d?this[a]+c:0+c,f=!1,g=e;g<b[a].length;g++)if(b[a][g]){this[a]=g-c,f=!0;break}return f},f.prototype.increment=function(a){for(var b=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]],c=0;c<5;){if(!this.findNext(b[c][0],a,b[c][2]))for(this[b[c][1]]++;c>=0;)this.findNext(b[c][0],a,b[c][2],0),c--;c++}for(;!a.daysOfWeek[this.getDate().getDay()];)this.days+=1},f.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,0)},g.prototype.parse=function(){"string"!=typeof this.pattern&&c("invalid configuration string ('"+this.pattern+"').");var b,d,f,g,h,a=this.pattern.trim().replace(/\s+/g," ").split(" "),e=/[^\/\*0-9,-]+/;for(6!==a.length&&c("invalid configuration format ('"+this.pattern+"'), exacly five space separated parts required."),d=0;d<a.length;d++)b=a[d].trim(),e.test(b)&&c("configuration entry "+(d+1)+" ("+b+") contains illegal characters.");f="*"!==a[4],g="*"!==a[5],h="*"!==a[3],g&&(f||h)&&c("configuration invalid, you can not combine month/date with day of week."),this.partToArray("seconds",this.seconds,a[0],0),this.partToArray("minutes",this.minutes,a[1],0),this.partToArray("hours",this.hours,a[2],0),this.partToArray("days",this.days,a[3],-1),this.partToArray("months",this.months,a[4],-1),this.partToArray("daysOfWeek",this.daysOfWeek,a[5],0),this.daysOfWeek[0]&&(this.daysOfWeek[7]=1),this.daysOfWeek[7]&&(this.daysOfWeek[0]=1)},g.prototype.partToArray=function(a,b,d,e){var f,g,h,i,j,k,l,m;if("*"!==d)if(d.indexOf("/")&&(h=d.split(",")),h.length>1)for(f=0;f<h.length;f++)this.partToArray(a,b,h[f],e);else if(d.indexOf("-")!==-1)for(i=d.split("-"),2!==i.length&&c("Syntax error, illegal range: '"+d+"'"),k=parseInt(i[0],10)+e,l=parseInt(i[1],10)+e,isNaN(k)?c("Syntax error, illegal lower range (NaN)"):isNaN(l)&&c("Syntax error, illegal upper range (NaN)"),(k<0||l>=b.length)&&c("Value out of range: '"+d+"'"),k>l&&c("From value is larger than to value: '"+d+"'"),g=k;g<=l;g++)b[g+e]=1;else if(d.indexOf("/")!==-1)for(i=d.split("/"),2!==i.length&&c("Syntax error, illegal stepping: '"+d+"'"),"*"!==i[0]&&c("Syntax error, left part of / needs to be * : '"+d+"'"),m=parseInt(i[1],10),isNaN(m)&&c("Syntax error, illegal stepping: (NaN)"),0==m&&c("Syntax error, illegal stepping: 0"),m>b.length&&c("Syntax error, steps cannot be greater than maximum value of part ("+b.length+")"),g=0;g<b.length;g+=m)b[g+e]=1;else j=parseInt(d,10)+e,(j<0||j>=b.length)&&c(a+" value out of range: '"+d+"'"),b[j]=1;else for(f=0;f<b.length;f++)b[f]=1},h.prototype.next=function(a){var b=new f(a||d());return b.increment(this.pattern),b.getDate()},h.prototype.msToNext=function(a){return a=a||d(),this.next(a)-a.getTime()},h.prototype.schedule=function(a,c,e){var g,f=this,h=f.maxDelay||b;if(c||(c=a,a={}),a.paused="undefined"!=typeof a.paused&&a.paused,a.previous=e===!1?d():a.startAt||a.previous,a.stopAt=a.stopAt||this.schedulerDefaults.stopAt,a.kill=a.kill||this.schedulerDefaults.kill,a.rest=a.rest||0,a.maxRuns||0===a.maxRuns||(a.maxRuns=this.schedulerDefaults.maxRuns),a.startAt=void 0,g=this.msToNext(a.previous),!(a.maxRuns<=0||a.stopAt!==1/0&&a.previous.getTime()+g/1e3>a.stopAt.getTime()||a.kill))return g>h&&(g=h),a.currentTimeout=setTimeout(function(){g===h||a.paused||(a.maxRuns--,a.previous=d(),c()),a.paused&&(a.previous=d()),f.schedule(a,c,!0)},g),{stop:function(){a.kill=!0,a.currentTimeout&&clearTimeout(a.currentTimeout)},pause:function(){return(a.paused=!0)&&!a.kill},resume:function(){return!(a.paused=!1)&&!a.kill}}},"undefined"!=typeof module&&"object"==typeof module.exports?module.exports=h:"function"==typeof define&&define.amd?define([],function(){return h}):a.Cron=h}).call(this);
(function(){"use strict";function c(a){throw new TypeError("Cron parser: "+a)}function d(){return new Date((new Date).setMilliseconds(0))}function e(a,b){for(var c=0;c<a.length;c++)a[c]=b;return a}function f(a){this.seconds=a.getSeconds()+1,this.minutes=a.getMinutes(),this.hours=a.getHours(),this.days=a.getDate(),this.months=a.getMonth(),this.years=a.getFullYear()}function g(a){this.pattern=a,this.seconds=e(Array(60),0),this.minutes=e(Array(60),0),this.hours=e(Array(24),0),this.days=e(Array(31),0),this.months=e(Array(12),0),this.daysOfWeek=e(Array(8),0),this.parse()}function h(a,b,c){var d=this;return this instanceof h?(d.pattern=new g(a),d.schedulerDefaults={stopAt:1/0,maxRuns:1/0,kill:!1},"function"==typeof b&&(c=b,b={}),"undefined"==typeof c?d:this.schedule(b,c)):new h(a,b,c)}var a=this,b=Math.pow(2,31)-1;f.prototype.findNext=function(a,b,c,d){for(var e=void 0===d?this[a]+c:0+c,f=!1,g=e;g<b[a].length;g++)if(b[a][g]){this[a]=g-c,f=!0;break}return f},f.prototype.increment=function(a){for(var b=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]],c=0;c<5;){if(!this.findNext(b[c][0],a,b[c][2]))for(this[b[c][1]]++;c>=0;)this.findNext(b[c][0],a,b[c][2],0),c--;c++}for(;!a.daysOfWeek[this.getDate().getDay()];)this.days+=1},f.prototype.getDate=function(){return new Date(this.years,this.months,this.days,this.hours,this.minutes,this.seconds,0)},g.prototype.parse=function(){"string"!=typeof this.pattern&&c("invalid configuration string ('"+this.pattern+"').");var b,d,f,g,h,a=this.pattern.trim().replace(/\s+/g," ").split(" "),e=/[^\/\*0-9,-]+/;for(6!==a.length&&c("invalid configuration format ('"+this.pattern+"'), exacly five space separated parts required."),d=0;d<a.length;d++)b=a[d].trim(),e.test(b)&&c("configuration entry "+(d+1)+" ("+b+") contains illegal characters.");f="*"!==a[4],g="*"!==a[5],h="*"!==a[3],g&&(f||h)&&c("configuration invalid, you can not combine month/date with day of week."),this.partToArray("seconds",this.seconds,a[0],0),this.partToArray("minutes",this.minutes,a[1],0),this.partToArray("hours",this.hours,a[2],0),this.partToArray("days",this.days,a[3],-1),this.partToArray("months",this.months,a[4],-1),this.partToArray("daysOfWeek",this.daysOfWeek,a[5],0),this.daysOfWeek[0]&&(this.daysOfWeek[7]=1),this.daysOfWeek[7]&&(this.daysOfWeek[0]=1)},g.prototype.partToArray=function(a,b,d,e){var f,g,h,i,j,k,l,m;if("*"!==d)if(h=d.split(","),h.length>1)for(f=0;f<h.length;f++)this.partToArray(a,b,h[f],e);else if(d.indexOf("-")!==-1)for(i=d.split("-"),2!==i.length&&c("Syntax error, illegal range: '"+d+"'"),k=parseInt(i[0],10)+e,l=parseInt(i[1],10)+e,isNaN(k)?c("Syntax error, illegal lower range (NaN)"):isNaN(l)&&c("Syntax error, illegal upper range (NaN)"),(k<0||l>=b.length)&&c("Value out of range: '"+d+"'"),k>l&&c("From value is larger than to value: '"+d+"'"),g=k;g<=l;g++)b[g+e]=1;else if(d.indexOf("/")!==-1)for(i=d.split("/"),2!==i.length&&c("Syntax error, illegal stepping: '"+d+"'"),"*"!==i[0]&&c("Syntax error, left part of / needs to be * : '"+d+"'"),m=parseInt(i[1],10),isNaN(m)&&c("Syntax error, illegal stepping: (NaN)"),0===m&&c("Syntax error, illegal stepping: 0"),m>b.length&&c("Syntax error, steps cannot be greater than maximum value of part ("+b.length+")"),g=0;g<b.length;g+=m)b[g+e]=1;else j=parseInt(d,10)+e,(j<0||j>=b.length)&&c(a+" value out of range: '"+d+"'"),b[j]=1;else for(f=0;f<b.length;f++)b[f]=1},h.prototype.next=function(a){var b=new f(a||d());return b.increment(this.pattern),b.getDate()},h.prototype.msToNext=function(a){return a=a||d(),this.next(a)-a.getTime()},h.prototype.schedule=function(a,c,e){var g,f=this,h=f.maxDelay||b;if(c||(c=a,a={}),a.paused="undefined"!=typeof a.paused&&a.paused,a.previous=e===!1?d():a.startAt||a.previous,a.stopAt=a.stopAt||this.schedulerDefaults.stopAt,a.kill=a.kill||this.schedulerDefaults.kill,a.rest=a.rest||0,a.maxRuns||0===a.maxRuns||(a.maxRuns=this.schedulerDefaults.maxRuns),a.startAt=void 0,g=this.msToNext(a.previous),!(a.maxRuns<=0||a.stopAt!==1/0&&a.previous.getTime()+g/1e3>a.stopAt.getTime()||a.kill))return g>h&&(g=h),a.currentTimeout=setTimeout(function(){g===h||a.paused||(a.maxRuns--,a.previous=d(),c()),a.paused&&(a.previous=d()),f.schedule(a,c,!0)},g),{stop:function(){a.kill=!0,a.currentTimeout&&clearTimeout(a.currentTimeout)},pause:function(){return(a.paused=!0)&&!a.kill},resume:function(){return!(a.paused=!1)&&!a.kill}}},"undefined"!=typeof module&&"object"==typeof module.exports?module.exports=h:"function"==typeof define&&define.amd?define([],function(){return h}):a.Cron=h}).call(this);
{
"name": "croner",
"version": "1.1.4",
"version": "1.1.5",
"description": "Isomorphic JavaScript cron parser and scheduler.",

@@ -5,0 +5,0 @@ "author": "Hexagon <github.com/hexagon>",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc