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

@llmcode/yamux-ts

v0.0.2

Published

Yamux implementation for Node.js in TypeScript coding by Codex

Readme

yamux-ts

TypeScript implementation of Yamux for Node.js.

This library multiplexes many logical Duplex streams over a single underlying transport (typically a TCP socket), following the Yamux framing and stream lifecycle rules.

Features

  • Yamux frame codec (12-byte header, big-endian)
  • SYN/ACK/FIN/RST stream lifecycle
  • Per-stream flow control (default 256 KB)
  • Session-level Ping and GoAway
  • Node.js Duplex API for each logical stream
  • Interop tests with hashicorp/yamux (Go)

Install

pnpm add @llmcode/yamux-ts

Quick Start

Client side

import net from "node:net";
import { Client } from "@llmcode/yamux-ts";

const socket = net.connect(9000, "127.0.0.1");

socket.once("connect", async () => {
  const session = Client(socket);

  session.on("error", (err) => {
    console.error("session error", err);
  });

  const stream = session.openStream();
  stream.write("hello over yamux\n");
  stream.end();

  for await (const chunk of stream) {
    process.stdout.write(chunk);
  }

  const ping = await session.ping();
  console.log("rtt(ms)", ping.rttMs);

  session.goAway();
  session.close();
});

Server side

import net from "node:net";
import { Server } from "@llmcode/yamux-ts";

const server = net.createServer((socket) => {
  const session = Server(socket);

  session.on("stream", (stream) => {
    stream.on("data", (chunk) => {
      // Echo back.
      stream.write(chunk);
    });

    stream.on("end", () => {
      stream.end();
    });
  });

  session.on("goaway", (code) => {
    console.log("peer sent goaway", code);
  });

  session.on("error", (err) => {
    console.error("session error", err);
    session.close();
  });
});

server.listen(9000, "127.0.0.1");

API

Client(transport, config?)

Create a Yamux session in client mode (outbound stream IDs are odd: 1, 3, 5...).

Server(transport, config?)

Create a Yamux session in server mode (outbound stream IDs are even: 2, 4, 6...).

createClientSession(transport, options?) and createServerSession(transport, options?)

Compatibility aliases for users who prefer explicit factory names. They are functionally equivalent to Client and Server.

new YamuxSession(transport, options)

options / config:

  • role: "client" | "server" (required)
  • initialStreamWindow?: number default 256 * 1024
  • maxFrameSize?: number default 64 * 1024

Methods:

  • openStream(): YamuxStream
  • ping(timeoutMs?: number): Promise<{ nonce: number; rttMs: number }>
  • goAway(code?: GoAwayCode): void
  • close(): void

Events:

  • stream incoming YamuxStream
  • goaway peer session termination code
  • error session/protocol error
  • close session closed

YamuxStream (extends Duplex)

Use it as a normal Node stream:

  • write with stream.write() / stream.end()
  • read with stream.on("data") / async iteration
  • remote half-close maps to end
  • reset maps to stream error (YamuxStreamResetError)

Constants and Types

Exported protocol constants:

  • YAMUX_VERSION
  • HEADER_SIZE
  • FrameType
  • FrameFlag
  • GoAwayCode
  • DEFAULT_INITIAL_WINDOW
  • DEFAULT_MAX_FRAME_SIZE

Exported low-level helpers:

  • encodeFrame, decodeFrame, decodeHeader, writeHeader
  • FrameParser, YamuxCodec

Error Semantics

  • YamuxProtocolError: invalid frame or protocol violation
  • YamuxClosedError: operation on closed/goaway session
  • YamuxStreamResetError: stream reset (RST)

On protocol violation, session sends GoAway(ProtocolError) and closes.

Development

pnpm typecheck
pnpm test
pnpm test:interop
pnpm build

Interop Testing

pnpm test:interop starts a Go process in test/interop/go using hashicorp/yamux and validates:

  • stream open + payload echo
  • concurrent streams
  • ping roundtrip

LLM Integration Guide

For code generation agents, see:

  • docs/LLM_GUIDE.md