0.0.3 • Published 5 years ago

portisoccupied v0.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Check If Port is Occupied

Check if the port is Occupied. If not, it returns the default value, otherwise, it will return a free port not be occupied.

Install

npm install portisoccupied --save

Demos

Example 1

// Port 3000 is free
import portisoccupied from 'portisoccupied';

const port = await portisoccupied(3000);

Output

3000

Example 2

// Port 3000 is occupied
import * as net from 'net';
import portisoccupied from 'portisoccupied';

const server = net.createServer().listen(3000);
const port = await portisoccupied(3000);

Output

3001

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago