-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π chore(.eslintignore): add README.md to ignored files
π¨ 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
Showing
3 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |