# portu

> Port utils

Latest version **0.3.0** (published 2021-05-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install portu
pnpm add portu
yarn add portu
bun add portu
```

Provides the command `portu`.

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2021-05-31 |
| First published | 2020-10-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.13.0 |
| Dependencies | 2 |
| Unpacked size | 7.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 81 |
| Maintainers | deepsweet, psxcode, fosimus |
| Keywords | port, free-port, check-port |

## Links

- npm: https://www.npmjs.com/package/portu
- Repository: https://github.com/nextools/metarepo
- Homepage: https://github.com/nextools/metarepo#readme
- Issues: https://github.com/nextools/metarepo/issues
- npm.io page: https://npm.io/package/portu

## Dependencies (2)

- [sleap](https://npm.io/package/sleap.md) ^0.1.0
- [spown](https://npm.io/package/spown.md) ^0.1.2

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2021-05-31
- 0.2.0 — 2020-10-15
- 0.1.0 — 2020-10-13
- 0.0.0 — 2020-10-06

## README

# portu ![npm](https://flat.badgen.net/npm/v/portu)

Port utils.

## Install

```sh
$ yarn add portu
```

## Usage

```ts
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>
```

```ts
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
```

---
_Source: https://npm.io/package/portu · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
