Move conditions to the top

This commit is contained in:
Lars Strojny 2022-11-24 20:21:10 +01:00
parent f30dfe0cee
commit 8a0061428d
No known key found for this signature in database
GPG key ID: 887416A2AD3B0CA9

View file

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