smart-nodes 0.3.34 → 0.3.35

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.
package/delay/delay.js CHANGED
@@ -1,3 +1,5 @@
1
+ const smart_helper = require("../smart_helper.js");
2
+
1
3
  module.exports = function (RED)
2
4
  {
3
5
  "use strict";
@@ -140,7 +142,7 @@ module.exports = function (RED)
140
142
  if (delay_ms <= 0)
141
143
  {
142
144
  node.status({ fill: "yellow", shape: "dot", text: helper.getCurrentTimeForStatus() + ": " + "Sended " + getMessageStatusText(msg) });
143
- node_settings.last_message = msg
145
+ node_settings.last_message = helper.cloneObject(msg);
144
146
 
145
147
  if (config.save_state)
146
148
  smart_context.set(node.id, node_settings);
@@ -155,7 +157,7 @@ module.exports = function (RED)
155
157
  {
156
158
  timeout = null;
157
159
  node.status({ fill: "yellow", shape: "dot", text: helper.getCurrentTimeForStatus() + ": " + "Sended " + getMessageStatusText(msg) });
158
- node_settings.last_message = msg
160
+ node_settings.last_message = helper.cloneObject(msg);
159
161
 
160
162
  if (config.save_state)
161
163
  smart_context.set(node.id, node_settings);
@@ -77,7 +77,7 @@ module.exports = function (RED)
77
77
  node_settings.last_msg_was_sended = false;
78
78
  }
79
79
 
80
- node_settings.last_message = msg;
80
+ node_settings.last_message = helper.cloneObject(msg);;
81
81
  break;
82
82
  }
83
83
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-nodes",
3
- "version": "0.3.34",
3
+ "version": "0.3.35",
4
4
  "description": "Smart Nodes",
5
5
  "keywords": [
6
6
  "node-red",
package/smart_helper.js CHANGED
@@ -295,5 +295,15 @@ module.exports = {
295
295
  return date.getHours().toString().padStart(2, "0") + ":" +
296
296
  date.getMinutes().toString().padStart(2, "0") + ":" +
297
297
  date.getSeconds().toString().padStart(2, "0");
298
+ },
299
+
300
+ /**
301
+ * Creates a new independend object and copies all properties to the new one
302
+ * @param {*} obj The Object to copy
303
+ * @returns A new Object
304
+ */
305
+ cloneObject(obj)
306
+ {
307
+ return Object.assign({}, obj);
298
308
  }
299
309
  };