Skip to content

Commit

Permalink
providers.js formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstas committed Nov 24, 2024
1 parent 46bb53e commit f243f29
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/interfaces/providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,15 @@ module.exports = function (app) {

if (provider.options.type === 'canbus-canboatjs') {
if (isNumber(provider.options.uniqueNumber)) {
provider.options.uniqueNumber = parseInt(provider.options.uniqueNumber);
}
else {
provider.options.uniqueNumber = Math.floor(Math.random() * 2097151);
provider.options.uniqueNumber = parseInt(provider.options.uniqueNumber)
} else {
provider.options.uniqueNumber = Math.floor(Math.random() * 2097151)
}

if (isNumber(provider.options.mfgCode)) {
provider.options.mfgCode = parseInt(provider.options.mfgCode);
}
else {
if (provider.options.mfgCode !== '')
delete provider.options.mfgCode; //if value is not empty or not a number then removing property
provider.options.mfgCode = parseInt(provider.options.mfgCode)
} else {
if (provider.options.mfgCode !== '') delete provider.options.mfgCode //if value is not empty or not a number then removing property
}
}

Expand All @@ -179,10 +176,15 @@ module.exports = function (app) {
}

function isNumber(s) {
return typeof s == 'number' ? true
: typeof s == 'string' ? (s.trim() === '' ? false : !isNaN(s))
: (typeof s).match(/object|function/) ? false
: !isNaN(s)
return typeof s == 'number'
? true
: typeof s == 'string'
? s.trim() === ''
? false
: !isNaN(s)
: (typeof s).match(/object|function/)
? false
: !isNaN(s)
}

function applyProviderSettings(target, source, res) {
Expand Down

0 comments on commit f243f29

Please sign in to comment.