Skip to content

Commit

Permalink
πŸ” chore(.eslintignore): add README.md to ignored files
Browse files Browse the repository at this point in the history
🎨 style(README.md): format README.md file
πŸš€ feat(README.md): add documentation for scotty-beam-me-up package
The first commit adds README.md to the ignored files in the eslint configuration. The second commit formats the README.md file. The third commit adds documentation for the scotty-beam-me-up package, including usage instructions, options, and license information.
  • Loading branch information
nyxb committed May 18, 2023
1 parent 8f91ee3 commit 2516d03
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist
README.md
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 112 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
[![cover][cover-src]][cover-href]
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![License][license-src]][license-href]

# πŸ›Έ scotty-beam-me-up

> πŸ›Έ Get an available TCP port to listen
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![License][license-src]][license-href]
[![JSDocs][jsdocs-src]][jsdocs-href]

## πŸ’‘ Usage

Install package:

```bash
npm i scotty-beam-me-up
```

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

// CommonJS
const {
getPort,
checkPort,
getRandomPort,
waitForPort,
} = require('scotty-beam-me-up')
```

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

```ts
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](./LICENSE) - Made with πŸ’ž

<!-- Badges -->

[npm-version-src]: https://img.shields.io/npm/v/scotty-beam-me-up?style=flat&colorA=18181B&colorB=14F195
[npm-version-href]: https://npmjs.com/package/scotty-beam-me-up
[npm-downloads-src]: https://img.shields.io/npm/dm/scotty-beam-me-up?style=flat&colorA=18181B&colorB=14F195
[npm-downloads-href]: https://npmjs.com/package/scotty-beam-me-up
[bundle-src]: https://img.shields.io/bundlephobia/minzip/scotty-beam-me-up?style=flat&colorA=18181B&colorB=14F195
[bundle-href]: https://bundlephobia.com/result?p=scotty-beam-me-up
[license-src]: https://img.shields.io/github/license/nyxblabs/scotty-beam-me-up.svg?style=flat&colorA=18181B&colorB=14F195
[license-href]: https://github.com/nyxblabs/scotty-beam-me-up/blob/main/LICENSE

<!-- Cover -->
[cover-src]: https://raw.githubusercontent.com/nyxblabs/scotty-beam-me-up/main/.github/assets/cover-github-scotty-beam-me-up.png
[cover-href]: https://πŸ’»nyxb.ws

0 comments on commit 2516d03

Please sign in to comment.