Skip to content

Commit

Permalink
refactor: optimise object creation & remove spread (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkurki authored May 28, 2024
1 parent 5ac7ec8 commit aa5ff47
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/stringMsg.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ 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 = {}) {
return {
...canIdInfo,
function buildMsg(_canIdInfo, format, data, rest = {}) {
const canIdInfo = Object.assign({}, _canIdInfo, {
format,
data,
...rest,
data
})
for (const property in rest) {
if (canIdInfo[property] === undefined) {
canIdInfo[property] = rest[property]
}
}
return canIdInfo
}
function buildErrMsg(msg, input) {
if (input && isString(input)) return `${msg} - ${input}`
Expand Down

0 comments on commit aa5ff47

Please sign in to comment.