node-schedule
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -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(); | ||
} | ||
} | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49176
13
1283
2
6
+ Addedcron-parser@0.6.4(transitive)
- Removedcron-parser@0.3.6(transitive)
Updatedcron-parser@~0.6.1