npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@digta/network

v0.1.0

Published

TCP + WebSocket client with autoreconnect, plus a tiny HTTP API client with retries. One toolkit.

Readme

@digta/network

Network toolkit for Node: a TCP / WebSocket client with autoreconnect, plus a tiny HTTP API client with retries. Same package, one import.

npm install @digta/network

Connection — TCP / WebSocket + autoreconnect

One API for both transports. Pick it with the URL scheme: tcp://, ws://, or wss://.

import { createConnection } from "@digta/network";
// or: const { createConnection } = require("@digta/network");

const conn = createConnection({
  url: "tcp://192.168.1.10:502",   // or "ws://host:8080/path"
  reconnect: true,                 // on by default
  backoff: { min: 500, max: 30000, factor: 2 },
});

conn.on("connect", () => console.log("connected"));
conn.on("message", (data) => console.log("in:", data));
conn.on("reconnecting", (attempt, delay) => console.log(`retry #${attempt} in ${delay}ms`));
conn.on("close", () => console.log("closed"));
conn.on("error", (err) => console.error(err));

conn.connect();
conn.send("hello");
// conn.close();  // intentional — stops reconnecting

Autoreconnect uses exponential backoff with jitter and resets on success. Call close() to stop for good.

Heartbeat & latency (optional)

Set heartbeat (ms) to ping and measure round-trip time:

const conn = createConnection({ url: "ws://host:8080", heartbeat: 5000 });
conn.on("latency", (ms) => console.log(`${ms}ms`));
conn.on("timeout", () => console.log("no pong — dropping + reconnecting"));
  • WebSocket: works out of the box (native ping/pong frames).
  • Raw TCP: has no ping frame. Provide your protocol's ping bytes and an isPong(data) matcher, or rely on OS keepalive (always on) for dead-link detection.

Events

connect · message(data) · close · error(err) · reconnecting(attempt, delay) · reconnect_failed(attempts) · latency(ms) · timeout

TCP is a raw byte stream — it has no message framing. message fires per chunk; handle your own boundaries. WebSocket messages are framed for you.

API — HTTP client with retries

import { createApi } from "@digta/network";

const api = createApi({
  baseURL: "https://api.example.com",
  headers: { authorization: "Bearer …" },
  timeout: 10000,
  retries: 3,        // retries network errors, timeouts, 429, and 5xx (exp backoff)
});

const { data, status } = await api.get("/users", { query: { page: 2 } });
await api.post("/users", { name: "digta" });          // JSON body auto-serialized
await api.get("/thing", { retries: 0, timeout: 2000 }); // per-request overrides
  • JSON bodies are serialized and Content-Type set automatically; JSON responses are parsed.
  • 4xx/5xx reject with an error carrying .status and .response.
  • Follows redirects (up to 5 hops).
  • Zero HTTP dependency — built on Node's http/https, works on Node 14+.

For one-off absolute-URL calls, use the ready api:

import { api } from "@digta/network";
const res = await api.get("https://example.com/health");

License

MIT