mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fix Delay node milliseconds label to read ms.
(and add use strict)
This commit is contained in:
parent
dcc0adf2f7
commit
b67e70e09f
@ -101,6 +101,7 @@
|
|||||||
label: function() { // sets the default label contents
|
label: function() { // sets the default label contents
|
||||||
if (this.pauseType == "delay") {
|
if (this.pauseType == "delay") {
|
||||||
var units = this.timeoutUnits ? this.timeoutUnits.charAt(0) : "s";
|
var units = this.timeoutUnits ? this.timeoutUnits.charAt(0) : "s";
|
||||||
|
if (this.timeoutUnits == "milliseconds") { units = "ms"; }
|
||||||
return this.name||"delay "+this.timeout+" " + units;
|
return this.name||"delay "+this.timeout+" " + units;
|
||||||
} else if (this.pauseType == "rate") {
|
} else if (this.pauseType == "rate") {
|
||||||
var units = this.rateUnits ? this.rateUnits.charAt(0) : "s";
|
var units = this.rateUnits ? this.rateUnits.charAt(0) : "s";
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
//Simple node to introduce a pause into a flow
|
//Simple node to introduce a pause into a flow
|
||||||
module.exports = function(RED) {
|
module.exports = function(RED) {
|
||||||
|
"use strict";
|
||||||
function random(n) {
|
function random(n) {
|
||||||
var wait = n.randomFirst + (n.diff * Math.random());
|
var wait = n.randomFirst + (n.diff * Math.random());
|
||||||
if (n.buffer.length > 0) {
|
if (n.buffer.length > 0) {
|
||||||
@ -105,6 +106,9 @@ module.exports = function(RED) {
|
|||||||
if (!node.drop) {
|
if (!node.drop) {
|
||||||
if ( node.intervalID !== -1) {
|
if ( node.intervalID !== -1) {
|
||||||
node.buffer.push(msg);
|
node.buffer.push(msg);
|
||||||
|
if (node.buffer.length > 0) {
|
||||||
|
node.status({text:node.buffer.length});
|
||||||
|
}
|
||||||
if (node.buffer.length > 1000) {
|
if (node.buffer.length > 1000) {
|
||||||
node.warn(this.name + " buffer exceeded 1000 messages");
|
node.warn(this.name + " buffer exceeded 1000 messages");
|
||||||
}
|
}
|
||||||
@ -114,10 +118,12 @@ module.exports = function(RED) {
|
|||||||
if (node.buffer.length === 0) {
|
if (node.buffer.length === 0) {
|
||||||
clearInterval(node.intervalID);
|
clearInterval(node.intervalID);
|
||||||
node.intervalID = -1;
|
node.intervalID = -1;
|
||||||
|
node.status({text:""});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.buffer.length > 0) {
|
if (node.buffer.length > 0) {
|
||||||
node.send(node.buffer.shift());
|
node.send(node.buffer.shift());
|
||||||
|
node.status({text:node.buffer.length});
|
||||||
}
|
}
|
||||||
},node.rate);
|
},node.rate);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user