scotty-beam-me-up
TypeScript icon, indicating that this package has built-in type declarations

0.0.2Β β€’Β PublicΒ β€’Β Published

cover npm version npm downloads bundle License

πŸ›Έ scotty-beam-me-up

πŸ›Έ Get an available TCP port to listen

npm version npm downloads License [![JSDocs][jsdocs-src]][jsdocs-href]

πŸ’‘ Usage

Install package:

npm i scotty-beam-me-up
// ESM
import {
   checkPort,
   getPort,
   getRandomPort,
   waitForPort,
} from 'scotty-beam-me-up'

// CommonJS
const {
   getPort,
   checkPort,
   getRandomPort,
   waitForPort,
} = require('scotty-beam-me-up')
getPort(options?: GetPortOptions): Promise<number>
checkPort(port: number, host?: string): Promise<number | false>
waitForPort(port: number, options): Promise<number | false>

Try sequence is: port > ports > random

πŸŽ›οΈ Options

interface GetPortOptions {
   name?: string

   random?: boolean
   port?: number
   portRange?: [from: number, to: number]
   ports?: number[]
   host?: string

   memoDir?: string
   memoName?: string
}

πŸ“› name

Unique name for port memorizing. Default is default.

🎲 random

If enabled, port and ports will be ignored. Default is false.

βš“οΈ port

First port to check. Default is process.env.PORT || 3000

βš“οΈβš“οΈ ports

Extended ports to check.

πŸ”’ portRange

Extended port range to check.

πŸ”’πŸ”’ alternativePortRange

Alternative port range to check as fallback when non of the ports are available. Default is [3000, 3100] (only when port in unspecified.)

🏠 host

The host to check. Default is process.env.HOST otherwise all available hosts will be checked.

πŸ“œ License

MIT - Made with πŸ’ž

Readme

Keywords

none

Package Sidebar

Install

npm i scotty-beam-me-up

Weekly Downloads

2

Version

0.0.2

License

MIT

Unpacked Size

24.7 kB

Total Files

7

Last publish

Collaborators

  • dennisollhoff