Socket
Book a DemoInstallSign in
Socket

port-get

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

port-get

Get an available TCP port (a minimal CJS module)

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

port-get

Get an available TCP port (a minimal CJS module)

Install

npm install port-get

Usage

const portGet = require('@holepunchto/port-get')

async function run () {
  console.log('here is a port', await portGet())
}

run.catch(console.error)

Provide a port list. If all ports are unavailable will pick another port.

const portGet = require('@holepunchto/port-get')

async function run () {
  console.log('here is a port', await portGet([7777, 7779, 7779]))
}

run.catch(console.error)

Defaults to providing port on host 127.0.0.1, set host

const portGet = require('@holepunchto/port-get')

async function run () {
  console.log('here is any public port', await portGet('0.0.0.0'))
  console.log('here is a target public port', await portGet([7777, 7779, 7779], '0.0.0.0'))

}

run.catch(console.error)

Prior Art

  • https://github.com/sindresorhus/get-port

License

BSD-3-Clause

Keywords

get-port

FAQs

Package last updated on 29 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts