portfinder

  • Version 1.0.32
  • Published
  • 19.9 kB
  • 3 dependencies
  • MIT license

Install

npm i portfinder
yarn add portfinder
pnpm add portfinder

Overview

A simple tool to find an open port on the current machine

Index

Variables

variable basePort

let basePort: number;
  • The lowest port to begin any port search from.

variable highestPort

let highestPort: number;
  • The highest port to end any port search from.

Functions

function getPort

getPort: {
(callback: PortfinderCallback): void;
(options: PortFinderOptions, callback: PortfinderCallback): void;
};
  • Responds with a unbound port on the current machine.

function getPortPromise

getPortPromise: (options?: PortFinderOptions) => Promise<number>;
  • Responds a promise of an unbound port on the current machine.

function getPorts

getPorts: (
count: number,
options: PortFinderOptions,
callback: (err: Error, ports: Array<number>) => void
) => void;

    function setBasePort

    setBasePort: (port: number) => void;
    • Set the lowest port to begin any port search from.

    function setHighestPort

    setHighestPort: (port: number) => void;
    • Set the higheset port to end any port search from.

    Interfaces

    interface PortFinderOptions

    interface PortFinderOptions {}

      property host

      host?: string;
      • Host to find available port on.

      property port

      port?: number;
      • Minimum port (takes precedence over basePort).

      property startPort

      startPort?: number;
      • search start port (equals to port when not provided) This exists because getPort and getPortPromise mutates port state in recursive calls and doesn't have a way to retrieve begininng port while searching.

      property stopPort

      stopPort?: number;
      • Maximum port

      Type Aliases

      type PortfinderCallback

      type PortfinderCallback = (err: Error, port: number) => void;
      • portfinder.js typescript definitions.

        (C) 2011, Charlie Robbins

      Package Files (1)

      Dependencies (3)

      Dev Dependencies (1)

      Peer Dependencies (0)

      No peer dependencies.

      Badge

      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/portfinder.

      • Markdown
        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/portfinder)
      • HTML
        <a href="https://www.jsdocs.io/package/portfinder"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>