cron-allowed-range
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"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
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
22639
217
47
1
4
+ Addednyc@^14.1.1
+ Added@babel/code-frame@7.26.2(transitive)
+ Added@babel/generator@7.26.3(transitive)
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/parser@7.26.3(transitive)
+ Added@babel/template@7.25.9(transitive)
+ Added@babel/traverse@7.26.4(transitive)
+ Added@babel/types@7.26.3(transitive)
+ Added@jridgewell/gen-mapping@0.3.8(transitive)
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/set-array@1.2.1(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@jridgewell/trace-mapping@0.3.25(transitive)
+ Addedansi-regex@4.1.1(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedappend-transform@1.0.0(transitive)
+ Addedarchy@1.0.0(transitive)
+ Addedargparse@1.0.10(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedcaching-transform@3.0.2(transitive)
+ Addedcamelcase@5.3.1(transitive)
+ Addedcliui@5.0.0(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedcommondir@1.0.1(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedconvert-source-map@1.9.0(transitive)
+ Addedcp-file@6.2.0(transitive)
+ Addedcross-spawn@4.0.2(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addeddefault-require-extensions@2.0.0(transitive)
+ Addedemoji-regex@7.0.3(transitive)
+ Addederror-ex@1.3.2(transitive)
+ Addedes6-error@4.1.1(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedfind-cache-dir@2.1.0(transitive)
+ Addedfind-up@3.0.0(transitive)
+ Addedforeground-child@1.5.6(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedglobals@11.12.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedhasha@3.0.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhosted-git-info@2.8.9(transitive)
+ Addedhtml-escaper@2.0.2(transitive)
+ Addedimurmurhash@0.1.4(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-arrayish@0.2.1(transitive)
+ Addedis-core-module@2.16.1(transitive)
+ Addedis-fullwidth-code-point@2.0.0(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedistanbul-lib-coverage@2.0.5(transitive)
+ Addedistanbul-lib-hook@2.0.7(transitive)
+ Addedistanbul-lib-instrument@3.3.0(transitive)
+ Addedistanbul-lib-report@2.0.8(transitive)
+ Addedistanbul-lib-source-maps@3.0.6(transitive)
+ Addedistanbul-reports@2.2.7(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedjsesc@3.1.0(transitive)
+ Addedjson-parse-better-errors@1.0.2(transitive)
+ Addedload-json-file@4.0.0(transitive)
+ Addedlocate-path@3.0.0(transitive)
+ Addedlodash.flattendeep@4.4.0(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addedmake-dir@2.1.0(transitive)
+ Addedmerge-source-map@1.1.0(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedms@2.1.3(transitive)
+ Addednested-error-stacks@2.1.1(transitive)
+ Addednormalize-package-data@2.5.0(transitive)
+ Addednyc@14.1.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedos-homedir@1.0.2(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@3.0.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedpackage-hash@3.0.0(transitive)
+ Addedparse-json@4.0.0(transitive)
+ Addedpath-exists@3.0.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedpath-type@3.0.0(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpify@3.0.04.0.1(transitive)
+ Addedpkg-dir@3.0.0(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedread-pkg@3.0.0(transitive)
+ Addedread-pkg-up@4.0.0(transitive)
+ Addedrelease-zalgo@1.0.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedrequire-main-filename@2.0.0(transitive)
+ Addedresolve@1.22.10(transitive)
+ Addedresolve-from@4.0.0(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsemver@5.7.26.3.1(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedspawn-wrap@1.4.3(transitive)
+ Addedspdx-correct@3.2.0(transitive)
+ Addedspdx-exceptions@2.5.0(transitive)
+ Addedspdx-expression-parse@3.0.1(transitive)
+ Addedspdx-license-ids@3.0.20(transitive)
+ Addedsprintf-js@1.0.3(transitive)
+ Addedstring-width@3.1.0(transitive)
+ Addedstrip-ansi@5.2.0(transitive)
+ Addedstrip-bom@3.0.0(transitive)
+ Addedsupports-color@6.1.0(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedtest-exclude@5.2.3(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedvalidate-npm-package-license@3.0.4(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedwhich-module@2.0.1(transitive)
+ Addedwrap-ansi@5.1.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedwrite-file-atomic@2.4.3(transitive)
+ Addedy18n@4.0.3(transitive)
+ Addedyallist@2.1.2(transitive)
+ Addedyargs@13.3.2(transitive)
+ Addedyargs-parser@13.1.2(transitive)