JSPM

port-get

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 172
  • Score
    100M100P100Q80904F
  • License Apache-2.0

Get an available TCP port (a minimal CJS module)

Package Exports

  • port-get
  • port-get/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (port-get) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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

License

BSD-3-Clause