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

@holesail/hyper-cmd-lib-net

v2.0.1

Published

Network library to pipe local and hypderdht udp/tcp streams

Readme

hyper-cmd-lib-net

Pipe local and remote (hyperdht) TCP/UDP streams together.

npm i @holesail/hyper-cmd-lib-net

Usage

const { createTcpProxy } = require('@holesail/hyper-cmd-lib-net')

const proxy = createTcpProxy(
  () => tunnel.createStream(),
  { port: 8080, host: '127.0.0.1' },
  () => console.log('listening on', proxy.address())
)

API

connPiper(a, bFactory, [opts])

Pipe two duplex streams together, and destroy both the moment either one closes or errors.

bFactory() is called once to make the second stream. Throw, or return null, to reject the connection — a gets destroyed and bFactory is never called again.

connPiper(a, () => b, {
  logger: null, // { debug, info, warn, error }, defaults to a no-op logger
  onDestroy: (err) => {} // called once, when the pipe is torn down
})

const proxy = createTcpProxy(remoteTunnel, opts, onListen)

Start a TCP server. Every accepted connection is piped to a fresh remoteTunnel() stream using connPiper above.

createTcpProxy(
  () => tunnel.createStream(),
  {
    port: 0,
    host: '127.0.0.1',
    logger: null,
    onDestroy: (err) => {}
  },
  () => {}
)

Returns the underlying net.Server. proxy.close() also destroys any connections still open, so it doesn't need 'close' listeners on every socket to fully shut down.

pipeTcpServer(remoteStream, leftover, opts)

The other direction of createTcpProxy — connects out to a local TCP service and pipes it to remoteStream.

pipeTcpServer(remoteStream, leftoverBuffer, {
  port: 3000,
  host: '127.0.0.1'
})

leftover is a buffer of bytes already read off remoteStream (eg while sniffing a protocol) that gets written to the local socket before piping starts. Pass null if there isn't any.

UDP framing

UDP has no stream boundaries, so the two helpers below speak a small length-prefixed framing over the tunnel instead: 4 bytes big-endian length, then that many bytes of payload. They're meant to be run as a pair, one on each end of a tunnel.

const { proxySocket, clients } = createUdpFramedProxy(createTunnel, opts, onBind)

Bind a UDP socket. Every distinct sender (by address:port) gets its own tunnel stream, made lazily via createTunnel() on its first packet.

createUdpFramedProxy(
  () => tunnel.createStream(),
  {
    port: 0,
    host: '127.0.0.1',
    maxFrameSize: 65535,
    logger: null
  },
  () => {}
)

clients is a Map of address:port -> { stream, rinfo, buffer }. A frame bigger than maxFrameSize destroys that client's tunnel and evicts it — the next packet from the same client just starts a new one.

pipeUdpFramedServer(stream, leftover, opts)

The other end of the pair. Unframes packets off stream and forwards them as plain UDP to a local service, framing replies back onto stream.

pipeUdpFramedServer(remoteStream, leftoverBuffer, {
  port: 53,
  host: '127.0.0.1',
  maxFrameSize: 65535
})

A clean end on stream ends the local socket, no drama. An error, or a frame over maxFrameSize, destroys it.

License

Apache-2.0