cron-parser
Advanced tools
Comparing version 0.3.4 to 0.3.5
@@ -433,2 +433,22 @@ 'use strict'; | ||
/** | ||
* Check if next suitable date exists | ||
* | ||
* @public | ||
* @return {Boolean} | ||
*/ | ||
CronExpression.prototype.hasNext = function() { | ||
var memorized = this._currentDate; | ||
try { | ||
this.next(); | ||
return true; | ||
} | ||
catch(error) { | ||
return false; | ||
} | ||
finally { | ||
this._currentDate = memorized; | ||
} | ||
}; | ||
/** | ||
* Iterate over expression iterator | ||
@@ -435,0 +455,0 @@ * |
{ | ||
"name": "cron-parser", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "Node.js library for parsing crontab instructions", | ||
@@ -26,3 +26,4 @@ "main": "lib/parser.js", | ||
"Meaglin Wasabi <Meaglin.wasabi@gmail.com>", | ||
"Mike Kusold <hello@mikekusold.com>" | ||
"Mike Kusold <hello@mikekusold.com>", | ||
"Alex Kit <alex.kit@atmajs.com>" | ||
], | ||
@@ -29,0 +30,0 @@ "license": "MIT", |
@@ -19,2 +19,3 @@ var util = require('util'); | ||
t.equal(result.expressions[0].hasNext(), true); | ||
next = result.expressions[0].next(); | ||
@@ -31,2 +32,15 @@ t.ok(next, 'first date'); | ||
}); | ||
}); | ||
}); | ||
test('no next date', function(t){ | ||
var options = { | ||
currentDate: new Date(2014, 0, 1), | ||
endDate: new Date(2014, 0, 1) | ||
}; | ||
CronParser.parseExpression('* * 2 * *', options, function(err, interval) { | ||
t.ifError(err, 'Parse read error'); | ||
t.equal(interval.hasNext(), false); | ||
t.end(); | ||
}); | ||
}) |
Sorry, the diff of this file is not supported yet
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
997
32316
11