From 7cfd03885158713e63d0bfd8b5b1466131cadae6 Mon Sep 17 00:00:00 2001 From: kodemon Date: Fri, 19 Jul 2024 19:41:59 +0200 Subject: [PATCH] feat: export port tools --- docker/libraries/port.ts | 8 ++++---- mod.ts | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docker/libraries/port.ts b/docker/libraries/port.ts index 7aa8212..dd875df 100644 --- a/docker/libraries/port.ts +++ b/docker/libraries/port.ts @@ -4,7 +4,7 @@ export const MAX_PORT = 65535; /** * Try run listener to check if port is open. * - * @param options + * @param options - Deno listen options. */ export function checkPort(options: Deno.ListenOptions): CheckedPort { const { port } = options; @@ -45,7 +45,7 @@ export function makeRange(from: number, to: number): number[] { /** * Return a random port between 1024 and 65535. * - * @param hostname + * @param hostname - Hostname to check for port availability under. (Optional) */ export function randomPort(hostname?: string): number { const port = Math.ceil(Math.random() * ((MAX_PORT - 1) - MIN_PORT + 1) + MIN_PORT + 1); @@ -59,8 +59,8 @@ export function randomPort(hostname?: string): number { /** * Return available port. * - * @param port - * @param hostname + * @param port - Wanted port, or list of ports. (Optional) + * @param hostname - Hostname to check for availability under. (Optional) */ export default function getPort(port?: number | number[], hostname?: string): number { const listenOptions: Deno.ListenOptions = { diff --git a/mod.ts b/mod.ts index bb74a76..660e25f 100644 --- a/mod.ts +++ b/mod.ts @@ -5,5 +5,6 @@ export type { Docker } from "./docker/libraries/docker.ts"; export type { Exec } from "./docker/libraries/exec.ts"; export type { Image } from "./docker/libraries/image.ts"; export { modem } from "./docker/libraries/modem.ts"; +export * from "./docker/libraries/port.ts"; export const docker: Docker = new Docker();