New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-red-contrib-suncron

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-suncron - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

package.json
{
"name": "node-red-contrib-suncron",
"version": "1.0.2",
"version": "1.0.3",
"description": "A Node-RED node that triggers configurable outgoing messages based on the position of the sun",

@@ -5,0 +5,0 @@ "main": "index.js",

# SunCron
A Node-RED node that can output configurable messages at significant sun events (e.g. sunrise, sunset etc.)
A Node-RED node that can output configurable messages at significant sun events

@@ -18,3 +18,3 @@ ## Supported Sun Events

- Nadir
- NightEnd
- Night End
- Nautical Dawn

@@ -21,0 +21,0 @@ - Dawn

@@ -102,3 +102,9 @@ const CronJob = require('cron').CronJob

ejectMsg(event, schedule)
setNodeStatus(`${event.event} at ${event.cronTime.format('HH:mm')}`)
setNodeStatus(
`now: ${event.event} @ ${event.cronTime.format('HH:mm')}`,
'green'
)
setTimeout(() => {
setNodeStatusToNextEvent(schedule)
}, 2000)
}

@@ -117,2 +123,5 @@ })

setNodeStatus(`${i} crons active`)
setTimeout(() => {
setNodeStatusToNextEvent(schedule)
}, 2000)
}

@@ -129,4 +138,5 @@

onTick: () => {
installMsgCronjobs(calcScheduleForToday())
setNodeStatus(`updated for ${dayjs().format('ddd, MMM D')}`)
const schedule = calcScheduleForToday()
installMsgCronjobs(schedule)
setNodeStatusToNextEvent(schedule)
}

@@ -152,2 +162,31 @@ })

const setNodeStatusToNextEvent = function (schedule) {
function findNextEvent (schedule) {
let futureEvents = Object.keys(schedule)
.map(eventType => ({
eventName: eventType,
eventTime: schedule[eventType].cronTime
}))
.sort((e1, e2) => e1.eventTime.unix() - e2.eventTime.unix())
.filter(event => event.eventTime.isAfter(dayjs()))
if (futureEvents.length > 0) {
return futureEvents.shift()
} else {
throw new Error('done for today')
}
}
try {
const nextEvent = findNextEvent(schedule)
setNodeStatus(
`next: ${nextEvent.eventName} @ ${nextEvent.eventTime.format(
'HH:mm'
)}`
)
} catch (err) {
setNodeStatus(err.message)
}
}
const stopMsgCrons = function () {

@@ -192,6 +231,5 @@ if (msgCrons.length > 0) {

const schedule = calcScheduleForToday()
installMsgCronjobs(schedule)
debug(schedule)
installMsgCronjobs(schedule)
dailyCron = installDailyCronjob()

@@ -198,0 +236,0 @@ })()

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