node-red-contrib-trashschedule
Advanced tools
Comparing version 1.0.4 to 1.1.5
@@ -0,0 +0,0 @@ --- |
{ | ||
"name": "node-red-contrib-trashschedule", | ||
"version": "1.0.4", | ||
"version": "1.1.5", | ||
"deprecated": false, | ||
@@ -12,3 +12,3 @@ "description": "NodeRED Node to manage trash schedule events", | ||
"scripts": { | ||
"test": "" | ||
"test": "jest" | ||
}, | ||
@@ -30,3 +30,4 @@ "keywords": [ | ||
"eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-plugin-import": "^2.22.1" | ||
"eslint-plugin-import": "^2.22.1", | ||
"jest": "^26.6.3" | ||
}, | ||
@@ -33,0 +34,0 @@ "repository": { |
@@ -0,0 +0,0 @@ ![banner](img/trashschedule_banner.svg) |
/* eslint-disable no-shadow */ | ||
/* eslint-disable prefer-destructuring */ | ||
// eslint-disable-next-line func-names | ||
const validateEvent = require('./src/validateEvent'); | ||
const sortTrashschedule = require('./src/sortTrashschedule'); | ||
// eslint-disable-next-line func-names | ||
module.exports = function (RED) { | ||
@@ -9,5 +14,3 @@ function trashschedule(config) { | ||
let trashschedule = []; | ||
trashschedule = config.trashschedule; | ||
let trashschedule = config.trashschedule; | ||
const skipHour = config.skipHour; | ||
@@ -31,33 +34,2 @@ | ||
// sort trashschedule array by yyyy, mm, dd | ||
function sortTrashschedule() { | ||
trashschedule.sort((a, b) => { | ||
if (new Date(a.year, a.month, a.day) > new Date(b.year, b.month, b.day)) { | ||
return 1; | ||
} | ||
if (new Date(a.year, a.month, a.day) < new Date(b.year, b.month, b.day)) { | ||
return -1; | ||
} | ||
return 0; | ||
}); | ||
} | ||
function validateEvent(trashscheduleElement) { | ||
if (trashscheduleElement == null) { | ||
return false; | ||
} | ||
if (new Date( | ||
trashscheduleElement.year, | ||
trashscheduleElement.month, | ||
trashscheduleElement.day, | ||
).valueOf() - new Date( | ||
currentYear, | ||
currentMonth, | ||
currentDay, | ||
).valueOf() < 0) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
// calculate daysLeft | ||
@@ -79,3 +51,4 @@ function calcDaysLeft(trashscheduleElement) { | ||
function sendNextThreeTrashEvents() { | ||
sortTrashschedule(); | ||
// sort trashschedule array by yyyy, mm, dd | ||
trashschedule = sortTrashschedule(trashschedule); | ||
@@ -215,3 +188,4 @@ // outputArr bundles the 3 events | ||
function checkTrashschedule() { | ||
sortTrashschedule(); | ||
// sort trashschedule array by yyyy, mm, dd | ||
trashschedule = sortTrashschedule(trashschedule); | ||
@@ -294,2 +268,6 @@ // check wether trashschedule array contains trashschedule events | ||
break; | ||
case '123': | ||
trashschedule = sortTrashschedule(trashschedule); | ||
node.send({ payload: trashschedule }); | ||
break; | ||
default: | ||
@@ -296,0 +274,0 @@ checkTrashschedule(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
112129
15
290
0
4