Skip to content

Commit

Permalink
chore: prefer .find(fn) over .filter(fn)[0] (#444)
Browse files Browse the repository at this point in the history
This is slightly clearer and slightly more efficient.
  • Loading branch information
EvanHahn authored Jan 23, 2024
1 parent d8f4039 commit 8827026
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/discovery/dns-sd.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class DnsSd extends TypedEmitter {
this.#log(`Ignoring service up from self`)
return
}
const address = service.addresses?.filter(isIPv4)[0]
const address = service.addresses?.find(isIPv4)
/* c8 ignore start */
if (!address) {
this.#log(`service up (${service.name}) with no ipv4 addresses`)
Expand All @@ -57,7 +57,7 @@ export class DnsSd extends TypedEmitter {
this.#log(`Ignoring service down from self`)
return
}
const address = service.addresses?.filter(isIPv4)[0]
const address = service.addresses?.find(isIPv4)
/* c8 ignore start */
if (!address) {
this.#log(`service down (${service.name}) with no ipv4 addresses`)
Expand Down

0 comments on commit 8827026

Please sign in to comment.