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

simple-rebroadcaster

v0.0.3

Published

Simple service to re-broadcast websocket to all clients in a 'room'

Downloads

12

Readme

Simple Rebroadcaster

Simple server for websocket 'rooms' and 'clients'

Example

Using the server

import {start} from 'simple-rebroadcaster'
start(host, port, logger)

Running the default server

Simply run with npm run start.

This will run server at environment variables APP_HOST and APP_PORT defaulting to "0.0.0.0" and 10000 respectively.

Clientside - Connecting, sending, listening

Simply connect as usual, including a roomId and clientId

// clientside javascript
const url = new URL('wss://your-hosted-server.com')
url.searchParams.append('roomId', 'some-room-id')
url.searchParams.append('clientId', 'some-client-id')

const socket = new WebSocket(url.toString())
socket.onopen = e => console.debug('socket.onopen', {e})
socket.onclose = e => console.debug('socket.onclose', {e})
socket.onerror = e => console.error('socket.onclose', {e})
socket.onmessage = e => console.debug('socket.onmessage', {e})

When sending messages, anything that should be rebroadcast to any other clients in the room should be sent as json

socket.send(JSON.stringify({
  some: 'arbitrary',
  data: ['goes', 'here']
}))

One exception is a ping/pong that can be used as a heartbeat for servers that are killed on inactivity

socket.send('ping')

Messages are handled with the types described in the types file, the arbitrary client messages will look like this:

socket.on('message', e => {
  // do nothing for heartbeat response
  if(e.data === 'pong') return;

  const data = JSON.parse(e.data)
  // {
  //   type: 'client-event',
  //   data: {
  //     id: 'the-source-clients-id'
  //     data: {
  //       some: 'arbitrary',
  //       data: ['goes', 'here']
  //     }
  //   }
  // }
})