Check if your machine is currently online and connected to the internet in Deno.
Import the isOnline
function and use it:
import { isOnline } from "https://deno.land/x/online/mod.ts";
const amIOnline = await isOnline(); // boolean
CLI with DPX
After installing DPX, you can directly use the CLI using the dpx
command:
dpx online --allow-net
# You are not in a Docker environment
Alternatively, you can use it directly from the CLI by using deno run
:
deno run --allow-read https://deno.land/x/online/cli.ts
You can also install it globally using the following:
deno install --allow-read -n online https://deno.land/x/online/cli.ts
Then, the package is available to run:
online # You are online
Required permissions:
--allow-net
Run tests:
deno test --allow-net
- sindresorhus/is-online is the Node.js project serving as inspiration for this one
MIT © Denorg
A project by Denorg, the world's first Deno-focused community
organization and consulting company. Work with us →