0.3.0 • Published 3 years ago

portu v0.3.0

Weekly downloads
129
License
MIT
Repository
github
Last release
3 years ago

portu npm

Port utils.

Install

$ yarn add portu

Usage

const isPortFree: (port: number, host: string) => Promise<boolean>

const getFreePort: (from: number, to: number, host: string) => Promise<number>

const getPortProcess: (port: number, host: string) => Promise<number | null>

const killPortProcess: (port: number, host: string) => Promise<number | null>

const waitForPort: (port: number, host: string) => Promise<void>
import { isPortFree, getFreePort, getPortProcess, killPortProcess, waitForPort } from 'portu'

const host = 'localhost'
const port = 31337

const isFree = await isPortFree(port, host)
// true

const port = await getFreePort(port, port + 10, host
// 31337

let pid = await getPortProcess(port, host)
// null

pid = await killPortProcess(port, host)
// null

await waitForPort(port, host)
// checks every 200ms
0.3.0

3 years ago

0.2.0

4 years ago

0.1.0

4 years ago

0.0.0

4 years ago