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

generator-host

v1.0.1

Published

`generator-host` is a JavaScript library that allows you to create a multi-port WebSocket server. It supports creating WebSocket servers on multiple ports and handles incoming client requests through customizable decorator functions. You can easily add

Readme

GeneratorHost

generator-host is a JavaScript library that allows you to create a multi-port WebSocket server. It supports creating WebSocket servers on multiple ports and handles incoming client requests through customizable decorator functions. You can easily add WebSocket servers, process data, and customize the behavior of connections on a per-port basis.

Installation

npm i generator-host

Usage

Initializing GeneratorHost

First, you need to initialize a GeneratorHost object and provide the list of ports on which you want the WebSocket server to listen.

import {GeneratorHost} from "generator-host";

// Initialize GeneratorHost with ports 7070 and 3030
// Default  host  ['8080']
const HostSocket = new GeneratorHost({ host: ["7070", "3030"] });

// Initialize servers and WebSocket
await HostSocket.init();

Customizing decorators for each port

You can use the portDecorator method to specify how to handle client messages for each port separately. The decorator function will be called whenever the server receives a message from the client

HostSocket.portDecorator("7070", (clientMessage) => {
    // Process client data and return the result
    const convertedMessage = clientMessage + " editor";
    return convertedMessage;
});

Customizing decorators for each port

After initialization, you can check the list of ports that your WebSocket server is listening on

 console.log(HostSocket.allport);

Full Example

import {GeneratorHost} from "generator-host";
// Initialize with ports 7070 and 3030
const HostSocket = new GeneratorHost({ host: ["7070", "3030"] });

// Initialize WebSocket servers
await HostSocket.init();

// Customize decorator for port 7070
HostSocket.portDecorator("7070", (clientMessage) => {
  return clientMessage + " - processed on 7070";
});

// Customize decorator for port 3030
HostSocket.portDecorator("3030", (clientMessage) => {
  return clientMessage + " - processed on 3030";
});

// Check active ports
console.log(HostSocket.allport);