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 ๐Ÿ’ž

Dependentsโ€‚(1)

Package Sidebar

Install

npm i scotty-beam-me-up

Weekly Downloads

3

Version

0.0.2

License

MIT

Unpacked Size

24.7 kB

Total Files

7

Last publish

Collaborators

  • dennisollhoff