Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/http.ts>randomPort

A JavaScript extension package for building strong and modern applications.
Latest
function randomPort
import { randomPort } from "https://deno.land/x/ayonli_jsext@v0.9.72/http.ts";

Returns a random port number that is available for listening.

NOTE: This function is not available in the browser and worker runtimes such as Cloudflare Workers.

Parameters

optional
prefer: number | undefined = [UNSUPPORTED]

The preferred port number to return if it is available, otherwise a random port is returned.

optional
hostname: string | undefined = [UNSUPPORTED]

The hostname to bind the port to. Default is "0.0.0.0", only used when prefer is set and not 0.

Returns

Promise<number>