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 🙏

© 2025 – Pkg Stats / Ryan Hefner

sonic-ws

v1.0.6

Published

Ultra-lightweight, high-performance, and bandwidth efficient websocket library

Readme

sonic-ws

INFO

SonicWS is an ultra-lightweight, high-performance WebSocket library focused on maximum bandwidth efficiency, speed, and security.

Compression:

  • Lossless compression up to 70% or more (for example, 38kb -> 14kb)
  • Optimized bandwidth for many different types to fit special constraints
  • Automatic helpers to flatten typed nested arrays for maximum wire efficiency (for example, [[1,2,3],[4,5,6]] to [[1,4],[2,5],[3,6]])
  • Uses raw binary bytes to transmit data as efficiently as possible while still using high level readable code

Developer Friendly:

  • Predefined data types of various sized integers, single and double precision floating point numbers, strings, enums, etc. and RAW to allow for developers to do anything they want
  • Keys are automatically indexed before transfer, improving readability and efficiency (for example, send("pixel") and send("p") use the same bandwidth)
  • Data is validated and supports custom validation, ensuring only valid, safe, and untampered packets ever call your listeners
  • Edge cases are heavily tested with heavy data ranges; supports code points fully up to the max of 0x10FFFF

Security:

  • Tamper-proof; any invalid packet instantly causes closure, and tampering becomes incredibly difficult
  • Built-in ability for handshake packets, preventing repetitive initiation checks in listeners (for example, removes if(!init) everywhere)
  • Built-in rate limiting for packets; ability for global send & receive, alongside per-packet rate limiting
  • Built-in disabling & enabling of packets to prevent abuse

Performance & Scaling:

  • Can handle very large packets in microseconds
  • Can support megabytes of data and millions of values with minimal latency
  • Can broadcast to a filtered list of connections such as all, except sender, or any other subset
  • Built-in packet batching feature with no boilerplate and with per-client queues and bandwidth efficiency

Developer Experience:

  • Minimal boilerplate code due to listeners only receiving valid data
  • Enums can map to any primitive value (e.g. number, string, boolean, null) and transmits in 1 byte
  • Timers and intervals for sockets that automatically clear upon closure
  • Many data types to maximize speed, clarity, bandwidth, and security
  • Debug tools for socket ids, byte size, data logging, etc. for troubleshooting
  • Very minimal learning curve, easy to work in
  • JSDoc's for understanding

Whether you're making a real-time game, a dashboard, a distributed system, or anything else, SonicWS gets you safe, structured packets, fast.

SAMPLES

Importing:

Node (Client & Server):

import { PacketType, SonicWS, SonicWSServer, CreatePacket, CreateObjPacket } from "sonic-ws";

Browser (Client):

<script src="https://cdn.jsdelivr.net/gh/liwybloc/sonic-ws/release/SonicWS_bundle.js"></script>

*This will always give the latest release build. I will add branches for each release if this project actually goes anywhere.

Server:

const wss = new SonicWSServer({
    clientPackets: [
        CreatePacket({tag: "pong", type: PacketType.UVARINT, dataMax: 1})
    ],
    serverPackets: [
        CreatePacket({tag: "ping", type: PacketType.UVARINT, dataMax: 1}),
        CreateObjPacket({tag: "data", types: [PacketType.UBYTES, PacketTypes.STRINGS], dataMaxes: [2, 3]})
    ],
    websocketOptions: { port: 1234 }
});

wss.on_connect((socket) => {

    console.log("Socket connection:", socket.id);

    socket.on("pong", (num) => {
        console.log("Ponged!", num);
        socket.send("data", [Math.floor(Math.random() * 26), Math.floor(Math.random() * 256)], ["hello", "from", "server"]);
    });

    socket.setInterval(() => {
        socket.send("ping", Date.now());
    }, 10000);

});

wss.on_ready(() => {
    console.log("Server ready!");
});

Client:

const ws = new SonicWS("ws://localhost:1234");

ws.on_ready(() => {
    console.log("Connected to server");
});

ws.on("ping", (num) => {
    console.log("Pinged!", num);
    ws.send("pong", Date.now());
})
ws.on("data", (i, s) => {
    console.log("data: ", i);
    console.log("message: " + s.join(" "));
});

ws.on_close((event) => {
    console.log("closed client: " + event.code);
});

KNOWN ISSUES

PLANNED FEATURES

Better error handling