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

node-schedule

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-schedule - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

test/schedule-cron-jobs.js

80

lib/schedule.js

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

};
this.pendingInvocations = function(){
return pendingInvocations;
};
}

@@ -134,45 +137,44 @@

var success = false;
cron_parser.parseExpression(spec, function(err, res) {
if (!err) {
var inv = scheduleNextRecurrence(res, self);
if (inv !== null) {
success = self.trackInvocation(inv);
try {
var res = cron_parser.parseExpression(spec);
var inv = scheduleNextRecurrence(res, self);
if (inv !== null) {
success = self.trackInvocation(inv);
}
} catch (err) {
var type = typeof(spec);
if (type === 'string') {
spec = new Date(spec);
}
if (spec instanceof Date) {
var inv = new Invocation(self, spec);
scheduleInvocation(inv);
success = self.trackInvocation(inv);
} else if (type === 'object') {
if (!(spec instanceof RecurrenceRule)) {
var r = new RecurrenceRule();
if ('year' in spec)
r.year = spec.year;
if ('month' in spec)
r.month = spec.month;
if ('date' in spec)
r.date = spec.date;
if ('dayOfWeek' in spec)
r.dayOfWeek = spec.dayOfWeek;
if ('hour' in spec)
r.hour = spec.hour;
if ('minute' in spec)
r.minute = spec.minute;
if ('second' in spec)
r.second = spec.second;
spec = r;
}
} else {
var type = typeof(spec);
if (type === 'string') {
spec = new Date(spec);
}
if (spec instanceof Date) {
var inv = new Invocation(self, spec);
scheduleInvocation(inv);
var inv = scheduleNextRecurrence(spec, self);
if (inv !== null)
success = self.trackInvocation(inv);
} else if (type === 'object') {
if (!(spec instanceof RecurrenceRule)) {
var r = new RecurrenceRule();
if ('year' in spec)
r.year = spec.year;
if ('month' in spec)
r.month = spec.month;
if ('date' in spec)
r.date = spec.date;
if ('dayOfWeek' in spec)
r.dayOfWeek = spec.dayOfWeek;
if ('hour' in spec)
r.hour = spec.hour;
if ('minute' in spec)
r.minute = spec.minute;
if ('second' in spec)
r.second = spec.second;
spec = r;
}
var inv = scheduleNextRecurrence(spec, self);
if (inv !== null)
success = self.trackInvocation(inv);
}
}
});
}

@@ -179,0 +181,0 @@ return success;

{
"name": "node-schedule",
"version": "0.2.0",
"version": "0.2.1",
"description": "A cron-like and not-cron-like job scheduler for Node.",

@@ -21,8 +21,9 @@ "keywords": ["schedule", "task", "job", "cron"],

"dependencies": {
"cron-parser": "~0.3.0",
"cron-parser": "~0.6.1",
"long-timeout": "~0.0.1"
},
"devDependencies": {
"nodeunit": "~0.8.1"
"nodeunit": "~0.8.1",
"sinon": "~1.12.2"
}
}

@@ -275,3 +275,14 @@ var main = require('../package.json').main;

}
},
'.pendingInvocations()': {
"Retrieves pendingInvocations of the job": function(test) {
var job = schedule.scheduleJob(new Date(Date.now() + 1000), function() {});
test.ok(job instanceof schedule.Job);
test.ok(job.pendingInvocations()[0].job);
job.cancel();
test.done();
}
}
};
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