Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion lib/ip.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,25 @@ ip.address = function(name, family) {
return res[0].address;
}

var all = Object.keys(interfaces).map(function (nic) {
function priority (name) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should remove space before (name for consistency with the rest of the codebase

if (name.startsWith('en') || name.startsWith('eth')) {
return 0;
}
if (name.startsWith('wlan')) {
return 1;
}

return 2;
}

var sortedInterfaces = Object.keys(interfaces).sort(function(a, b) {
a = priority(a);
b = priority(b);

return a - b;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just return priority(a) - priority(b)?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brentvatne you're right :-) I did that to debug my code.

});

var all = sortedInterfaces.map(function (nic) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should remove space between function and (nic)

//
// Note: name will only be `public` or `private`
// when this is called.
Expand Down