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

cron-parser

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cron-parser - npm Package Compare versions

Comparing version 0.4.3 to 0.4.4

11

lib/expression.js

@@ -59,3 +59,3 @@ 'use strict';

[ 1, 12 ], // Month
[ 0, 6 ] // Day of week
[ 0, 7 ] // Day of week
];

@@ -169,2 +169,6 @@

if (field == 'dayOfWeek') {
value = value % 7;
}
if (value > max) {

@@ -187,2 +191,6 @@ stack.push(value);

if (field == 'dayOfWeek') {
result = result % 7;
}
if (result > max) {

@@ -311,2 +319,3 @@ stack.push(result);

CronExpression._matchSchedule = function matchSchedule (value, sequence) {
for (var i = 0, c = sequence.length; i < c; i++) {

@@ -313,0 +322,0 @@ if (sequence[i] >= value) {

2

package.json
{
"name": "cron-parser",
"version": "0.4.3",
"version": "0.4.4",
"description": "Node.js library for parsing crontab instructions",

@@ -5,0 +5,0 @@ "main": "lib/parser.js",

@@ -22,3 +22,3 @@ cron-parser

│ │ │ │ │ |
│ │ │ │ │ └ day of week (0 - 6)
│ │ │ │ │ └ day of week (0 - 7) (0 or 7 is Sun)
│ │ │ │ └───── month (1 - 12)

@@ -43,3 +43,3 @@ │ │ │ └────────── day of month (1 - 31)

var interval = parser.parseExpression('*/2 * * * *');
console.log('Date: ', interval.next()); // Sat Dec 29 2012 00:42:00 GMT+0200 (EET)

@@ -65,3 +65,3 @@ console.log('Date: ', interval.next()); // Sat Dec 29 2012 00:44:00 GMT+0200 (EET)

var interval = parser.parseExpression('*/22 * * * *', options);
while (true) {

@@ -68,0 +68,0 @@ try {

@@ -65,3 +65,2 @@ var util = require('util');

CronExpression.parse('-1 * * * * *', function(err, interval) {
console.log('Error', err);
t.ok(err, 'Error expected');

@@ -421,1 +420,117 @@ t.equal(interval, undefined, 'No interval iterator expected');

});
test('day of month and week are both set and dow is 7', function(t) {
CronExpression.parse('10 2 12 8 7', function(err, interval) {
t.ifError(err, 'Interval parse error');
t.ok(interval, 'Interval parsed');
var next = interval.next();
t.ok(next, 'Found next scheduled interval');
t.equal(next.getDay(), 0, 'Day matches');
t.equal(next.getMonth(), 7, 'Month matches');
t.equal(next.getDate(), 2, 'Day of month matches');
next = interval.next();
t.ok(next, 'Found next scheduled interval');
t.equal(next.getDay(), 0, 'Day matches');
t.equal(next.getMonth(), 7, 'Month matches');
t.equal(next.getDate(), 9, 'Day of month matches');
next = interval.next();
t.ok(next, 'Found next scheduled interval');
t.equal(next.getDay(), 3, 'Day matches');
t.equal(next.getMonth(), 7, 'Month matches');
t.equal(next.getDate(), 12, 'Day of month matches');
next = interval.next();
t.ok(next, 'Found next scheduled interval');
t.equal(next.getDay(), 0, 'Day matches');
t.equal(next.getMonth(), 7, 'Month matches');
t.equal(next.getDate(), 16, 'Day of month matches');
t.end();
});
});
test('day of month and week are both set and dow is 6,0', function(t) {
CronExpression.parse('10 2 12 8 6,0', function(err, interval) {
t.ifError(err, 'Interval parse error');
t.ok(interval, 'Interval parsed');
var next = interval.next();
console.error(next);
t.ok(next, 'Found next scheduled interval');
t.equal(next.getDay(), 6, 'Day matches');
t.equal(next.getMonth(), 7, 'Month matches');
t.equal(next.getDate(), 1, 'Day of month matches');
next = interval.next();
t.ok(next, 'Found next scheduled interval');
t.equal(next.getDay(), 6, 'Day matches');
t.equal(next.getMonth(), 7, 'Month matches');
t.equal(next.getDate(), 8, 'Day of month matches');
next = interval.next();
t.ok(next, 'Found next scheduled interval');
t.equal(next.getDay(), 3, 'Day matches');
t.equal(next.getMonth(), 7, 'Month matches');
t.equal(next.getDate(), 12, 'Day of month matches');
// next = interval.next();
t.ok(next, 'Found next scheduled interval');
t.equal(next.getDay(), 3, 'Day matches');
t.equal(next.getMonth(), 7, 'Month matches');
t.equal(next.getDate(), 12, 'Day of month matches');
t.end();
});
});
test('day of month and week are both set and dow is 6-7', function(t) {
CronExpression.parse('10 2 12 8 6-7', function(err, interval) {
t.ifError(err, 'Interval parse error');
t.ok(interval, 'Interval parsed');
var next = interval.next();
console.error(next);
t.ok(next, 'Found next scheduled interval');
t.equal(next.getDay(), 6, 'Day matches');
t.equal(next.getMonth(), 7, 'Month matches');
t.equal(next.getDate(), 1, 'Day of month matches');
next = interval.next();
t.ok(next, 'Found next scheduled interval');
t.equal(next.getDay(), 6, 'Day matches');
t.equal(next.getMonth(), 7, 'Month matches');
t.equal(next.getDate(), 8, 'Day of month matches');
next = interval.next();
t.ok(next, 'Found next scheduled interval');
t.equal(next.getDay(), 3, 'Day matches');
t.equal(next.getMonth(), 7, 'Month matches');
t.equal(next.getDate(), 12, 'Day of month matches');
// next = interval.next();
t.ok(next, 'Found next scheduled interval');
t.equal(next.getDay(), 3, 'Day matches');
t.equal(next.getMonth(), 7, 'Month matches');
t.equal(next.getDate(), 12, 'Day of month matches');
t.end();
});
});

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