From fbb2c7e133930142c30305e419457550cba22a75 Mon Sep 17 00:00:00 2001 From: Teppo Kurki Date: Thu, 18 Apr 2024 18:31:32 +0300 Subject: [PATCH] second tweak to buildMsg --- lib/stringMsg.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/stringMsg.js b/lib/stringMsg.js index d914b90..80a5a5c 100644 --- a/lib/stringMsg.js +++ b/lib/stringMsg.js @@ -19,9 +19,11 @@ const { * @param {Object} [rest={}] Anything else to be added like len, timestamp, direction. * @return {Object} All canId fields with format and data props added. */ -function buildMsg(canIdInfo, format, data, rest = {}) { - canIdInfo.format = canIdInfo.format ? canIdInfo.format : format - canIdInfo.data = canIdInfo.data ? canIdInfo.data : data +function buildMsg(_canIdInfo, format, data, rest = {}) { + const canIdInfo = Object.assign({}, _canIdInfo, { + format, + data + }) for (const property in rest) { if (canIdInfo[property] === undefined) { canIdInfo[property] = rest[property]