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

abstract-stream-muxer

v0.2.3

Published

A test suite and interface you can use to implement a stream muxer.

Readme

abstract-stream-muxer

A test suite and interface you can use to implement a stream muxer. "A one stop shop for all your muxing needs"

The primary goal of this module is to enable developers to pick and swap their stream muxing module as they see fit for their application, without having to go through shims or compatibility issues. This module and test suite was heavily inspired by abstract-blog-store.

Publishing a test suite as a module lets multiple modules all ensure compatibility since they use the same test suite.

The API is presented with both Node.js and Go primitives, however, there is not actual limitations for it to be extended for any other language, pushing forward the cross compatibility and interop through diferent stacks.

Modules that implement the interface

Send a PR to add a new one if you happen to find or write one.

Badge

Include this badge in your readme if you make a new module that uses abstract-stream-muxer API.

How to use the battery tests

Node.js

Install abstract-stream-muxer as one of the dependencies of your project and as a test file, using tap, tape or a test runner with compatible API, do:

var tape = require('tape')
var tests = require('abstract-stream-muxer/tests')
var YourStreamMuxer = require('../src')

var common = {
  setup: function (t, cb) {
    cb(null, YourStreamMuxer)
  },
  teardown: function (t, cb) {
    cb()
  }
}

var megaTest = false // a really really intensive test case

tests(tape, common, megaTest)

Go

WIP - being written

API

A valid (read: that follows this abstraction) stream muxer, must implement the following API.

Attach muxer to a transport

  • Node.js conn = muxer.attach(transport, isListener)
  • Go conn, err := muxer.Attach(transport, isListener)

This method attaches our stream muxer to the desired transport (UDP, TCP) and returns/callbacks with the err, conn(error, connection).

If err is passed, no operation should be made in conn.

isListener is a bool that tells the side of the socket we are, isListener = true for listener/server and isListener = false for dialer/client side.

conn abstracts our established Connection with the other endpoint, it must offer an interface to open a stream inside this connection and to receive incomming stream requests.

Dial(open/create) a new stream

  • Node.js stream = conn.dialStream([function (err, stream)])
  • Go stream, err := conn.DialStream()

This method negotiates and opens a new stream with the other endpoint.

If err is passed, no operation should be made in stream.

stream abstract our established Stream with the other endpoint, it must implement the Duplex Stream interface in Node.js or the ReadWriteCloser in Go.

In the Node.js case, if no callback is passed, stream will emit an 'ready' event when it is prepared or a 'error' event if it fails to establish the connection, until then, it will buffer the 'write' calls.

Listen(wait/accept) a new incoming stream

  • Node.js conn.on('stream', function (stream))
  • Go stream := conn.Accept()

Each time a dialing peer initiates the new stream handshake, a new stream is created on the listening side.

In Node.js, the Event Emitter pattern is expected to be used in order to receive new incoming streams, while in Go, it expects to wait when Accept is called.