portfinder

  • Version 1.0.28
  • Published
  • 19.4 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.

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;

    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 (2)

      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>