can-bind-to-host
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,3 +0,3 @@ | ||
declare const canBindToHost: (host: string, port?: number) => Promise<unknown>; | ||
declare const canBindToHost: (host: string, port?: number) => Promise<boolean>; | ||
export default canBindToHost; | ||
export { canBindToHost }; |
@@ -10,9 +10,15 @@ "use strict"; | ||
if (port === void 0) { port = 0; } | ||
var server = null; | ||
return new Promise(function (res) { | ||
net_1.default.createServer(function (socket) { return socket.destroy(); }).listen({ | ||
server = net_1.default | ||
.createServer() | ||
.listen({ | ||
host: host, | ||
port: 0 | ||
port: 0, | ||
}) | ||
.addListener("error", function () { return res(false); }) | ||
.addListener("listening", function () { return res(true); }); | ||
.addListener('error', function () { return res(false); }) | ||
.addListener('listening', function () { | ||
server === null || server === void 0 ? void 0 : server.close(); | ||
res(true); | ||
}); | ||
}); | ||
@@ -19,0 +25,0 @@ }; |
{ | ||
"name": "can-bind-to-host", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Utility package to see if the node process can bind to the host or listen on a port. Can be used for checking if a host resolves to localhost.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10908
7
192