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

cron-schedule

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cron-schedule - npm Package Compare versions

Comparing version 3.0.4 to 3.0.5

2

dist/cron-schedule.cjs.min.js

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

var M=Object.defineProperty,z=Object.defineProperties;var P=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var R=(r,e,n)=>e in r?M(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,H=(r,e)=>{for(var n in e||(e={}))B.call(e,n)&&R(r,n,e[n]);if(N)for(var n of N(e))L.call(e,n)&&R(r,n,e[n]);return r},$=(r,e)=>z(r,P(e)),j=r=>M(r,"__esModule",{value:!0});var Y=(r,e)=>{j(r);for(var n in e)M(r,n,{get:e[n],enumerable:!0})};var O=(r,e,n)=>{if(!e.has(r))throw TypeError("Cannot "+n)};var f=(r,e,n)=>(O(r,e,"read from private field"),n?n.call(r):e.get(r)),v=(r,e,n)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,n)},p=(r,e,n,t)=>(O(r,e,"write to private field"),t?t.call(r,n):e.set(r,n),n);Y(exports,{Cron:()=>C,IntervalBasedCronScheduler:()=>W,TIMEOUT_MAX:()=>D,TimerBasedCronScheduler:()=>F,extractDateElements:()=>k,getDaysBetweenWeekdays:()=>E,getDaysInMonth:()=>S,longTimeout:()=>A,parseCronExpression:()=>K,wrapFunction:()=>g});var D=2147483647;function A(r,e,n){let t=0;return e>D&&(t=e-D,e=D),n!=null||(n={timeoutId:void 0}),n.timeoutId=setTimeout(()=>{t>0?A(r,t,n):r()},e),n}function k(r){return{second:r.getSeconds(),minute:r.getMinutes(),hour:r.getHours(),day:r.getDate(),month:r.getMonth(),weekday:r.getDay(),year:r.getFullYear()}}function S(r,e){return new Date(r,e+1,0).getDate()}function E(r,e){return r<=e?e-r:6-r+e+1}function g(r,e){return()=>{try{let n=r();n instanceof Promise&&n.catch(t=>{e&&e(t)})}catch(n){e&&e(n)}}}var I,y,c,T,W=class{constructor(e){v(this,I,void 0);v(this,y,void 0);v(this,c,[]);v(this,T,1);p(this,I,e),this.start()}start(){if(f(this,y)!==void 0)throw new Error("Scheduler already started.");p(this,y,setInterval(this.processTasks.bind(this),f(this,I)))}stop(){f(this,y)&&(clearInterval(f(this,y)),p(this,y,void 0))}insertTask(e){let n=f(this,c).findIndex(t=>t.nextExecution.getTime()>e.nextExecution.getTime());f(this,c).splice(n,0,e)}registerTask(e,n,t){var o;let s=f(this,T);return this.insertTask({id:s,cron:e,nextExecution:e.getNextDate(),task:n,isOneTimeTask:(o=t==null?void 0:t.isOneTimeTask)!=null?o:!1,errorHandler:t==null?void 0:t.errorHandler}),p(this,T,f(this,T)+1),s}unregisterTask(e){let n=f(this,c).findIndex(t=>t.id===e);if(n===-1)throw new Error("Task not found.");f(this,c).splice(n,1)}sortTasks(){f(this,c).sort((e,n)=>e.nextExecution.getTime()-n.nextExecution.getTime())}processTasks(){let e=Date.now(),n=!1,t=!1;for(let s=0;s<f(this,c).length;s+=1){let o=f(this,c)[s];if(o.nextExecution.getTime()<=e)g(o.task,o.errorHandler)(),o.isOneTimeTask?t=!0:(n=!0,o.nextExecution=o.cron.getNextDate());else break}t&&p(this,c,f(this,c).filter(s=>s.nextExecution.getTime()>e)),n&&this.sortTasks()}};I=new WeakMap,y=new WeakMap,c=new WeakMap,T=new WeakMap;var F=class{static setTimeout(e,n,t){let o=e.getNextDate().getTime()-Date.now();return A(g(n,t==null?void 0:t.errorHandler),o)}static setInterval(e,n,t){var u;let s=(u=t==null?void 0:t.handle)!=null?u:{timeoutId:void 0},{timeoutId:o}=this.setTimeout(e,()=>{g(n,t==null?void 0:t.errorHandler)(),this.setInterval(e,n,$(H({},t),{handle:s}))});return s.timeoutId=o,s}static clearTimeoutOrInterval(e){e.timeoutId&&clearTimeout(e.timeoutId)}};var C=class{constructor({seconds:e,minutes:n,hours:t,days:s,months:o,weekdays:u}){if(!e||e.size===0)throw new Error("There must be at least one allowed second.");if(!n||n.size===0)throw new Error("There must be at least one allowed minute.");if(!t||t.size===0)throw new Error("There must be at least one allowed hour.");if(!o||o.size===0)throw new Error("There must be at least one allowed month.");if((!u||u.size===0)&&(!s||s.size===0))throw new Error("There must be at least one allowed day or weekday.");this.seconds=Array.from(e).sort((i,d)=>i-d),this.minutes=Array.from(n).sort((i,d)=>i-d),this.hours=Array.from(t).sort((i,d)=>i-d),this.days=Array.from(s).sort((i,d)=>i-d),this.months=Array.from(o).sort((i,d)=>i-d),this.weekdays=Array.from(u).sort((i,d)=>i-d);let m=(i,d,a)=>{if(d.some(h=>typeof h!="number"||h%1!=0||h<a.min||h>a.max))throw new Error(`${i} must only consist of integers which are within the range of ${a.min} and ${a.max}`)};m("seconds",this.seconds,{min:0,max:59}),m("minutes",this.minutes,{min:0,max:59}),m("hours",this.hours,{min:0,max:23}),m("days",this.days,{min:1,max:31}),m("months",this.months,{min:0,max:11}),m("weekdays",this.weekdays,{min:0,max:6}),this.reversed={seconds:this.seconds.map(i=>i).reverse(),minutes:this.minutes.map(i=>i).reverse(),hours:this.hours.map(i=>i).reverse(),days:this.days.map(i=>i).reverse(),months:this.months.map(i=>i).reverse(),weekdays:this.weekdays.map(i=>i).reverse()}}findAllowedHour(e,n){return e==="next"?this.hours.find(t=>t>=n):this.reversed.hours.find(t=>t<=n)}findAllowedMinute(e,n){return e==="next"?this.minutes.find(t=>t>=n):this.reversed.minutes.find(t=>t<=n)}findAllowedSecond(e,n){return e==="next"?this.seconds.find(t=>t>n):this.reversed.seconds.find(t=>t<n)}findAllowedTime(e,n){let t=this.findAllowedHour(e,n.hour);if(t!==void 0)if(t===n.hour){let s=this.findAllowedMinute(e,n.minute);if(s!==void 0)if(s===n.minute){let o=this.findAllowedSecond(e,n.second);if(o!==void 0)return{hour:t,minute:s,second:o};if(s=this.findAllowedMinute(e,e==="next"?n.minute+1:n.minute-1),s!==void 0)return{hour:t,minute:s,second:e==="next"?this.seconds[0]:this.reversed.seconds[0]}}else return{hour:t,minute:s,second:e==="next"?this.seconds[0]:this.reversed.seconds[0]};if(t=this.findAllowedHour(e,e==="next"?n.hour+1:n.hour-1),t!==void 0)return{hour:t,minute:e==="next"?this.minutes[0]:this.reversed.minutes[0],second:e==="next"?this.seconds[0]:this.reversed.seconds[0]}}else return{hour:t,minute:e==="next"?this.minutes[0]:this.reversed.minutes[0],second:e==="next"?this.seconds[0]:this.reversed.seconds[0]}}findAllowedDayInMonth(e,n,t,s){var a,h;if(s<1)throw new Error("startDay must not be smaller than 1.");let o=S(n,t),u=this.days.length!==31,m=this.weekdays.length!==7;if(!u&&!m)return s>o?e==="next"?void 0:o:s;let i;u&&(i=e==="next"?this.days.find(l=>l>=s):this.reversed.days.find(l=>l<=s),i!==void 0&&i>o&&(i=void 0));let d;if(m){let l=new Date(n,t,s).getDay(),x=e==="next"?(a=this.weekdays.find(b=>b>=l))!=null?a:this.weekdays[0]:(h=this.reversed.weekdays.find(b=>b<=l))!=null?h:this.reversed.weekdays[0];if(x!==void 0){let b=e==="next"?E(l,x):E(x,l);d=e==="next"?s+b:s-b,(d>o||d<1)&&(d=void 0)}}if(i!==void 0&&d!==void 0)return e==="next"?Math.min(i,d):Math.max(i,d);if(i!==void 0)return i;if(d!==void 0)return d}getNextDate(e=new Date){let n=k(e),t=n.year,s=this.months.findIndex(u=>u>=n.month);s===-1&&(s=0,t++);let o=this.months.length*5;for(let u=0;u<o;u++){let m=t+Math.floor((s+u)/this.months.length),i=this.months[(s+u)%this.months.length],d=m===n.year&&i===n.month,a=this.findAllowedDayInMonth("next",m,i,d?n.day:1),h=d&&a===n.day;if(a!==void 0&&h){let l=this.findAllowedTime("next",n);if(l!==void 0)return new Date(m,i,a,l.hour,l.minute,l.second);a=this.findAllowedDayInMonth("next",m,i,a+1),h=!1}if(a!==void 0&&!h)return new Date(m,i,a,this.hours[0],this.minutes[0],this.seconds[0])}throw new Error("No valid next date was found.")}getNextDates(e,n){let t=[],s;for(let o=0;o<e;o++)s=this.getNextDate(s!=null?s:n),t.push(s);return t}*getNextDatesIterator(e,n){let t;for(;;){if(t=this.getNextDate(e),e=t,n&&n.getTime()<t.getTime())return;yield t}}getPrevDate(e=new Date){let n=k(e),t=n.year,s=this.reversed.months.findIndex(u=>u<=n.month);s===-1&&(s=0,t--);let o=this.reversed.months.length*5;for(let u=0;u<o;u++){let m=t-Math.floor((s+u)/this.reversed.months.length),i=this.reversed.months[(s+u)%this.reversed.months.length],d=m===n.year&&i===n.month,a=this.findAllowedDayInMonth("prev",m,i,d?n.day:31),h=d&&a===n.day;if(a!==void 0&&h){let l=this.findAllowedTime("prev",n);if(l!==void 0)return new Date(m,i,a,l.hour,l.minute,l.second);a>1&&(a=this.findAllowedDayInMonth("prev",m,i,a-1),h=!1)}if(a!==void 0&&!h)return new Date(m,i,a,this.reversed.hours[0],this.reversed.minutes[0],this.reversed.seconds[0])}throw new Error("No valid previous date was found.")}getPrevDates(e,n){let t=[],s;for(let o=0;o<e;o++)s=this.getPrevDate(s!=null?s:n),t.push(s);return t}*getPrevDatesIterator(e,n){let t;for(;;){if(t=this.getPrevDate(e),e=t,n&&n.getTime()>t.getTime())return;yield t}}matchDate(e){let{second:n,minute:t,hour:s,day:o,month:u,weekday:m}=k(e);return this.seconds.indexOf(n)!==-1&&this.minutes.indexOf(t)!==-1&&this.hours.indexOf(s)!==-1&&this.months.indexOf(u)!==-1&&(this.days.indexOf(o)!==-1||this.weekdays.indexOf(m)!==-1)}};var G={min:0,max:59},Z={min:0,max:59},U={min:0,max:23},X={min:1,max:31},_={min:1,max:12,aliases:{jan:"1",feb:"2",mar:"3",apr:"4",may:"5",jun:"6",jul:"7",aug:"8",sep:"9",oct:"10",nov:"11",dec:"12"}},q={min:0,max:6,aliases:{"7":"0",sun:"0",mon:"1",tue:"2",wed:"3",thu:"4",fri:"5",sat:"6"}},J={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 1 *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@hourly":"0 * * * *","@minutely":"* * * * *"};function w(r,e){let n=new Set;if(r==="*"){for(let a=e.min;a<=e.max;a=a+1)n.add(a);return n}let t=r.split(",");if(t.length>1)return t.forEach(a=>{w(a,e).forEach(l=>n.add(l))}),n;let s=a=>{var l,x;a=(x=(l=e.aliases)==null?void 0:l[a.toLowerCase()])!=null?x:a;let h=parseInt(a,10);if(Number.isNaN(h))throw new Error(`Failed to parse ${r}: ${a} is NaN.`);if(h<e.min||h>e.max)throw new Error(`Failed to parse ${r}: ${a} is outside of constraint range of ${e.min} - ${e.max}.`);return h},o=/^((([0-9a-zA-Z]+)-([0-9a-zA-Z]+))|\*)(\/([0-9]+))?$/.exec(r);if(o===null)return n.add(s(r)),n;let u=o[1]==="*"?e.min:s(o[3]),m=o[1]==="*"?e.max:s(o[4]);if(u>=m-1)throw new Error(`Failed to parse ${r}: Invalid range (start: ${u}, end: ${m}).`);let i=o[6],d=1;if(i!==void 0){if(d=parseInt(i,10),Number.isNaN(d))throw new Error(`Failed to parse step: ${i} is NaN.`);if(d<1)throw new Error(`Failed to parse step: Expected ${i} to be greater than 0.`)}for(let a=u;a<=m;a=a+d)n.add(a);return n}function K(r){var i;if(typeof r!="string")throw new TypeError("Invalid cron expression: must be of type string.");r=(i=J[r.toLowerCase()])!=null?i:r;let e=r.split(" ");if(e.length<5||e.length>6)throw new Error("Invalid cron expression: expected 5 or 6 elements.");let n=e.length===6?e[0]:"0",t=e.length===6?e[1]:e[0],s=e.length===6?e[2]:e[1],o=e.length===6?e[3]:e[2],u=e.length===6?e[4]:e[3],m=e.length===6?e[5]:e[4];return new C({seconds:w(n,G),minutes:w(t,Z),hours:w(s,U),days:w(o,X),months:new Set(Array.from(w(u,_)).map(d=>d-1)),weekdays:w(m,q)})}0&&(module.exports={Cron,IntervalBasedCronScheduler,TIMEOUT_MAX,TimerBasedCronScheduler,extractDateElements,getDaysBetweenWeekdays,getDaysInMonth,longTimeout,parseCronExpression,wrapFunction});
var D=Object.defineProperty,z=Object.defineProperties,P=Object.getOwnPropertyDescriptor,B=Object.getOwnPropertyDescriptors,L=Object.getOwnPropertyNames,S=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var N=(r,e,n)=>e in r?D(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,H=(r,e)=>{for(var n in e||(e={}))R.call(e,n)&&N(r,n,e[n]);if(S)for(var n of S(e))U.call(e,n)&&N(r,n,e[n]);return r},O=(r,e)=>z(r,B(e)),X=r=>D(r,"__esModule",{value:!0});var _=(r,e)=>{for(var n in e)D(r,n,{get:e[n],enumerable:!0})},j=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of L(e))!R.call(r,s)&&(n||s!=="default")&&D(r,s,{get:()=>e[s],enumerable:!(t=P(e,s))||t.enumerable});return r};var Y=(r=>(e,n)=>r&&r.get(e)||(n=j(X({}),e,1),r&&r.set(e,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var $=(r,e,n)=>{if(!e.has(r))throw TypeError("Cannot "+n)};var f=(r,e,n)=>($(r,e,"read from private field"),n?n.call(r):e.get(r)),v=(r,e,n)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,n)},p=(r,e,n,t)=>($(r,e,"write to private field"),t?t.call(r,n):e.set(r,n),n);var ne={};_(ne,{Cron:()=>M,IntervalBasedCronScheduler:()=>W,TIMEOUT_MAX:()=>re,TimerBasedCronScheduler:()=>F,extractDateElements:()=>I,getDaysBetweenWeekdays:()=>E,getDaysInMonth:()=>C,longTimeout:()=>A,parseCronExpression:()=>ee,wrapFunction:()=>g});var re=2147483647;function A(r,e,n){let t=0;return e>2147483647&&(t=e-2147483647,e=2147483647),n!=null||(n={timeoutId:void 0}),n.timeoutId=setTimeout(()=>{t>0?A(r,t,n):r()},e),n}function I(r){return{second:r.getSeconds(),minute:r.getMinutes(),hour:r.getHours(),day:r.getDate(),month:r.getMonth(),weekday:r.getDay(),year:r.getFullYear()}}function C(r,e){return new Date(r,e+1,0).getDate()}function E(r,e){return r<=e?e-r:6-r+e+1}function g(r,e){return()=>{try{let n=r();n instanceof Promise&&n.catch(t=>{e&&e(t)})}catch(n){e&&e(n)}}}var T,y,c,k,W=class{constructor(e){v(this,T,void 0);v(this,y,void 0);v(this,c,[]);v(this,k,1);p(this,T,e),this.start()}start(){if(f(this,y)!==void 0)throw new Error("Scheduler already started.");p(this,y,setInterval(this.processTasks.bind(this),f(this,T)))}stop(){f(this,y)&&(clearInterval(f(this,y)),p(this,y,void 0))}insertTask(e){let n=f(this,c).findIndex(t=>t.nextExecution.getTime()>e.nextExecution.getTime());f(this,c).splice(n,0,e)}registerTask(e,n,t){var o;let s=f(this,k);return this.insertTask({id:s,cron:e,nextExecution:e.getNextDate(),task:n,isOneTimeTask:(o=t==null?void 0:t.isOneTimeTask)!=null?o:!1,errorHandler:t==null?void 0:t.errorHandler}),p(this,k,f(this,k)+1),s}unregisterTask(e){let n=f(this,c).findIndex(t=>t.id===e);if(n===-1)throw new Error("Task not found.");f(this,c).splice(n,1)}sortTasks(){f(this,c).sort((e,n)=>e.nextExecution.getTime()-n.nextExecution.getTime())}processTasks(){let e=Date.now(),n=!1,t=!1;for(let s=0;s<f(this,c).length;s+=1){let o=f(this,c)[s];if(o.nextExecution.getTime()<=e)g(o.task,o.errorHandler)(),o.isOneTimeTask?t=!0:(n=!0,o.nextExecution=o.cron.getNextDate());else break}t&&p(this,c,f(this,c).filter(s=>s.nextExecution.getTime()>e)),n&&this.sortTasks()}};T=new WeakMap,y=new WeakMap,c=new WeakMap,k=new WeakMap;var F=class{static setTimeout(e,n,t){let o=e.getNextDate().getTime()-Date.now();return A(g(n,t==null?void 0:t.errorHandler),o)}static setInterval(e,n,t){var u;let s=(u=t==null?void 0:t.handle)!=null?u:{timeoutId:void 0},{timeoutId:o}=this.setTimeout(e,()=>{g(n,t==null?void 0:t.errorHandler)(),this.setInterval(e,n,O(H({},t),{handle:s}))});return s.timeoutId=o,s}static clearTimeoutOrInterval(e){e.timeoutId&&clearTimeout(e.timeoutId)}};var M=class{constructor({seconds:e,minutes:n,hours:t,days:s,months:o,weekdays:u}){if(!e||e.size===0)throw new Error("There must be at least one allowed second.");if(!n||n.size===0)throw new Error("There must be at least one allowed minute.");if(!t||t.size===0)throw new Error("There must be at least one allowed hour.");if(!o||o.size===0)throw new Error("There must be at least one allowed month.");if((!u||u.size===0)&&(!s||s.size===0))throw new Error("There must be at least one allowed day or weekday.");this.seconds=Array.from(e).sort((i,d)=>i-d),this.minutes=Array.from(n).sort((i,d)=>i-d),this.hours=Array.from(t).sort((i,d)=>i-d),this.days=Array.from(s).sort((i,d)=>i-d),this.months=Array.from(o).sort((i,d)=>i-d),this.weekdays=Array.from(u).sort((i,d)=>i-d);let m=(i,d,a)=>{if(d.some(l=>typeof l!="number"||l%1!==0||l<a.min||l>a.max))throw new Error(`${i} must only consist of integers which are within the range of ${a.min} and ${a.max}`)};m("seconds",this.seconds,{min:0,max:59}),m("minutes",this.minutes,{min:0,max:59}),m("hours",this.hours,{min:0,max:23}),m("days",this.days,{min:1,max:31}),m("months",this.months,{min:0,max:11}),m("weekdays",this.weekdays,{min:0,max:6}),this.reversed={seconds:this.seconds.map(i=>i).reverse(),minutes:this.minutes.map(i=>i).reverse(),hours:this.hours.map(i=>i).reverse(),days:this.days.map(i=>i).reverse(),months:this.months.map(i=>i).reverse(),weekdays:this.weekdays.map(i=>i).reverse()}}findAllowedHour(e,n){return e==="next"?this.hours.find(t=>t>=n):this.reversed.hours.find(t=>t<=n)}findAllowedMinute(e,n){return e==="next"?this.minutes.find(t=>t>=n):this.reversed.minutes.find(t=>t<=n)}findAllowedSecond(e,n){return e==="next"?this.seconds.find(t=>t>n):this.reversed.seconds.find(t=>t<n)}findAllowedTime(e,n){let t=this.findAllowedHour(e,n.hour);if(t!==void 0)if(t===n.hour){let s=this.findAllowedMinute(e,n.minute);if(s!==void 0)if(s===n.minute){let o=this.findAllowedSecond(e,n.second);if(o!==void 0)return{hour:t,minute:s,second:o};if(s=this.findAllowedMinute(e,e==="next"?n.minute+1:n.minute-1),s!==void 0)return{hour:t,minute:s,second:e==="next"?this.seconds[0]:this.reversed.seconds[0]}}else return{hour:t,minute:s,second:e==="next"?this.seconds[0]:this.reversed.seconds[0]};if(t=this.findAllowedHour(e,e==="next"?n.hour+1:n.hour-1),t!==void 0)return{hour:t,minute:e==="next"?this.minutes[0]:this.reversed.minutes[0],second:e==="next"?this.seconds[0]:this.reversed.seconds[0]}}else return{hour:t,minute:e==="next"?this.minutes[0]:this.reversed.minutes[0],second:e==="next"?this.seconds[0]:this.reversed.seconds[0]}}findAllowedDayInMonth(e,n,t,s){var a,l;if(s<1)throw new Error("startDay must not be smaller than 1.");let o=C(n,t),u=this.days.length!==31,m=this.weekdays.length!==7;if(!u&&!m)return s>o?e==="next"?void 0:o:s;let i;u&&(i=e==="next"?this.days.find(h=>h>=s):this.reversed.days.find(h=>h<=s),i!==void 0&&i>o&&(i=void 0));let d;if(m){let h=new Date(n,t,s).getDay(),x=e==="next"?(a=this.weekdays.find(b=>b>=h))!=null?a:this.weekdays[0]:(l=this.reversed.weekdays.find(b=>b<=h))!=null?l:this.reversed.weekdays[0];if(x!==void 0){let b=e==="next"?E(h,x):E(x,h);d=e==="next"?s+b:s-b,(d>o||d<1)&&(d=void 0)}}if(i!==void 0&&d!==void 0)return e==="next"?Math.min(i,d):Math.max(i,d);if(i!==void 0)return i;if(d!==void 0)return d}getNextDate(e=new Date){let n=I(e),t=n.year,s=this.months.findIndex(u=>u>=n.month);s===-1&&(s=0,t++);let o=this.months.length*5;for(let u=0;u<o;u++){let m=t+Math.floor((s+u)/this.months.length),i=this.months[(s+u)%this.months.length],d=m===n.year&&i===n.month,a=this.findAllowedDayInMonth("next",m,i,d?n.day:1),l=d&&a===n.day;if(a!==void 0&&l){let h=this.findAllowedTime("next",n);if(h!==void 0)return new Date(m,i,a,h.hour,h.minute,h.second);a=this.findAllowedDayInMonth("next",m,i,a+1),l=!1}if(a!==void 0&&!l)return new Date(m,i,a,this.hours[0],this.minutes[0],this.seconds[0])}throw new Error("No valid next date was found.")}getNextDates(e,n){let t=[],s;for(let o=0;o<e;o++)s=this.getNextDate(s!=null?s:n),t.push(s);return t}*getNextDatesIterator(e,n){let t;for(;;){if(t=this.getNextDate(e),e=t,n&&n.getTime()<t.getTime())return;yield t}}getPrevDate(e=new Date){let n=I(e),t=n.year,s=this.reversed.months.findIndex(u=>u<=n.month);s===-1&&(s=0,t--);let o=this.reversed.months.length*5;for(let u=0;u<o;u++){let m=t-Math.floor((s+u)/this.reversed.months.length),i=this.reversed.months[(s+u)%this.reversed.months.length],d=m===n.year&&i===n.month,a=this.findAllowedDayInMonth("prev",m,i,d?n.day:31),l=d&&a===n.day;if(a!==void 0&&l){let h=this.findAllowedTime("prev",n);if(h!==void 0)return new Date(m,i,a,h.hour,h.minute,h.second);a>1&&(a=this.findAllowedDayInMonth("prev",m,i,a-1),l=!1)}if(a!==void 0&&!l)return new Date(m,i,a,this.reversed.hours[0],this.reversed.minutes[0],this.reversed.seconds[0])}throw new Error("No valid previous date was found.")}getPrevDates(e,n){let t=[],s;for(let o=0;o<e;o++)s=this.getPrevDate(s!=null?s:n),t.push(s);return t}*getPrevDatesIterator(e,n){let t;for(;;){if(t=this.getPrevDate(e),e=t,n&&n.getTime()>t.getTime())return;yield t}}matchDate(e){let{second:n,minute:t,hour:s,day:o,month:u,weekday:m}=I(e);return this.seconds.indexOf(n)!==-1&&this.minutes.indexOf(t)!==-1&&this.hours.indexOf(s)!==-1&&this.months.indexOf(u)!==-1&&(this.days.indexOf(o)!==-1||this.weekdays.indexOf(m)!==-1)}};var G={min:0,max:59},Z={min:0,max:59},q={min:0,max:23},J={min:1,max:31},K={min:1,max:12,aliases:{jan:"1",feb:"2",mar:"3",apr:"4",may:"5",jun:"6",jul:"7",aug:"8",sep:"9",oct:"10",nov:"11",dec:"12"}},Q={min:0,max:6,aliases:{"7":"0",sun:"0",mon:"1",tue:"2",wed:"3",thu:"4",fri:"5",sat:"6"}},V={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 1 *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@hourly":"0 * * * *","@minutely":"* * * * *"};function w(r,e){let n=new Set;if(r==="*"){for(let a=e.min;a<=e.max;a=a+1)n.add(a);return n}let t=r.split(",");if(t.length>1)return t.forEach(a=>{w(a,e).forEach(h=>n.add(h))}),n;let s=a=>{var h,x;a=(x=(h=e.aliases)==null?void 0:h[a.toLowerCase()])!=null?x:a;let l=parseInt(a,10);if(Number.isNaN(l))throw new Error(`Failed to parse ${r}: ${a} is NaN.`);if(l<e.min||l>e.max)throw new Error(`Failed to parse ${r}: ${a} is outside of constraint range of ${e.min} - ${e.max}.`);return l},o=/^((([0-9a-zA-Z]+)-([0-9a-zA-Z]+))|\*)(\/([0-9]+))?$/.exec(r);if(o===null)return n.add(s(r)),n;let u=o[1]==="*"?e.min:s(o[3]),m=o[1]==="*"?e.max:s(o[4]);if(u>m)throw new Error(`Failed to parse ${r}: Invalid range (start: ${u}, end: ${m}).`);let i=o[6],d=1;if(i!==void 0){if(d=parseInt(i,10),Number.isNaN(d))throw new Error(`Failed to parse step: ${i} is NaN.`);if(d<1)throw new Error(`Failed to parse step: Expected ${i} to be greater than 0.`)}for(let a=u;a<=m;a=a+d)n.add(a);return n}function ee(r){var i;if(typeof r!="string")throw new TypeError("Invalid cron expression: must be of type string.");r=(i=V[r.toLowerCase()])!=null?i:r;let e=r.split(" ");if(e.length<5||e.length>6)throw new Error("Invalid cron expression: expected 5 or 6 elements.");let n=e.length===6?e[0]:"0",t=e.length===6?e[1]:e[0],s=e.length===6?e[2]:e[1],o=e.length===6?e[3]:e[2],u=e.length===6?e[4]:e[3],m=e.length===6?e[5]:e[4];return new M({seconds:w(n,G),minutes:w(t,Z),hours:w(s,q),days:w(o,J),months:new Set(Array.from(w(u,K)).map(d=>d-1)),weekdays:w(m,Q)})}module.exports=Y(ne);0&&(module.exports={Cron,IntervalBasedCronScheduler,TIMEOUT_MAX,TimerBasedCronScheduler,extractDateElements,getDaysBetweenWeekdays,getDaysInMonth,longTimeout,parseCronExpression,wrapFunction});
//# sourceMappingURL=cron-schedule.cjs.min.js.map

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

var cronSchedule=(()=>{var M=Object.defineProperty,z=Object.defineProperties;var P=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var R=(r,e,n)=>e in r?M(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,H=(r,e)=>{for(var n in e||(e={}))B.call(e,n)&&R(r,n,e[n]);if(N)for(var n of N(e))L.call(e,n)&&R(r,n,e[n]);return r},$=(r,e)=>z(r,P(e)),j=r=>M(r,"__esModule",{value:!0});var Y=(r,e)=>{j(r);for(var n in e)M(r,n,{get:e[n],enumerable:!0})};var O=(r,e,n)=>{if(!e.has(r))throw TypeError("Cannot "+n)};var f=(r,e,n)=>(O(r,e,"read from private field"),n?n.call(r):e.get(r)),v=(r,e,n)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,n)},p=(r,e,n,t)=>(O(r,e,"write to private field"),t?t.call(r,n):e.set(r,n),n);var Q={};Y(Q,{Cron:()=>C,IntervalBasedCronScheduler:()=>W,TIMEOUT_MAX:()=>D,TimerBasedCronScheduler:()=>F,extractDateElements:()=>k,getDaysBetweenWeekdays:()=>E,getDaysInMonth:()=>S,longTimeout:()=>A,parseCronExpression:()=>K,wrapFunction:()=>g});var D=2147483647;function A(r,e,n){let t=0;return e>D&&(t=e-D,e=D),n!=null||(n={timeoutId:void 0}),n.timeoutId=setTimeout(()=>{t>0?A(r,t,n):r()},e),n}function k(r){return{second:r.getSeconds(),minute:r.getMinutes(),hour:r.getHours(),day:r.getDate(),month:r.getMonth(),weekday:r.getDay(),year:r.getFullYear()}}function S(r,e){return new Date(r,e+1,0).getDate()}function E(r,e){return r<=e?e-r:6-r+e+1}function g(r,e){return()=>{try{let n=r();n instanceof Promise&&n.catch(t=>{e&&e(t)})}catch(n){e&&e(n)}}}var I,y,c,T,W=class{constructor(e){v(this,I,void 0);v(this,y,void 0);v(this,c,[]);v(this,T,1);p(this,I,e),this.start()}start(){if(f(this,y)!==void 0)throw new Error("Scheduler already started.");p(this,y,setInterval(this.processTasks.bind(this),f(this,I)))}stop(){f(this,y)&&(clearInterval(f(this,y)),p(this,y,void 0))}insertTask(e){let n=f(this,c).findIndex(t=>t.nextExecution.getTime()>e.nextExecution.getTime());f(this,c).splice(n,0,e)}registerTask(e,n,t){var o;let s=f(this,T);return this.insertTask({id:s,cron:e,nextExecution:e.getNextDate(),task:n,isOneTimeTask:(o=t==null?void 0:t.isOneTimeTask)!=null?o:!1,errorHandler:t==null?void 0:t.errorHandler}),p(this,T,f(this,T)+1),s}unregisterTask(e){let n=f(this,c).findIndex(t=>t.id===e);if(n===-1)throw new Error("Task not found.");f(this,c).splice(n,1)}sortTasks(){f(this,c).sort((e,n)=>e.nextExecution.getTime()-n.nextExecution.getTime())}processTasks(){let e=Date.now(),n=!1,t=!1;for(let s=0;s<f(this,c).length;s+=1){let o=f(this,c)[s];if(o.nextExecution.getTime()<=e)g(o.task,o.errorHandler)(),o.isOneTimeTask?t=!0:(n=!0,o.nextExecution=o.cron.getNextDate());else break}t&&p(this,c,f(this,c).filter(s=>s.nextExecution.getTime()>e)),n&&this.sortTasks()}};I=new WeakMap,y=new WeakMap,c=new WeakMap,T=new WeakMap;var F=class{static setTimeout(e,n,t){let o=e.getNextDate().getTime()-Date.now();return A(g(n,t==null?void 0:t.errorHandler),o)}static setInterval(e,n,t){var u;let s=(u=t==null?void 0:t.handle)!=null?u:{timeoutId:void 0},{timeoutId:o}=this.setTimeout(e,()=>{g(n,t==null?void 0:t.errorHandler)(),this.setInterval(e,n,$(H({},t),{handle:s}))});return s.timeoutId=o,s}static clearTimeoutOrInterval(e){e.timeoutId&&clearTimeout(e.timeoutId)}};var C=class{constructor({seconds:e,minutes:n,hours:t,days:s,months:o,weekdays:u}){if(!e||e.size===0)throw new Error("There must be at least one allowed second.");if(!n||n.size===0)throw new Error("There must be at least one allowed minute.");if(!t||t.size===0)throw new Error("There must be at least one allowed hour.");if(!o||o.size===0)throw new Error("There must be at least one allowed month.");if((!u||u.size===0)&&(!s||s.size===0))throw new Error("There must be at least one allowed day or weekday.");this.seconds=Array.from(e).sort((i,d)=>i-d),this.minutes=Array.from(n).sort((i,d)=>i-d),this.hours=Array.from(t).sort((i,d)=>i-d),this.days=Array.from(s).sort((i,d)=>i-d),this.months=Array.from(o).sort((i,d)=>i-d),this.weekdays=Array.from(u).sort((i,d)=>i-d);let m=(i,d,a)=>{if(d.some(h=>typeof h!="number"||h%1!=0||h<a.min||h>a.max))throw new Error(`${i} must only consist of integers which are within the range of ${a.min} and ${a.max}`)};m("seconds",this.seconds,{min:0,max:59}),m("minutes",this.minutes,{min:0,max:59}),m("hours",this.hours,{min:0,max:23}),m("days",this.days,{min:1,max:31}),m("months",this.months,{min:0,max:11}),m("weekdays",this.weekdays,{min:0,max:6}),this.reversed={seconds:this.seconds.map(i=>i).reverse(),minutes:this.minutes.map(i=>i).reverse(),hours:this.hours.map(i=>i).reverse(),days:this.days.map(i=>i).reverse(),months:this.months.map(i=>i).reverse(),weekdays:this.weekdays.map(i=>i).reverse()}}findAllowedHour(e,n){return e==="next"?this.hours.find(t=>t>=n):this.reversed.hours.find(t=>t<=n)}findAllowedMinute(e,n){return e==="next"?this.minutes.find(t=>t>=n):this.reversed.minutes.find(t=>t<=n)}findAllowedSecond(e,n){return e==="next"?this.seconds.find(t=>t>n):this.reversed.seconds.find(t=>t<n)}findAllowedTime(e,n){let t=this.findAllowedHour(e,n.hour);if(t!==void 0)if(t===n.hour){let s=this.findAllowedMinute(e,n.minute);if(s!==void 0)if(s===n.minute){let o=this.findAllowedSecond(e,n.second);if(o!==void 0)return{hour:t,minute:s,second:o};if(s=this.findAllowedMinute(e,e==="next"?n.minute+1:n.minute-1),s!==void 0)return{hour:t,minute:s,second:e==="next"?this.seconds[0]:this.reversed.seconds[0]}}else return{hour:t,minute:s,second:e==="next"?this.seconds[0]:this.reversed.seconds[0]};if(t=this.findAllowedHour(e,e==="next"?n.hour+1:n.hour-1),t!==void 0)return{hour:t,minute:e==="next"?this.minutes[0]:this.reversed.minutes[0],second:e==="next"?this.seconds[0]:this.reversed.seconds[0]}}else return{hour:t,minute:e==="next"?this.minutes[0]:this.reversed.minutes[0],second:e==="next"?this.seconds[0]:this.reversed.seconds[0]}}findAllowedDayInMonth(e,n,t,s){var a,h;if(s<1)throw new Error("startDay must not be smaller than 1.");let o=S(n,t),u=this.days.length!==31,m=this.weekdays.length!==7;if(!u&&!m)return s>o?e==="next"?void 0:o:s;let i;u&&(i=e==="next"?this.days.find(l=>l>=s):this.reversed.days.find(l=>l<=s),i!==void 0&&i>o&&(i=void 0));let d;if(m){let l=new Date(n,t,s).getDay(),x=e==="next"?(a=this.weekdays.find(b=>b>=l))!=null?a:this.weekdays[0]:(h=this.reversed.weekdays.find(b=>b<=l))!=null?h:this.reversed.weekdays[0];if(x!==void 0){let b=e==="next"?E(l,x):E(x,l);d=e==="next"?s+b:s-b,(d>o||d<1)&&(d=void 0)}}if(i!==void 0&&d!==void 0)return e==="next"?Math.min(i,d):Math.max(i,d);if(i!==void 0)return i;if(d!==void 0)return d}getNextDate(e=new Date){let n=k(e),t=n.year,s=this.months.findIndex(u=>u>=n.month);s===-1&&(s=0,t++);let o=this.months.length*5;for(let u=0;u<o;u++){let m=t+Math.floor((s+u)/this.months.length),i=this.months[(s+u)%this.months.length],d=m===n.year&&i===n.month,a=this.findAllowedDayInMonth("next",m,i,d?n.day:1),h=d&&a===n.day;if(a!==void 0&&h){let l=this.findAllowedTime("next",n);if(l!==void 0)return new Date(m,i,a,l.hour,l.minute,l.second);a=this.findAllowedDayInMonth("next",m,i,a+1),h=!1}if(a!==void 0&&!h)return new Date(m,i,a,this.hours[0],this.minutes[0],this.seconds[0])}throw new Error("No valid next date was found.")}getNextDates(e,n){let t=[],s;for(let o=0;o<e;o++)s=this.getNextDate(s!=null?s:n),t.push(s);return t}*getNextDatesIterator(e,n){let t;for(;;){if(t=this.getNextDate(e),e=t,n&&n.getTime()<t.getTime())return;yield t}}getPrevDate(e=new Date){let n=k(e),t=n.year,s=this.reversed.months.findIndex(u=>u<=n.month);s===-1&&(s=0,t--);let o=this.reversed.months.length*5;for(let u=0;u<o;u++){let m=t-Math.floor((s+u)/this.reversed.months.length),i=this.reversed.months[(s+u)%this.reversed.months.length],d=m===n.year&&i===n.month,a=this.findAllowedDayInMonth("prev",m,i,d?n.day:31),h=d&&a===n.day;if(a!==void 0&&h){let l=this.findAllowedTime("prev",n);if(l!==void 0)return new Date(m,i,a,l.hour,l.minute,l.second);a>1&&(a=this.findAllowedDayInMonth("prev",m,i,a-1),h=!1)}if(a!==void 0&&!h)return new Date(m,i,a,this.reversed.hours[0],this.reversed.minutes[0],this.reversed.seconds[0])}throw new Error("No valid previous date was found.")}getPrevDates(e,n){let t=[],s;for(let o=0;o<e;o++)s=this.getPrevDate(s!=null?s:n),t.push(s);return t}*getPrevDatesIterator(e,n){let t;for(;;){if(t=this.getPrevDate(e),e=t,n&&n.getTime()>t.getTime())return;yield t}}matchDate(e){let{second:n,minute:t,hour:s,day:o,month:u,weekday:m}=k(e);return this.seconds.indexOf(n)!==-1&&this.minutes.indexOf(t)!==-1&&this.hours.indexOf(s)!==-1&&this.months.indexOf(u)!==-1&&(this.days.indexOf(o)!==-1||this.weekdays.indexOf(m)!==-1)}};var G={min:0,max:59},Z={min:0,max:59},U={min:0,max:23},X={min:1,max:31},_={min:1,max:12,aliases:{jan:"1",feb:"2",mar:"3",apr:"4",may:"5",jun:"6",jul:"7",aug:"8",sep:"9",oct:"10",nov:"11",dec:"12"}},q={min:0,max:6,aliases:{"7":"0",sun:"0",mon:"1",tue:"2",wed:"3",thu:"4",fri:"5",sat:"6"}},J={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 1 *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@hourly":"0 * * * *","@minutely":"* * * * *"};function w(r,e){let n=new Set;if(r==="*"){for(let a=e.min;a<=e.max;a=a+1)n.add(a);return n}let t=r.split(",");if(t.length>1)return t.forEach(a=>{w(a,e).forEach(l=>n.add(l))}),n;let s=a=>{var l,x;a=(x=(l=e.aliases)==null?void 0:l[a.toLowerCase()])!=null?x:a;let h=parseInt(a,10);if(Number.isNaN(h))throw new Error(`Failed to parse ${r}: ${a} is NaN.`);if(h<e.min||h>e.max)throw new Error(`Failed to parse ${r}: ${a} is outside of constraint range of ${e.min} - ${e.max}.`);return h},o=/^((([0-9a-zA-Z]+)-([0-9a-zA-Z]+))|\*)(\/([0-9]+))?$/.exec(r);if(o===null)return n.add(s(r)),n;let u=o[1]==="*"?e.min:s(o[3]),m=o[1]==="*"?e.max:s(o[4]);if(u>=m-1)throw new Error(`Failed to parse ${r}: Invalid range (start: ${u}, end: ${m}).`);let i=o[6],d=1;if(i!==void 0){if(d=parseInt(i,10),Number.isNaN(d))throw new Error(`Failed to parse step: ${i} is NaN.`);if(d<1)throw new Error(`Failed to parse step: Expected ${i} to be greater than 0.`)}for(let a=u;a<=m;a=a+d)n.add(a);return n}function K(r){var i;if(typeof r!="string")throw new TypeError("Invalid cron expression: must be of type string.");r=(i=J[r.toLowerCase()])!=null?i:r;let e=r.split(" ");if(e.length<5||e.length>6)throw new Error("Invalid cron expression: expected 5 or 6 elements.");let n=e.length===6?e[0]:"0",t=e.length===6?e[1]:e[0],s=e.length===6?e[2]:e[1],o=e.length===6?e[3]:e[2],u=e.length===6?e[4]:e[3],m=e.length===6?e[5]:e[4];return new C({seconds:w(n,G),minutes:w(t,Z),hours:w(s,U),days:w(o,X),months:new Set(Array.from(w(u,_)).map(d=>d-1)),weekdays:w(m,q)})}return Q;})();
var cronSchedule=(()=>{var D=Object.defineProperty,z=Object.defineProperties,P=Object.getOwnPropertyDescriptor,B=Object.getOwnPropertyDescriptors,L=Object.getOwnPropertyNames,S=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var N=(r,e,n)=>e in r?D(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,H=(r,e)=>{for(var n in e||(e={}))R.call(e,n)&&N(r,n,e[n]);if(S)for(var n of S(e))U.call(e,n)&&N(r,n,e[n]);return r},O=(r,e)=>z(r,B(e)),X=r=>D(r,"__esModule",{value:!0});var _=(r,e)=>{for(var n in e)D(r,n,{get:e[n],enumerable:!0})},j=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of L(e))!R.call(r,s)&&(n||s!=="default")&&D(r,s,{get:()=>e[s],enumerable:!(t=P(e,s))||t.enumerable});return r};var Y=(r=>(e,n)=>r&&r.get(e)||(n=j(X({}),e,1),r&&r.set(e,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var $=(r,e,n)=>{if(!e.has(r))throw TypeError("Cannot "+n)};var f=(r,e,n)=>($(r,e,"read from private field"),n?n.call(r):e.get(r)),v=(r,e,n)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,n)},p=(r,e,n,t)=>($(r,e,"write to private field"),t?t.call(r,n):e.set(r,n),n);var ne={};_(ne,{Cron:()=>M,IntervalBasedCronScheduler:()=>W,TIMEOUT_MAX:()=>re,TimerBasedCronScheduler:()=>F,extractDateElements:()=>I,getDaysBetweenWeekdays:()=>E,getDaysInMonth:()=>C,longTimeout:()=>A,parseCronExpression:()=>ee,wrapFunction:()=>g});var re=2147483647;function A(r,e,n){let t=0;return e>2147483647&&(t=e-2147483647,e=2147483647),n!=null||(n={timeoutId:void 0}),n.timeoutId=setTimeout(()=>{t>0?A(r,t,n):r()},e),n}function I(r){return{second:r.getSeconds(),minute:r.getMinutes(),hour:r.getHours(),day:r.getDate(),month:r.getMonth(),weekday:r.getDay(),year:r.getFullYear()}}function C(r,e){return new Date(r,e+1,0).getDate()}function E(r,e){return r<=e?e-r:6-r+e+1}function g(r,e){return()=>{try{let n=r();n instanceof Promise&&n.catch(t=>{e&&e(t)})}catch(n){e&&e(n)}}}var T,y,c,k,W=class{constructor(e){v(this,T,void 0);v(this,y,void 0);v(this,c,[]);v(this,k,1);p(this,T,e),this.start()}start(){if(f(this,y)!==void 0)throw new Error("Scheduler already started.");p(this,y,setInterval(this.processTasks.bind(this),f(this,T)))}stop(){f(this,y)&&(clearInterval(f(this,y)),p(this,y,void 0))}insertTask(e){let n=f(this,c).findIndex(t=>t.nextExecution.getTime()>e.nextExecution.getTime());f(this,c).splice(n,0,e)}registerTask(e,n,t){var o;let s=f(this,k);return this.insertTask({id:s,cron:e,nextExecution:e.getNextDate(),task:n,isOneTimeTask:(o=t==null?void 0:t.isOneTimeTask)!=null?o:!1,errorHandler:t==null?void 0:t.errorHandler}),p(this,k,f(this,k)+1),s}unregisterTask(e){let n=f(this,c).findIndex(t=>t.id===e);if(n===-1)throw new Error("Task not found.");f(this,c).splice(n,1)}sortTasks(){f(this,c).sort((e,n)=>e.nextExecution.getTime()-n.nextExecution.getTime())}processTasks(){let e=Date.now(),n=!1,t=!1;for(let s=0;s<f(this,c).length;s+=1){let o=f(this,c)[s];if(o.nextExecution.getTime()<=e)g(o.task,o.errorHandler)(),o.isOneTimeTask?t=!0:(n=!0,o.nextExecution=o.cron.getNextDate());else break}t&&p(this,c,f(this,c).filter(s=>s.nextExecution.getTime()>e)),n&&this.sortTasks()}};T=new WeakMap,y=new WeakMap,c=new WeakMap,k=new WeakMap;var F=class{static setTimeout(e,n,t){let o=e.getNextDate().getTime()-Date.now();return A(g(n,t==null?void 0:t.errorHandler),o)}static setInterval(e,n,t){var u;let s=(u=t==null?void 0:t.handle)!=null?u:{timeoutId:void 0},{timeoutId:o}=this.setTimeout(e,()=>{g(n,t==null?void 0:t.errorHandler)(),this.setInterval(e,n,O(H({},t),{handle:s}))});return s.timeoutId=o,s}static clearTimeoutOrInterval(e){e.timeoutId&&clearTimeout(e.timeoutId)}};var M=class{constructor({seconds:e,minutes:n,hours:t,days:s,months:o,weekdays:u}){if(!e||e.size===0)throw new Error("There must be at least one allowed second.");if(!n||n.size===0)throw new Error("There must be at least one allowed minute.");if(!t||t.size===0)throw new Error("There must be at least one allowed hour.");if(!o||o.size===0)throw new Error("There must be at least one allowed month.");if((!u||u.size===0)&&(!s||s.size===0))throw new Error("There must be at least one allowed day or weekday.");this.seconds=Array.from(e).sort((i,d)=>i-d),this.minutes=Array.from(n).sort((i,d)=>i-d),this.hours=Array.from(t).sort((i,d)=>i-d),this.days=Array.from(s).sort((i,d)=>i-d),this.months=Array.from(o).sort((i,d)=>i-d),this.weekdays=Array.from(u).sort((i,d)=>i-d);let m=(i,d,a)=>{if(d.some(l=>typeof l!="number"||l%1!==0||l<a.min||l>a.max))throw new Error(`${i} must only consist of integers which are within the range of ${a.min} and ${a.max}`)};m("seconds",this.seconds,{min:0,max:59}),m("minutes",this.minutes,{min:0,max:59}),m("hours",this.hours,{min:0,max:23}),m("days",this.days,{min:1,max:31}),m("months",this.months,{min:0,max:11}),m("weekdays",this.weekdays,{min:0,max:6}),this.reversed={seconds:this.seconds.map(i=>i).reverse(),minutes:this.minutes.map(i=>i).reverse(),hours:this.hours.map(i=>i).reverse(),days:this.days.map(i=>i).reverse(),months:this.months.map(i=>i).reverse(),weekdays:this.weekdays.map(i=>i).reverse()}}findAllowedHour(e,n){return e==="next"?this.hours.find(t=>t>=n):this.reversed.hours.find(t=>t<=n)}findAllowedMinute(e,n){return e==="next"?this.minutes.find(t=>t>=n):this.reversed.minutes.find(t=>t<=n)}findAllowedSecond(e,n){return e==="next"?this.seconds.find(t=>t>n):this.reversed.seconds.find(t=>t<n)}findAllowedTime(e,n){let t=this.findAllowedHour(e,n.hour);if(t!==void 0)if(t===n.hour){let s=this.findAllowedMinute(e,n.minute);if(s!==void 0)if(s===n.minute){let o=this.findAllowedSecond(e,n.second);if(o!==void 0)return{hour:t,minute:s,second:o};if(s=this.findAllowedMinute(e,e==="next"?n.minute+1:n.minute-1),s!==void 0)return{hour:t,minute:s,second:e==="next"?this.seconds[0]:this.reversed.seconds[0]}}else return{hour:t,minute:s,second:e==="next"?this.seconds[0]:this.reversed.seconds[0]};if(t=this.findAllowedHour(e,e==="next"?n.hour+1:n.hour-1),t!==void 0)return{hour:t,minute:e==="next"?this.minutes[0]:this.reversed.minutes[0],second:e==="next"?this.seconds[0]:this.reversed.seconds[0]}}else return{hour:t,minute:e==="next"?this.minutes[0]:this.reversed.minutes[0],second:e==="next"?this.seconds[0]:this.reversed.seconds[0]}}findAllowedDayInMonth(e,n,t,s){var a,l;if(s<1)throw new Error("startDay must not be smaller than 1.");let o=C(n,t),u=this.days.length!==31,m=this.weekdays.length!==7;if(!u&&!m)return s>o?e==="next"?void 0:o:s;let i;u&&(i=e==="next"?this.days.find(h=>h>=s):this.reversed.days.find(h=>h<=s),i!==void 0&&i>o&&(i=void 0));let d;if(m){let h=new Date(n,t,s).getDay(),x=e==="next"?(a=this.weekdays.find(b=>b>=h))!=null?a:this.weekdays[0]:(l=this.reversed.weekdays.find(b=>b<=h))!=null?l:this.reversed.weekdays[0];if(x!==void 0){let b=e==="next"?E(h,x):E(x,h);d=e==="next"?s+b:s-b,(d>o||d<1)&&(d=void 0)}}if(i!==void 0&&d!==void 0)return e==="next"?Math.min(i,d):Math.max(i,d);if(i!==void 0)return i;if(d!==void 0)return d}getNextDate(e=new Date){let n=I(e),t=n.year,s=this.months.findIndex(u=>u>=n.month);s===-1&&(s=0,t++);let o=this.months.length*5;for(let u=0;u<o;u++){let m=t+Math.floor((s+u)/this.months.length),i=this.months[(s+u)%this.months.length],d=m===n.year&&i===n.month,a=this.findAllowedDayInMonth("next",m,i,d?n.day:1),l=d&&a===n.day;if(a!==void 0&&l){let h=this.findAllowedTime("next",n);if(h!==void 0)return new Date(m,i,a,h.hour,h.minute,h.second);a=this.findAllowedDayInMonth("next",m,i,a+1),l=!1}if(a!==void 0&&!l)return new Date(m,i,a,this.hours[0],this.minutes[0],this.seconds[0])}throw new Error("No valid next date was found.")}getNextDates(e,n){let t=[],s;for(let o=0;o<e;o++)s=this.getNextDate(s!=null?s:n),t.push(s);return t}*getNextDatesIterator(e,n){let t;for(;;){if(t=this.getNextDate(e),e=t,n&&n.getTime()<t.getTime())return;yield t}}getPrevDate(e=new Date){let n=I(e),t=n.year,s=this.reversed.months.findIndex(u=>u<=n.month);s===-1&&(s=0,t--);let o=this.reversed.months.length*5;for(let u=0;u<o;u++){let m=t-Math.floor((s+u)/this.reversed.months.length),i=this.reversed.months[(s+u)%this.reversed.months.length],d=m===n.year&&i===n.month,a=this.findAllowedDayInMonth("prev",m,i,d?n.day:31),l=d&&a===n.day;if(a!==void 0&&l){let h=this.findAllowedTime("prev",n);if(h!==void 0)return new Date(m,i,a,h.hour,h.minute,h.second);a>1&&(a=this.findAllowedDayInMonth("prev",m,i,a-1),l=!1)}if(a!==void 0&&!l)return new Date(m,i,a,this.reversed.hours[0],this.reversed.minutes[0],this.reversed.seconds[0])}throw new Error("No valid previous date was found.")}getPrevDates(e,n){let t=[],s;for(let o=0;o<e;o++)s=this.getPrevDate(s!=null?s:n),t.push(s);return t}*getPrevDatesIterator(e,n){let t;for(;;){if(t=this.getPrevDate(e),e=t,n&&n.getTime()>t.getTime())return;yield t}}matchDate(e){let{second:n,minute:t,hour:s,day:o,month:u,weekday:m}=I(e);return this.seconds.indexOf(n)!==-1&&this.minutes.indexOf(t)!==-1&&this.hours.indexOf(s)!==-1&&this.months.indexOf(u)!==-1&&(this.days.indexOf(o)!==-1||this.weekdays.indexOf(m)!==-1)}};var G={min:0,max:59},Z={min:0,max:59},q={min:0,max:23},J={min:1,max:31},K={min:1,max:12,aliases:{jan:"1",feb:"2",mar:"3",apr:"4",may:"5",jun:"6",jul:"7",aug:"8",sep:"9",oct:"10",nov:"11",dec:"12"}},Q={min:0,max:6,aliases:{"7":"0",sun:"0",mon:"1",tue:"2",wed:"3",thu:"4",fri:"5",sat:"6"}},V={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 1 *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@hourly":"0 * * * *","@minutely":"* * * * *"};function w(r,e){let n=new Set;if(r==="*"){for(let a=e.min;a<=e.max;a=a+1)n.add(a);return n}let t=r.split(",");if(t.length>1)return t.forEach(a=>{w(a,e).forEach(h=>n.add(h))}),n;let s=a=>{var h,x;a=(x=(h=e.aliases)==null?void 0:h[a.toLowerCase()])!=null?x:a;let l=parseInt(a,10);if(Number.isNaN(l))throw new Error(`Failed to parse ${r}: ${a} is NaN.`);if(l<e.min||l>e.max)throw new Error(`Failed to parse ${r}: ${a} is outside of constraint range of ${e.min} - ${e.max}.`);return l},o=/^((([0-9a-zA-Z]+)-([0-9a-zA-Z]+))|\*)(\/([0-9]+))?$/.exec(r);if(o===null)return n.add(s(r)),n;let u=o[1]==="*"?e.min:s(o[3]),m=o[1]==="*"?e.max:s(o[4]);if(u>m)throw new Error(`Failed to parse ${r}: Invalid range (start: ${u}, end: ${m}).`);let i=o[6],d=1;if(i!==void 0){if(d=parseInt(i,10),Number.isNaN(d))throw new Error(`Failed to parse step: ${i} is NaN.`);if(d<1)throw new Error(`Failed to parse step: Expected ${i} to be greater than 0.`)}for(let a=u;a<=m;a=a+d)n.add(a);return n}function ee(r){var i;if(typeof r!="string")throw new TypeError("Invalid cron expression: must be of type string.");r=(i=V[r.toLowerCase()])!=null?i:r;let e=r.split(" ");if(e.length<5||e.length>6)throw new Error("Invalid cron expression: expected 5 or 6 elements.");let n=e.length===6?e[0]:"0",t=e.length===6?e[1]:e[0],s=e.length===6?e[2]:e[1],o=e.length===6?e[3]:e[2],u=e.length===6?e[4]:e[3],m=e.length===6?e[5]:e[4];return new M({seconds:w(n,G),minutes:w(t,Z),hours:w(s,q),days:w(o,J),months:new Set(Array.from(w(u,K)).map(d=>d-1)),weekdays:w(m,Q)})}return Y(ne);})();
//# sourceMappingURL=cron-schedule.iife.min.js.map
{
"name": "cron-schedule",
"description": "A zero-dependency cron parser and scheduler for Node.js, Deno and the browser.",
"version": "3.0.4",
"version": "3.0.5",
"license": "MIT",

@@ -12,3 +12,3 @@ "repository": {

"contributors": [
"Airfooox <konstantin.zisiadis@st.ovgu.de>"
"buffcode <l.stoetzel@meeva.de>"
],

@@ -74,4 +74,4 @@ "keywords": [

"tsc:check": "tsc --project ./tsconfig.json --noEmit",
"lint": "eslint \"src/**/*.ts\"",
"lint:fix": "eslint --fix \"src/**/*.ts\"",
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
"lint:fix": "eslint --fix \"src/**/*.ts\" \"test/**/*.ts\"",
"test": "jest -c jest.config.js",

@@ -85,27 +85,30 @@ "test:watch": "jest -c jest.config.js --watchAll",

"devDependencies": {
"@commitlint/cli": "13.2.1",
"@commitlint/config-conventional": "13.2.0",
"@commitlint/prompt-cli": "13.2.1",
"@semantic-release/changelog": "6.0.0",
"@semantic-release/git": "9.0.1",
"@types/jest": "27.0.2",
"@typescript-eslint/eslint-plugin": "5.2.0",
"@typescript-eslint/parser": "5.2.0",
"@typescript-eslint/typescript-estree": "5.2.0",
"esbuild": "0.13.10",
"eslint": "8.1.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-import": "2.25.2",
"@commitlint/cli": "16.2.1",
"@commitlint/config-conventional": "16.2.1",
"@commitlint/prompt-cli": "16.2.1",
"@semantic-release/changelog": "6.0.1",
"@semantic-release/git": "10.0.1",
"@types/jest": "27.4.1",
"@typescript-eslint/eslint-plugin": "5.12.1",
"@typescript-eslint/parser": "5.12.1",
"@typescript-eslint/typescript-estree": "5.12.1",
"esbuild": "0.14.23",
"eslint": "8.9.0",
"eslint-config-prettier": "8.4.0",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-security": "1.4.0",
"husky": "7.0.4",
"jest": "27.3.1",
"pinst": "2.1.6",
"prettier": "2.4.1",
"jest": "27.5.1",
"pinst": "3.0.0",
"prettier": "2.5.1",
"rimraf": "3.0.2",
"semantic-release": "18.0.0",
"ts-jest": "27.0.7",
"semantic-release": "19.0.2",
"ts-jest": "27.1.3",
"tslib": "2.3.1",
"typescript": "4.4.4"
"typescript": "4.5.5"
},
"resolutions": {
"npm/chalk": "^4.1.2"
},
"commitlint": {

@@ -115,3 +118,4 @@ "extends": [

]
}
},
"packageManager": "yarn@3.2.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

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