Skip to content

Commit

Permalink
refactor: optimise object creation & spread
Browse files Browse the repository at this point in the history
  • Loading branch information
tkurki committed Apr 18, 2024
1 parent e9b666b commit 97c912d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/stringMsg.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ const {
* @return {Object} All canId fields with format and data props added.
*/
function buildMsg(canIdInfo, format, data, rest = {}) {
return {
...canIdInfo,
format,
data,
...rest,
canIdInfo.format = canIdInfo.format ? canIdInfo.format : format
canIdInfo.data = canIdInfo.data ? canIdInfo.data : 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 97c912d

Please sign in to comment.