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

fastwss

v1.0.0

Published

Fastest WebSocket library for Node.js. Drop-in ws replacement. 900k+ msg/s.

Readme

fastwss

900k+ msg/s WebSocket for Node.js. Drop-in replacement for the ws package. Zero dependencies.

npm install fastwss

Kullanım — ws ile birebir aynı API

import { WebSocket, WebSocketServer } from "fastwss";

Server

import { WebSocketServer } from "fastwss";

const wss = new WebSocketServer({ port: 8080 });

wss.on("connection", (ws, req) => {
  ws.on("message", (data, isBinary) => {
    ws.send(data);                  // echo
  });

  ws.on("close",   (code, reason) => { });
  ws.on("error",   (err)          => { });
});

Client

import { WebSocket } from "fastwss";

const ws = new WebSocket("ws://localhost:8080");

ws.on("open",    ()            => ws.send("hello"));
ws.on("message", (data, isBinary) => console.log(data.toString()));
ws.on("close",   (code, reason)   => { });
ws.on("error",   (err)            => { });

Mevcut ws kodunu geçirmek

// önce
import WebSocket from "ws";
const WebSocketServer = WebSocket.Server;

// sonra — sadece import satırını değiştir
import { WebSocket, WebSocketServer } from "fastwss";

API

new WebSocketServer(options)

| Seçenek | Tip | Varsayılan | Açıklama | |---|---|---|---| | port | number | — | Dinlenecek port | | host | string | — | Bind adresi | | path | string | — | Sadece bu path'e upgrade et | | maxPayload | number | 104857600 | Maks frame boyutu (byte) | | server | http.Server | — | Mevcut HTTP sunucusuna bağla | | noServer | boolean | false | Manuel upgrade için |

Metodlar

wss.clients          // Set<WebSocket> — bağlı tüm clientlar
wss.close(cb)        // Sunucuyu kapat
wss.address()        // { address, port, family }
wss.handleUpgrade(req, socket, head, cb)  // noServer modu

WebSocket (hem client hem server tarafı)

ws.readyState        // 0 CONNECTING | 1 OPEN | 2 CLOSING | 3 CLOSED
ws.send(data, [opts], [cb])
ws.close([code], [reason])
ws.ping([data])
ws.pong([data])
ws.terminate()       // sert kes

// Toplu gönderim — çok daha hızlı
ws.sendBatch([data1, data2, data3, ...])

ws.binaryType

ws.binaryType = "nodebuffer"    // varsayılan → Buffer
ws.binaryType = "arraybuffer"   // → ArrayBuffer

Performans

| Test | msg/s | |---|---| | send() loop (server → client) | 456,000 | | Receive tarafı (client) | 963,810 | | sendBatch() receive | 3,067,036 |

32 byte payload, loopback, Node.js v22, tek işlem.


sendBatch — kitlesel gönderim

Aynı anda çok sayıda mesaj gönderirken sendBatch kullan:

wss.on("connection", (ws) => {
  // guild update, broadcast, vb.
  const msgs = users.map(u => JSON.stringify({ type: "presence", user: u }));
  ws.sendBatch(msgs);
});

noServer — Express / Fastify ile birlikte

import express          from "express";
import { createServer } from "node:http";
import { WebSocketServer } from "fastwss";

const app    = express();
const server = createServer(app);
const wss    = new WebSocketServer({ noServer: true });

server.on("upgrade", (req, socket, head) => {
  wss.handleUpgrade(req, socket, head, (ws) => {
    wss.emit("connection", ws, req);
  });
});

server.listen(3000);

Notlar

  • Compression (permessage-deflate) yok — v2'de gelecek
  • TLS için wss:// URL'i kullan, sertifika yönetimi dışarıda
  • Node.js ≥ 18 gerekli