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

@sihosbir/voidws

v1.0.0

Published

Ultra-fast WebSocket client for Discord Gateway

Readme

VoidWS (Ultra-High Performance WebSocket Engine)

Discord Gateway ve yüksek throughput gerektiren gerçek zamanlı sistemler için özel olarak optimize edilmiş, sıfırdan yazılmış ultra-hızlı WebSocket istemcisi.


🚀 Temel Özellikler ve Optimizasyonlar

  • 16-Byte Unrolled Vector Masking: 4x 32-bit register unrolling ile CPU pipeline'ını tam kapasite kullanan ultra-hızlı frame maskeleme.
  • 2MB Send Slab Pool: Küçük ve orta boyuttaki frame'ler için V8 heap allocation'ı ve Garbage Collector (GC) baskısını sıfıra indirir.
  • sendBatch(messages): Birden fazla mesajı tek bir TCP frame'inde birleştirerek sistem çağrısı (syscall) maliyetini N'den 1'e düşürür (6.8 Milyon+ msg/sec).
  • VoidSocket.broadcast(sockets, data): Tekil payload'ı N sokete minimum kopyalama ile dağıtır (4.4 Milyon+ msg/sec).
  • Zero-Copy Receive Parser: Gelen unmasked frame'leri kopyalamadan Buffer.subarray ile doğrudan işler (860K+ msg/sec).
  • Backpressure & Flow Control: bufferedAmount ve ondrain callback desteği.
  • Discord Gateway Acceleration: Binary seviyesinde önceden derlenmiş Buffer pattern matching ile string dönüşümü yapmadan anında event yönlendirme.

📊 Benchmark Sonuçları (Node.js v26)

Testleri çalıştırmak için:

node benchmark.js

| İşlem | Throughput (msg/s) | Veri Hızı (MB/s) | İşlem Başına Gecikme | |---|---|---|---| | send() (Small JSON - 20B) | 3,407,027 msg/s | 74.73 MB/s | 293.5 ns (0.29 µs) | | send() (Medium JSON - 150B) | 2,047,511 msg/s | 206.98 MB/s | 488.4 ns (0.48 µs) | | send() (Large JSON - 1.5KB) | 446,022 msg/s | 341.99 MB/s | 2,242.0 ns (2.24 µs) | | sendBatch() (Batch: 50) | 6,713,617 msg/s | 147.26 MB/s | 149.0 ns | | sendBatch() (Batch: 1000) | 6,860,682 msg/s | 150.49 MB/s | 145.8 ns | | VoidSocket.broadcast() (50 Soket) | 4,436,293 msg/s | - | 11.27 µs / broadcast | | Receive / Parse & Dispatch | 860,101 msg/s | 58.24 MB/s | 1,162.7 ns | | Real TCP Loopback RTT | 48,394 req/s | - | 20.66 µs (0.02 ms) |


📦 Kurulum ve Dahil Etme

npm veya GitHub kurulumu gerekmez:

const VoidSocket = require('./voidws');

🛠️ API Kullanım Rehberi

1. Tekil Mesaj Gönderme (send)

const ws = new VoidSocket('wss://gateway.discord.gg/?v=10&encoding=json', {
    edgeIP: '162.159.137.232', // Opsiyonel: DNS bypass
    servername: 'gateway.discord.gg'
});

ws.onopen = () => {
    ws.send('{"op":1,"d":null}');
};

2. Toplu Mesaj Gönderme (sendBatch) — Yüksek Verim

const messages = [
    '{"op":1,"d":null}',
    '{"op":2,"d":{...}}',
    '{"op":3,"d":{...}}'
];

// Tek bir TCP write ile atomik gönderim
ws.sendBatch(messages);

3. Çoklu Sokete Yayın (broadcast)

const activeSockets = [ws1, ws2, ws3, ws4];
VoidSocket.broadcast(activeSockets, '{"t":"BROADCAST_EVENT"}');

4. Zero-Copy Binary Dinleyici (onraw)

// UTF-8 string dönüşüm maliyeti olmadan doğrudan Buffer işleme
ws.onraw = (buf, opcode) => {
    // buf: Buffer subarray
};

5. Flow Control & Backpressure

const ok = ws.send(largePayload);
if (!ok) {
    console.log('Buffer doldu, pending bytes:', ws.bufferedAmount);
}

ws.ondrain = () => {
    console.log('Buffer boşaldı, göndermeye devam edilebilir.');
};