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

node-red-contrib-stoptimer

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.0.4 to 0.0.5

4

package.json
{
"name": "node-red-contrib-stoptimer",
"version": "0.0.4",
"description": "Sends the msg through after the set timer duration. If a new msg is received before the timer has ended, the timer will be restarted, unless the new msg has a payload of stop or STOP, in which case it will stop the timer.",
"version": "0.0.5",
"description": "Sends the msg through the first output after the set timer duration. If a new msg is received before the timer has ended, the timer will be restarted, unless the new msg has a payload of 'stop' or 'STOP', in which case it will stop the timer. The second output allows you to send an additional payload of a number, string or boolean. If the timer is stopped, the second output will automatically send a payload of 'stopped'.",
"main": "stoptimer.js",

@@ -6,0 +6,0 @@ "scripts": {},

Stop Timer for node-red
----------------------------
Sends the `msg` through after the set timer duration. If a new `msg` is received before the timer has ended, the timer will be restarted, unless the new `msg` has a payload of `stop` or `STOP`, in which case it will stop the timer.
Sends the `msg` through the first output after the set timer duration. If a new `msg` is received before the timer has ended, the timer will be restarted, unless the new `msg` has a payload of `stop` or `STOP`, in which case it will stop the timer. The second output allows you to send an additional payload of a number, string or boolean. If the timer is stopped, the second output will automatically send a payload of `stopped`.

@@ -15,1 +15,3 @@ This is like the built in delay function of node-red, but with the ability to not only restart the timer, but to stop it as well.

0.0.4 - Updated icon for less confusion with other nodes
0.0.5 - As per request, I have included a second output. You can set the payload for the second output to a number, string or boolean, however, if the timer is stopped with an incoming msg, the second output will send the payload of "stopped".

@@ -24,2 +24,4 @@ /**

this.duration = n.duration || 5;
this.payloadval = n.payloadval || "0";
this.payloadtype = n.payloadtype || "num";

@@ -33,2 +35,16 @@ if (this.duration <= 0) { this.duration = 0; }

if ((this.payloadtype === "num") && (!isNaN(this.payloadval))) {
this.payloadval = Number(this.payloadval);
}
else if (this.payloadval === 'true' || this.payloadval === 'false') {
this.payloadval = Boolean(this.payloadval);
}
else if (this.payloadval == "null") {
this.payloadtype = 'null';
this.payloadval = null;
}
else {
this.payloadval = String(this.payloadval);
}
var node = this;

@@ -42,6 +58,9 @@ var timeout = null;

clearTimeout(timeout);
timeout = null;
timeout = null;
if (msg.payload == "stop" || msg.payload == "STOP") {
node.status({fill:"red",shape:"ring",text:"stopped"});
stopped = true;
var msg2 = RED.util.cloneMessage(msg);
msg2.payload = "stopped";
node.send([null, msg2]);
}else{

@@ -53,3 +72,5 @@ msg._timerpass = true;

if(stopped === false) {
node.send(msg);
var msg2 = RED.util.cloneMessage(msg);
msg2.payload = node.payloadval;
node.send([msg, msg2]);
}

@@ -56,0 +77,0 @@ timeout = null;

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