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.15 to 1.1.16

4

lib/croner.js

@@ -431,3 +431,3 @@ /* ------------------------------------------------------------------------------------

// startAt is set, validate it
if( opts.startAt !== void 0 ) {
if( opts.startAt ) {
if( opts.startAt.constructor !== Date ) {

@@ -444,3 +444,3 @@ opts.startAt = new Date(Date.parse(opts.startAt)-1);

}
if( opts.stopAt !== void 0 ) {
if( opts.stopAt ) {
if( opts.stopAt.constructor !== Date ) {

@@ -447,0 +447,0 @@ opts.stopAt = new Date(Date.parse(opts.stopAt));

// Licenced under MIT - croner - ©2016 Hexagon <github.com/hexagon>
(function(){"use strict";function c(a){throw new TypeError("Cron parser: "+a)}function d(){var a=new Date;return a.setMilliseconds(0),a}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={}),d.opts=d.validateOpts(b||{}),void 0===c?d:this.schedule(b,c)):new h(a,b,c)}var a=this,b=Math.pow(2,31)-1;f.prototype.increment=function(a){for(var b=this,c=function(a,c,d,e){for(var f=void 0===e?b[a]+d:0+d,g=f;g<c[a].length;g++)if(c[a][g])return b[a]=g-d,!0;return!1},d=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]],e=0;e<5;){if(!c(d[e][0],a,d[e][2]))for(this[d[e][1]]++;e>=0;)c(d[e][0],a,d[e][2],0),e--;e++}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&&this.pattern.constructor!==String&&c("Pattern has to be of type string.");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",a[0],0),this.partToArray("minutes",a[1],0),this.partToArray("hours",a[2],0),this.partToArray("days",a[3],-1),this.partToArray("months",a[4],-1),this.partToArray("daysOfWeek",a[5],0),this.daysOfWeek[7]&&(this.daysOfWeek[0]=1)},g.prototype.partToArray=function(a,b,d){var e,f,g,h,i,j=this[a];if("*"!==b)if(f=b.split(","),f.length>1)for(e=0;e<f.length;e++)this.partToArray(a,f[e],d);else if(b.indexOf("-")!==-1)for(f=b.split("-"),2!==f.length&&c("Syntax error, illegal range: '"+b+"'"),g=parseInt(f[0],10)+d,h=parseInt(f[1],10)+d,isNaN(g)?c("Syntax error, illegal lower range (NaN)"):isNaN(h)&&c("Syntax error, illegal upper range (NaN)"),(g<0||h>=j.length)&&c("Value out of range: '"+b+"'"),g>h&&c("From value is larger than to value: '"+b+"'"),e=g;e<=h;e++)j[e+d]=1;else if(b.indexOf("/")!==-1)for(f=b.split("/"),2!==f.length&&c("Syntax error, illegal stepping: '"+b+"'"),"*"!==f[0]&&c("Syntax error, left part of / needs to be * : '"+b+"'"),i=parseInt(f[1],10),isNaN(i)&&c("Syntax error, illegal stepping: (NaN)"),0===i&&c("Syntax error, illegal stepping: 0"),i>j.length&&c("Syntax error, steps cannot be greater than maximum value of part ("+j.length+")"),e=0;e<j.length;e+=i)j[e+d]=1;else e=parseInt(b,10)+d,(e<0||e>=j.length)&&c(a+" value out of range: '"+b+"'"),j[e]=1;else for(e=0;e<j.length;e++)j[e]=1},h.prototype.next=function(a){a=a||d(),this.opts.startAt&&a<this.opts.startAt&&(a=this.opts.startAt);var e,b=this.opts.stopAt||this.schedulerDefaults.stopAt,c=new f(a);return c.increment(this.pattern),e=c.getDate(),b&&e>=b?void 0:e},h.prototype.validateOpts=function(a){return void 0!==a.startAt&&(a.startAt.constructor!==Date?a.startAt=new Date(Date.parse(a.startAt)-1):a.startAt=new Date(a.startAt.getTime()-1),isNaN(a.startAt)&&c("Provided value for startAt could not be parsed as date.")),void 0!==a.stopAt&&(a.stopAt.constructor!==Date&&(a.stopAt=new Date(Date.parse(a.stopAt))),isNaN(a.stopAt)&&c("Provided value for stopAt could not be parsed as date.")),a},h.prototype.msToNext=function(a){a=a||d();var b=this.next(a);return b?this.next(a)-a.getTime():b},h.prototype.schedule=function(a,c){var f,e=this,g=e.maxDelay||b;if(c||(c=a,a={}),a.paused=void 0!==a.paused&&a.paused,a.kill=a.kill||this.schedulerDefaults.kill,a.rest=a.rest||0,a.maxRuns||0===a.maxRuns||(a.maxRuns=this.schedulerDefaults.maxRuns),e.opts=e.validateOpts(a||{}),f=this.msToNext(a.previous),!(a.maxRuns<=0||void 0===f||a.kill))return f>g&&(f=g),a.currentTimeout=setTimeout(function(){f===g||a.paused||(a.maxRuns--,a.previous=d(),c()),a.paused&&(a.previous=d()),e.schedule(a,c)},f),{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}}},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(){var a=new Date;return a.setMilliseconds(0),a}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={}),d.opts=d.validateOpts(b||{}),void 0===c?d:this.schedule(b,c)):new h(a,b,c)}var a=this,b=Math.pow(2,31)-1;f.prototype.increment=function(a){for(var b=this,c=function(a,c,d,e){for(var f=void 0===e?b[a]+d:0+d,g=f;g<c[a].length;g++)if(c[a][g])return b[a]=g-d,!0;return!1},d=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]],e=0;e<5;){if(!c(d[e][0],a,d[e][2]))for(this[d[e][1]]++;e>=0;)c(d[e][0],a,d[e][2],0),e--;e++}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&&this.pattern.constructor!==String&&c("Pattern has to be of type string.");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",a[0],0),this.partToArray("minutes",a[1],0),this.partToArray("hours",a[2],0),this.partToArray("days",a[3],-1),this.partToArray("months",a[4],-1),this.partToArray("daysOfWeek",a[5],0),this.daysOfWeek[7]&&(this.daysOfWeek[0]=1)},g.prototype.partToArray=function(a,b,d){var e,f,g,h,i,j=this[a];if("*"!==b)if(f=b.split(","),f.length>1)for(e=0;e<f.length;e++)this.partToArray(a,f[e],d);else if(b.indexOf("-")!==-1)for(f=b.split("-"),2!==f.length&&c("Syntax error, illegal range: '"+b+"'"),g=parseInt(f[0],10)+d,h=parseInt(f[1],10)+d,isNaN(g)?c("Syntax error, illegal lower range (NaN)"):isNaN(h)&&c("Syntax error, illegal upper range (NaN)"),(g<0||h>=j.length)&&c("Value out of range: '"+b+"'"),g>h&&c("From value is larger than to value: '"+b+"'"),e=g;e<=h;e++)j[e+d]=1;else if(b.indexOf("/")!==-1)for(f=b.split("/"),2!==f.length&&c("Syntax error, illegal stepping: '"+b+"'"),"*"!==f[0]&&c("Syntax error, left part of / needs to be * : '"+b+"'"),i=parseInt(f[1],10),isNaN(i)&&c("Syntax error, illegal stepping: (NaN)"),0===i&&c("Syntax error, illegal stepping: 0"),i>j.length&&c("Syntax error, steps cannot be greater than maximum value of part ("+j.length+")"),e=0;e<j.length;e+=i)j[e+d]=1;else e=parseInt(b,10)+d,(e<0||e>=j.length)&&c(a+" value out of range: '"+b+"'"),j[e]=1;else for(e=0;e<j.length;e++)j[e]=1},h.prototype.next=function(a){a=a||d(),this.opts.startAt&&a<this.opts.startAt&&(a=this.opts.startAt);var e,b=this.opts.stopAt||this.schedulerDefaults.stopAt,c=new f(a);return c.increment(this.pattern),e=c.getDate(),b&&e>=b?void 0:e},h.prototype.validateOpts=function(a){return a.startAt&&(a.startAt.constructor!==Date?a.startAt=new Date(Date.parse(a.startAt)-1):a.startAt=new Date(a.startAt.getTime()-1),isNaN(a.startAt)&&c("Provided value for startAt could not be parsed as date.")),a.stopAt&&(a.stopAt.constructor!==Date&&(a.stopAt=new Date(Date.parse(a.stopAt))),isNaN(a.stopAt)&&c("Provided value for stopAt could not be parsed as date.")),a},h.prototype.msToNext=function(a){a=a||d();var b=this.next(a);return b?this.next(a)-a.getTime():b},h.prototype.schedule=function(a,c){var f,e=this,g=e.maxDelay||b;if(c||(c=a,a={}),a.paused=void 0!==a.paused&&a.paused,a.kill=a.kill||this.schedulerDefaults.kill,a.rest=a.rest||0,a.maxRuns||0===a.maxRuns||(a.maxRuns=this.schedulerDefaults.maxRuns),e.opts=e.validateOpts(a||{}),f=this.msToNext(a.previous),!(a.maxRuns<=0||void 0===f||a.kill))return f>g&&(f=g),a.currentTimeout=setTimeout(function(){f===g||a.paused||(a.maxRuns--,a.previous=d(),c()),a.paused&&(a.previous=d()),e.schedule(a,c)},f),{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}}},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.15",
"version": "1.1.16",
"description": "Isomorphic JavaScript cron parser and scheduler.",

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

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