@meslzy/port
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Port (✨)

Find available ports


stars forks issues


Getting Started (✅)

  • Installation (⏬)

npm install @meslzy/port

Usage (📙)

port.isPortAvailable(3000).then((available) => {
  console.log(available); // true | false
});

interface AvailablePortsOptions {
  /**
   * Minimum port number
   * @default 1023
   **/
  min?: number;
  /**
   * Maximum port number
   * @default 65535
   **/
  max?: number;
  /**
   * Maximum number of ports to return
   **/
  limit?: number;
  /**
   * Ports to include
   **/
  include?: number[];
  /**
   * Ports to exclude
   **/
  exclude?: number[];
}

port.getAvailablePorts(AvailablePortsOptions).then((ports) => {
  console.log(ports); // available from 1023 to 65535
});

interface AvailablePortOptions {
  /**
   * Minimum port number
   * @default 1023
   **/
  min?: number;
  /**
   * Maximum port number
   * @default 65535
   **/
  max?: number;
  /**
   * Ports to include
   **/
  include?: number[];
  /**
   * Ports to exclude
   **/
  exclude?: number[];
}

port.getAvailablePort(AvailablePortOptions).then((port) => {
  console.log(port); // available from 1023 to 65535
});

The End (💘)

Readme

Keywords

Package Sidebar

Install

npm i @meslzy/port

Weekly Downloads

1

Version

1.0.2

License

mit

Unpacked Size

7.84 kB

Total Files

6

Last publish

Collaborators

  • meslzy