Skip to content

Commit

Permalink
Simplify _recordsFor function
Browse files Browse the repository at this point in the history
It appears that it previously allowed the name and type to be optional.
Since this is no longer the case, we can remove a lot of the logic from
the function body now
  • Loading branch information
watson committed May 6, 2016
1 parent 13f7ff5 commit ccbb827
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions lib/mdns-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,12 @@ Server.prototype._respondToQuery = function (query) {
}

Server.prototype._recordsFor = function (name, type) {
var self = this

type = type ? [type] : Object.keys(this.registry)
if (!(type in this.registry)) return []

return flatten.depth(type.map(function (type) {
if (!(type in self.registry)) return []
if (name) {
return self.registry[type].filter(function (record) {
var _name = ~name.indexOf('.') ? record.name : record.name.split('.')[0]
return dnsEqual(_name, name)
})
} else {
return self.registry[type]
}
}), 1)
return this.registry[type].filter(function (record) {
var _name = ~name.indexOf('.') ? record.name : record.name.split('.')[0]
return dnsEqual(_name, name)
})
}

function isDuplicateRecord (a) {
Expand Down

0 comments on commit ccbb827

Please sign in to comment.