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

cron

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cron - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

29

lib/cron.js

@@ -92,7 +92,9 @@ (function(root, factory) {

var months = Object.keys(this.month);
var ok = false;
/* if a dayOfMonth is not found in all months, we only need to fix the last
wrong month to prevent infinite loop */
var lastWrongMonth={};
for (var i = 0; i < months.length; i++) {
var m = months[i];
var con = CronTime.monthConstraints[parseInt(m, 10)];
var ok = false;
var dsom = Object.keys(this.dayOfMonth);

@@ -102,14 +104,25 @@

var dom = dsom[j];
if (dom <= con) {
if (dom <= con)
ok = true;
} else {
delete this.dayOfMonth[j];
this.dayOfMonth[String(Number(dsom[j])) % con] = true;
}
}
if (!ok) {
// save the month inorder to be fixed if all months fails (infinite loop)
lastWrongMonth=m;
console.warn("Month '" + m + "' is limited to '" + con + "' days.");
}
}
// infinit loop detected (dayOfMonth is not found in all months)
if(!ok){
var con = CronTime.monthConstraints[parseInt(lastWrongMonth, 10)];
var dsom = Object.keys(this.dayOfMonth);
for (var j = 0; j < dsom.length; j++) {
var dom = dsom[j];
if(dom > con){
delete this.dayOfMonth[dom];
var fixedDay = Number(dom)% con;
this.dayOfMonth[fixedDay] = true;
}
}
}
},

@@ -116,0 +129,0 @@

{
"name": "cron",
"description": "Cron jobs for your node",
"version": "1.4.0",
"version": "1.4.1",
"author": "Nick Campbell <nicholas.j.campbell@gmail.com> (http://github.com/ncb000gt)",

@@ -6,0 +6,0 @@ "bugs": {

@@ -899,2 +899,24 @@ var chai = require('chai');

// from https://github.com/kelektiv/node-cron/issues/180#issuecomment-154108131
it('should run once not double', function() {
var c = 0;
var d = new Date(2015, 1, 1, 1, 1, 41, 0);
var clock = sinon.useFakeTimers(d.getTime());
var job = new cron.CronJob({
cronTime: '* * * * *',
onTick: function() {
c++;
},
start: true
});
var minute = 60 * 1000;
clock.tick(minute);
expect(c).to.eql(1);
clock.restore();
job.stop();
expect(c).to.eql(1);
});
it('should run every second monday');

@@ -901,0 +923,0 @@

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