@mschaeffler/node-red-logic 3.6.0 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84,7 +84,7 @@ module.exports = function(RED) {
84
84
  getPayload( function(value)
85
85
  {
86
86
  msg.value = Number( value );
87
- let status = { fill:data[msg.topic]?.status??"gray", shape:"dot", text:msg.value.toPrecision(4) };
87
+ let status = { fill:data[msg.topic]?.status??"gray", shape:"dot", text:tools.formatNumber( msg.value ) };
88
88
 
89
89
  if( ! isNaN( msg.value ) )
90
90
  {
package/math_mean.js CHANGED
@@ -93,7 +93,7 @@ module.exports = function(RED) {
93
93
  msg.count = count;
94
94
  last[msg.topic] = {value:value,time:now};
95
95
  context.set( "last", last );
96
- node.status({fill:"green",shape:"dot",text:`${item.length} / ${value.toPrecision(4)}`});
96
+ node.status({fill:"green",shape:"dot",text:`${item.length} / ${tools.formatNumber(value)}`});
97
97
  send( msg );
98
98
  }
99
99
 
@@ -118,7 +118,7 @@ module.exports = function(RED) {
118
118
  }
119
119
  else
120
120
  {
121
- node.status({fill:"gray",shape:"dot",text:`${item.length} / ${value.toPrecision(4)}`});
121
+ node.status({fill:"gray",shape:"dot",text:`${item.length} / ${tools.formatNumber(value)}`});
122
122
  }
123
123
  }
124
124
  else
package/math_reduce.js CHANGED
@@ -1,4 +1,5 @@
1
1
  module.exports = function(RED) {
2
+ var tools = require('./tools.js');
2
3
 
3
4
  function ReduceNode(config) {
4
5
  RED.nodes.createNode(this,config);
@@ -112,7 +113,7 @@ module.exports = function(RED) {
112
113
  {
113
114
  case "mean": msg.payload /= msg.count; break;
114
115
  }
115
- status.text = msg.payload.toPrecision(4);
116
+ status.text = tools.formatNumber( msg.payload );
116
117
  if( node.filter )
117
118
  {
118
119
  if( msg.payload !== node.last )
@@ -1,4 +1,5 @@
1
1
  module.exports = function(RED) {
2
+ var tools = require('./tools.js');
2
3
 
3
4
  function StatsNode(config) {
4
5
  RED.nodes.createNode(this,config);
@@ -103,7 +104,7 @@ module.exports = function(RED) {
103
104
  msg.stat.variation = msg.stat.deviation / msg.stat.average;
104
105
  if( node.showState )
105
106
  {
106
- node.status({fill:"green",shape:"dot",text:`${msg.stat.count} / ${msg.stat.deviation.toPrecision(4)}`});
107
+ node.status({fill:"green",shape:"dot",text:`${msg.stat.count} / ${tools.formatNumber(msg.stat.deviation)}`});
107
108
  }
108
109
  send( msg );
109
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mschaeffler/node-red-logic",
3
- "version": "3.6.0",
3
+ "version": "3.6.1",
4
4
  "description": "nodes for simple operations.",
5
5
  "license": "LGPL-2.1",
6
6
  "homepage": "https://github.com/m-schaeffler/node-red-my-nodes/tree/main/node-red-logic",
package/tools.js CHANGED
@@ -77,3 +77,8 @@ exports.distance = function(a,b)
77
77
  {
78
78
  return a>b ? a-b : b-a;
79
79
  }
80
+
81
+ exports.formatNumber = function(value)
82
+ {
83
+ return value > 5000 ? value.toFixed( 0 ) : value.toPrecision( 4 );
84
+ }