Skip to content

Commit

Permalink
Move conditions to the top
Browse files Browse the repository at this point in the history
  • Loading branch information
lstrojny committed Nov 24, 2022
1 parent f30dfe0 commit 8a00614
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ function extractMetrics(service: Service, timestamp: Date, labels: Record<string
const metrics: Metric[] = []

for (const characteristic of service.characteristics) {
if (METRICS_FILTER.includes(characteristic.description)) {
continue
}

if (characteristic.value == null) {
continue
}

const format = characteristic.format
switch (format) {
case 'string':
Expand All @@ -53,10 +61,7 @@ function extractMetrics(service: Service, timestamp: Date, labels: Record<string
case 'uint16':
case 'uint32':
case 'uint64':
if (characteristic.value != null) {
if (METRICS_FILTER.includes(characteristic.description)) {
break
}
{
const name = formatName(
Uuids[service.type] || 'custom',
characteristic.description,
Expand Down

0 comments on commit 8a00614

Please sign in to comment.