Skip to content

Commit f083a22

Browse files
committed
refactor: using indexOf instead of a loop
1 parent 736e982 commit f083a22

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

lib/portfinder.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,9 @@ exports.getPort = function (options, callback) {
126126
}
127127

128128
if (options.host) {
129-
130-
var hasUserGivenHost;
131-
for (var i = 0; i < exports._defaultHosts.length; i++) {
132-
if (exports._defaultHosts[i] === options.host) {
133-
hasUserGivenHost = true;
134-
break;
135-
}
129+
if (exports._defaultHosts.indexOf(options.host) !== -1) {
130+
exports._defaultHosts.push(options.host)
136131
}
137-
138-
if (!hasUserGivenHost) {
139-
exports._defaultHosts.push(options.host);
140-
}
141-
142132
}
143133

144134
var openPorts = [], currentHost;

0 commit comments

Comments
 (0)