portfinder
- Version 1.0.37
- Published
- 22.5 kB
- 2 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 basePath
let basePath: string;
Default path to begin any socket search from.
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: { (options: PortFinderOptions): Promise<number>; (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): Promise<Array<number>>; (count: number, callback: (err: Error, ports: number[]) => void): void; ( count: number, options: PortFinderOptions, callback: (err: Error, ports: number[]) => void ): void;};
Responds with an array of unbound ports on the current machine.
function getPortsPromise
getPortsPromise: ( count: number, options?: PortFinderOptions) => Promise<Array<number>>;
Responds a promise that resolves to an array of unbound ports on the current machine.
function getSocket
getSocket: { (options: SocketFinderOptions): Promise<string>; (callback: SocketfinderCallback): void; (options: SocketFinderOptions, callback: SocketfinderCallback): void;};
function getSocketPromise
getSocketPromise: (options?: SocketFinderOptions) => Promise<string>;
function setBasePath
setBasePath: (path: string) => void;
Set the base path to begin any socket search from.
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
interface SocketFinderOptions
interface SocketFinderOptions {}
Type Aliases
type PortfinderCallback
type PortfinderCallback = (err: Error, port: number) => void;
portfinder.js typescript definitions.
(C) 2011, Charlie Robbins
type SocketfinderCallback
type SocketfinderCallback = (err: Error, socket: string) => void;
Package Files (1)
Dependencies (2)
Dev Dependencies (1)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto 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[](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>
- Updated .
Package analyzed in 1761 ms. - Missing or incorrect documentation? Open an issue for this package.