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 3.1.0 to 3.2.0

test/fields.js

34

lib/expression.js

@@ -52,6 +52,6 @@ 'use strict';

this._endDate = options.endDate ? new CronDate(options.endDate, this._tz) : null;
this._fields = fields;
this._isIterator = options.iterator || false;
this._hasIterated = false;
this._nthDayOfWeek = options.nthDayOfWeek || 0;
this.fields = Object.freeze(fields);
}

@@ -387,3 +387,3 @@

// Starting DST
if (this._fields.hour.length !== 24) {
if (this.fields.hour.length !== 24) {
// Hour is specified

@@ -396,3 +396,3 @@ this._dstStart = currentHour;

// Ending DST
if (this._fields.hour.length !== 24) {
if (this.fields.hour.length !== 24) {
// Hour is specified

@@ -462,4 +462,4 @@ this._dstEnd = currentHour;

* Helper function that checks if 'L' is in the array
*
* @param {Array} dayOfMonth
*
* @param {Array} dayOfMonth
*/

@@ -507,10 +507,10 @@ function isLInDayOfMonth(dayOfMonth) {

var dayOfMonthMatch = matchSchedule(currentDate.getDate(), this._fields.dayOfMonth);
if (isLInDayOfMonth(this._fields.dayOfMonth)) {
var dayOfMonthMatch = matchSchedule(currentDate.getDate(), this.fields.dayOfMonth);
if (isLInDayOfMonth(this.fields.dayOfMonth)) {
dayOfMonthMatch = dayOfMonthMatch || currentDate.isLastDayOfMonth();
}
var dayOfWeekMatch = matchSchedule(currentDate.getDay(), this._fields.dayOfWeek);
var dayOfWeekMatch = matchSchedule(currentDate.getDay(), this.fields.dayOfWeek);
var isDayOfMonthWildcardMatch = isWildcardRange(this._fields.dayOfMonth, CronExpression.constraints[3]);
var isDayOfWeekWildcardMatch = isWildcardRange(this._fields.dayOfWeek, CronExpression.constraints[5]);
var isDayOfMonthWildcardMatch = isWildcardRange(this.fields.dayOfMonth, CronExpression.constraints[3]);
var isDayOfWeekWildcardMatch = isWildcardRange(this.fields.dayOfWeek, CronExpression.constraints[5]);

@@ -554,3 +554,3 @@ var currentHour = currentDate.getHours();

// Match month
if (!matchSchedule(currentDate.getMonth() + 1, this._fields.month)) {
if (!matchSchedule(currentDate.getMonth() + 1, this.fields.month)) {
this._applyTimezoneShift(currentDate, dateMathVerb, 'Month');

@@ -561,3 +561,3 @@ continue;

// Match hour
if (!matchSchedule(currentHour, this._fields.hour)) {
if (!matchSchedule(currentHour, this.fields.hour)) {
if (this._dstStart !== currentHour) {

@@ -567,3 +567,3 @@ this._dstStart = null;

continue;
} else if (!matchSchedule(currentHour - 1, this._fields.hour)) {
} else if (!matchSchedule(currentHour - 1, this.fields.hour)) {
currentDate[dateMathVerb + 'Hour']();

@@ -581,3 +581,3 @@ continue;

// Match minute
if (!matchSchedule(currentDate.getMinutes(), this._fields.minute)) {
if (!matchSchedule(currentDate.getMinutes(), this.fields.minute)) {
this._applyTimezoneShift(currentDate, dateMathVerb, 'Minute');

@@ -588,3 +588,3 @@ continue;

// Match second
if (!matchSchedule(currentDate.getSeconds(), this._fields.second)) {
if (!matchSchedule(currentDate.getSeconds(), this.fields.second)) {
this._applyTimezoneShift(currentDate, dateMathVerb, 'Second');

@@ -817,3 +817,3 @@ continue;

var key = CronExpression.map[i];
mappedFields[key] = fields[i];
mappedFields[key] = Object.freeze(fields[i]);
}

@@ -847,3 +847,3 @@

});
}

@@ -850,0 +850,0 @@

@@ -61,5 +61,13 @@ export = CronParser

type CronFieldsKeys = 'second' | 'minute' | 'hour' | 'dayOfMonth' | 'month' | 'dayOfWeek'
declare type CronFields = {
readonly [k in CronFieldsKeys]: readonly number[];
}
declare class CronExpression {
constructor(fields: {}, options: {})
public readonly fields: CronFields
constructor(fields: CronFields, options: {})
/** Find next suitable date */

@@ -66,0 +74,0 @@ next(): CronDate

{
"name": "cron-parser",
"version": "3.1.0",
"version": "3.2.0",
"description": "Node.js library for parsing crontab instructions",

@@ -11,6 +11,7 @@ "main": "lib/parser.js",

"scripts": {
"test:tsd": "tsd",
"test:unit": "TZ=UTC tap ./test/*.js",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"test": "npm run lint && npm run test:unit"
"test": "npm run lint && npm run test:unit && npm run test:tsd"
},

@@ -56,3 +57,4 @@ "repository": {

"sinon": "^9.2.1",
"tap": "^14.10.8"
"tap": "^14.10.8",
"tsd": "^0.14.0"
},

@@ -64,3 +66,6 @@ "engines": {

"fs": false
},
"tsd": {
"directory": "test"
}
}
cron-parser
================
[![Build Status](https://travis-ci.org/harrisiirak/cron-parser.svg?branch=master)](https://travis-ci.org/harrisiirak/cron-parser)
[![Build Status](https://travis-ci.com/harrisiirak/cron-parser.svg?branch=master)](https://travis-ci.com/harrisiirak/cron-parser)
[![NPM version](https://badge.fury.io/js/cron-parser.png)](http://badge.fury.io/js/cron-parser)

@@ -6,0 +6,0 @@

@@ -970,3 +970,6 @@ var test = require('tap').test;

try {
var interval = CronExpression.parse('* * * * 2 *');
var options = {
currentDate: new CronDate('2020-05-01T15:00:00.000')
};
var interval = CronExpression.parse('* * * * 2 *', options);
t.ok(interval, 'Interval parsed');

@@ -973,0 +976,0 @@

@@ -16,5 +16,6 @@ var luxon = require('luxon');

test('undefined date', (t) => {
const realDate = new Date();
var d = new CronDate();
t.equal(d.toDate().toString(), new Date().toString());
t.equal(d.toDate().toString(), realDate.toString());

@@ -21,0 +22,0 @@ 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