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 3.0.38 to 3.0.39

2

dist/croner.min.js

@@ -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,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<t.length;s++)t[s]=e;return t}function o(t){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()}function i(t){this.pattern=t,this.seconds=n(Array(60),0),this.minutes=n(Array(60),0),this.hours=n(Array(24),0),this.days=n(Array(31),0),this.months=n(Array(12),0),this.daysOfWeek=n(Array(8),0),this.parse()}function a(t,e,s){let r=this;return this instanceof a?(r.pattern=new i(t),r.schedulerDefaults={stopAt:1/0,maxRuns:1/0,kill:!1},"function"==typeof e&&(s=e,e={}),r.opts=r.validateOpts(e||{}),void 0===s?r:this.schedule(e,s)):new a(t,e,s)}return o.prototype.increment=function(t){this.seconds+=1,this.milliseconds=0;let e=this,s=function(t,s,r,n){for(let o=void 0===n?e[t]+r:0+r;o<s[t].length;o++)if(s[t][o])return e[t]=o-r,!0;return!1},r=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]],n=0;for(;n<5;){if(!s(r[n][0],t,r[n][2]))for(this[r[n][1]]++;n>=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;e<i.length;e++)t=i[e].trim(),a.test(t)&&r("configuration entry "+(e+1)+" ("+t+") contains illegal characters.");s="*"!==i[4],n="*"!==i[5],o="*"!==i[3],n&&(s||o)&&r("configuration invalid, you can not combine month/date with day of week."),this.partToArray("seconds",i[0],0),this.partToArray("minutes",i[1],0),this.partToArray("hours",i[2],0),this.partToArray("days",i[3],-1),this.partToArray("months",i[4],-1),this.partToArray("daysOfWeek",i[5],0),this.daysOfWeek[7]&&(this.daysOfWeek[0]=1)},i.prototype.partToArray=function(t,e,s){let n,o,i,a,l,u=this[t];if("*"!==e)if(o=e.split(","),o.length>1)for(n=0;n<o.length;n++)this.partToArray(t,o[n],s);else if(-1!==e.indexOf("-"))for(o=e.split("-"),2!==o.length&&r("Syntax error, illegal range: '"+e+"'"),i=parseInt(o[0],10)+s,a=parseInt(o[1],10)+s,isNaN(i)?r("Syntax error, illegal lower range (NaN)"):isNaN(a)&&r("Syntax error, illegal upper range (NaN)"),(i<0||a>=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;n+=l)u[n+s]=1;else n=parseInt(e,10)+s,(n<0||n>=u.length)&&r(t+" value out of range: '"+e+"'"),u[n]=1;else for(n=0;n<u.length;n++)u[n]=1},a.prototype.next=function(t){let e=this._next(t);return e&&e.setMilliseconds(0),e},a.prototype.previous=function(){return this.opts.previous},a.prototype._next=function(t){if(t=t||new Date,this.opts.startAt&&t<this.opts.startAt&&(t=this.opts.startAt),this.opts.maxRuns<=0||this.opts.kill)return;let e,s=this.opts.stopAt||this.schedulerDefaults.stopAt,r=new o(t);return r.increment(this.pattern),e=r.getDate(),s&&e>=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})()}));
!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<t.length;s++)t[s]=e;return t}function o(t){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()}function i(t){this.pattern=t,this.seconds=n(Array(60),0),this.minutes=n(Array(60),0),this.hours=n(Array(24),0),this.days=n(Array(31),0),this.months=n(Array(12),0),this.daysOfWeek=n(Array(8),0),this.parse()}function a(t,e,s){let r=this;return this instanceof a?(r.pattern=new i(t),r.schedulerDefaults={stopAt:1/0,maxRuns:1/0,kill:!1},"function"==typeof e&&(s=e,e={}),r.opts=r.validateOpts(e||{}),void 0===s?r:this.schedule(e,s)):new a(t,e,s)}o.prototype.increment=function(t){this.seconds+=1,this.milliseconds=0;let e=this,s=function(t,s,r,n){for(let o=void 0===n?e[t]+r:0+r;o<s[t].length;o++)if(s[t][o])return e[t]=o-r,!0;return!1},r=[["seconds","minutes",0],["minutes","hours",0],["hours","days",0],["days","months",-1],["months","years",0]],n=0;for(;n<5;){if(!s(r[n][0],t,r[n][2]))for(this[r[n][1]]++;n>=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;e<i.length;e++)t=i[e].trim(),a.test(t)&&r("configuration entry "+(e+1)+" ("+t+") contains illegal characters.");s="*"!==i[4],n="*"!==i[5],o="*"!==i[3],n&&(s||o)&&r("configuration invalid, you can not combine month/date with day of week."),this.partToArray("seconds",i[0],0),this.partToArray("minutes",i[1],0),this.partToArray("hours",i[2],0),this.partToArray("days",i[3],-1),this.partToArray("months",i[4],-1),this.partToArray("daysOfWeek",i[5],0),this.daysOfWeek[7]&&(this.daysOfWeek[0]=1)},i.prototype.partToArray=function(t,e,s){let n,o,i,a,l,u=this[t];if("*"!==e)if(o=e.split(","),o.length>1)for(n=0;n<o.length;n++)this.partToArray(t,o[n],s);else if(-1!==e.indexOf("-"))for(o=e.split("-"),2!==o.length&&r("Syntax error, illegal range: '"+e+"'"),i=parseInt(o[0],10)+s,a=parseInt(o[1],10)+s,isNaN(i)?r("Syntax error, illegal lower range (NaN)"):isNaN(a)&&r("Syntax error, illegal upper range (NaN)"),(i<0||a>=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;n+=l)u[n+s]=1;else n=parseInt(e,10)+s,(n<0||n>=u.length)&&r(t+" value out of range: '"+e+"'"),u[n]=1;else for(n=0;n<u.length;n++)u[n]=1},a.prototype.next=function(t){let e=this._next(t);return e&&e.setMilliseconds(0),e},a.prototype.previous=function(){return this.opts.previous},a.prototype._next=function(t){if(t=t||new Date,this.opts.startAt&&t<this.opts.startAt&&(t=this.opts.startAt),this.opts.maxRuns<=0||this.opts.kill)return;let e,s=this.opts.stopAt||this.schedulerDefaults.stopAt,r=new o(t);return r.increment(this.pattern),e=r.getDate(),s&&e>=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})()}));
{
"name": "croner",
"version": "3.0.38",
"version": "3.0.39",
"description": "Isomorphic JavaScript cron parser and scheduler.",

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

@@ -679,2 +679,4 @@ /* ------------------------------------------------------------------------------------

export { Cron, Cron as default};
export default Cron;
export { Cron };

@@ -7,4 +7,5 @@ {

"emitDeclarationOnly": true,
"esModuleInterop": true,
"outDir": "types"
}
}

@@ -0,1 +1,2 @@

export default Cron;
export type CronPatternPart = "seconds" | "minutes" | "hours" | "days" | "months" | "daysOfWeek";

@@ -157,2 +158,1 @@ export type CronIndexOffset = 0 | -1;

}
export { Cron as default };

Sorry, the diff of this file is not supported yet

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