Skip to content

Commit 6fb8af8

Browse files
committed
Renamed checkIfPortIsInUse to isPortInUse
1 parent 5b4336c commit 6fb8af8

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lup-system",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"description": "NodeJS library to retrieve system information and utilization.",
55
"main": "./lib/index",
66
"types": "./lib/index.d.ts",

src/__tests__/Net.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { checkIfPortIsInUse, getNetworkInterfaces, stopNetworkUtilizationComputation } from '../net';
1+
import { isPortInUse, getNetworkInterfaces, stopNetworkUtilizationComputation } from '../net';
22
import net from 'net';
33

44
test('getNetworkInterfaces', async () => {
@@ -8,11 +8,11 @@ test('getNetworkInterfaces', async () => {
88
expect(nics.length).toBeGreaterThan(0);
99
}, 10000);
1010

11-
test('checkIfPortIsInUse(12345)', async () => {
11+
test('isPortInUse(12345)', async () => {
1212
const port = 12345;
1313

1414
// port should be free
15-
const isInUse1 = await checkIfPortIsInUse(port);
15+
const isInUse1 = await isPortInUse(port);
1616
expect(isInUse1).toBe(false);
1717

1818
// start a server
@@ -21,7 +21,7 @@ test('checkIfPortIsInUse(12345)', async () => {
2121
await new Promise<void>((resolve) => server.listen(port, '0.0.0.0', resolve));
2222

2323
// port should now be in use
24-
const isInUse2 = await checkIfPortIsInUse(port);
24+
const isInUse2 = await isPortInUse(port);
2525
expect(isInUse2).toBe(true);
2626

2727
server.close();

src/net.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export function stopNetworkUtilizationComputation() {
175175
* @param bindAddress Address of the interface to bind to (default '0.0.0.0' which binds to all interfaces).
176176
* @returns Promise that resolves to true if the port is in use, false otherwise.
177177
*/
178-
export async function checkIfPortIsInUse(port: number, bindAddress: string = '0.0.0.0'): Promise<boolean> {
178+
export async function isPortInUse(port: number, bindAddress: string = '0.0.0.0'): Promise<boolean> {
179179
const server = net.createServer();
180180
return new Promise((resolve) => {
181181
server.unref();

0 commit comments

Comments
 (0)