portisoccupied
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

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

/portisoccupied/

    Package Sidebar

    Install

    npm i portisoccupied

    Weekly Downloads

    3

    Version

    0.0.3

    License

    MIT

    Unpacked Size

    3.75 kB

    Total Files

    6

    Last publish

    Collaborators

    • nelayah