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

cron-allowed-range

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cron-allowed-range - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

9

package.json
{
"name": "cron-allowed-range",
"version": "0.0.3",
"version": "0.0.4",
"description": "Use cron-like expressions to test if a datetime is in an allowed range.",

@@ -8,3 +8,4 @@ "main": "src/index.js",

"deploy": "publish",
"test": "mocha test/**/*.js"
"test": "nyc --reporter=html --reporter=text mocha test/**/*.js",
"test:coverage": "nyc report --reporter=text-lcov | coveralls"
},

@@ -27,5 +28,9 @@ "repository": {

"chai": "^4.2.0",
"coveralls": "^3.0.7",
"mocha": "^6.2.1",
"publish-me-maybe": "^1.0.1"
},
"dependencies": {
"nyc": "^14.1.1"
}
}
[![CircleCI](https://circleci.com/gh/neverendingqs/cron-allowed-range.svg?style=svg)](https://circleci.com/gh/neverendingqs/cron-allowed-range)
[![npm version](https://badge.fury.io/js/cron-allowed-range.svg)](https://badge.fury.io/js/cron-allowed-range)
[![Coverage
Status](https://coveralls.io/repos/github/neverendingqs/cron-allowed-range/badge.svg?branch=master)](https://coveralls.io/github/neverendingqs/cron-allowed-range?branch=master)
[![npm
version](https://badge.fury.io/js/cron-allowed-range.svg)](https://badge.fury.io/js/cron-allowed-range)

@@ -4,0 +7,0 @@ # cron-allowed-range

@@ -41,3 +41,3 @@ function parsePart(part) {

return ranges.some(({ start, end }) =>
start < end
start <= end
? value >= start && value <= end

@@ -44,0 +44,0 @@ : value <= start || value >= end

@@ -94,12 +94,23 @@ const assert = require('chai').assert;

describe('isDateAllowed()', function() {
/* Allowed if it is:
* - At any minute
* - Between 9 AM - 5 PM
* - On any day of the month
* - Between September to June or on August
* - Between Monday to Friday
*/
// TODO: add more test coverage for minutes and day of month
const cr = new CronAllowedRange('* 9-17 * 9-6,8 1-5');
describe('minutes', function() {
const cr = new CronAllowedRange('11-20,25 * * * *');
[11, 15, 20, 25].forEach(minutes => {
it(`returns true when within range (${minutes})`, function() {
const date = new Date(`December 18, 1995 08:${minutes}:59 GMT-0000`);
assert.isTrue(
cr.isDateAllowed(date)
);
});
});
[10, 21, 24, 26].forEach(minutes => {
it(`returns false when not within range (${minutes})`, function() {
const date = new Date(`December 18, 1995 08:${minutes}:59 GMT-0000`);
assert.isFalse(
cr.isDateAllowed(date)
);
});
});
});
[

@@ -132,2 +143,11 @@ {

it(`returns false because ${reason}`, function() {
/* Allowed if it is:
* - At any minute
* - Between 9 AM - 5 PM
* - On any day of the month
* - Between September to June or on August
* - Between Monday to Friday
*/
const cr = new CronAllowedRange('* 9-17 * 9-6,8 1-5');
const actual = cr.isDateAllowed(date);

@@ -143,2 +163,10 @@ assert.isFalse(actual);

it(`returns true for ${date}`, function() {
/* Allowed if it is:
* - At any minute
* - Between 9 AM - 5 PM
* - On any day of the month
* - Between September to June or on August
* - Between Monday to Friday
*/
const cr = new CronAllowedRange('* 9-17 * 9-6,8 1-5');
const actual = cr.isDateAllowed(date);

@@ -145,0 +173,0 @@ assert.isTrue(actual);

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