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

cluster-vir

v1.0.1

Published

Makes it easy to distribute arbitrary scripts across multiple workers.

Readme

cluster-vir

Simplifies running a script across multiple workers. This only works in Node.js (not in the browser) because it relies on Node.js's built-in cluster module.

Install

npm i cluster-vir

Usage

See full docs here: https://electrovir.github.io/cluster-vir

The main export from this package is runInCluster. Pass it a callback to be executed on each worker. Here's an example of how to use it:

import {createServer} from 'node:http';
import {runInCluster} from 'cluster-vir';

/**
 * In the primary thread the output of `runInCluster` gives you an instance of `ClusterManager`
 * which can be used to access all child nodes. In the worker threads it gives you an instance of
 * `WorkerRunner` which can be used to access the worker.
 */
const runner = runInCluster(
    ({worker}) => {
        /**
         * Do the worker actions here. In this example, each worker is listening to a port as an
         * HTTP server.
         */

        /**
         * Cluster workers can share a TCP connection, so an HTTP server can be handled by (and will
         * be load-balanced between) multiple workers (or threads).
         */
        const server = createServer((request, response) => {
            response.writeHead(200);
            response.end(`hello there ${worker.process.pid}`);
        }).listen(8000);

        return () => {
            /**
             * Do cleanup work in here. In this case, we're closing the HTTP server. Note that a
             * cleanup callback cannot be async.
             */
            server.close();
        };
    },
    {
        /**
         * Indicates that all child workers should be started immediately. If set to `false`, you
         * must call `runner.startWorkers()` to start them, giving you time to attach any listeners
         * you may need.
         */
        startWorkersImmediately: true,
    },
);

Notes

  • Workers will not terminate themselves when the callback you provide to runInCluster finishes, you must manually kill them with worker.kill() or process.exit().
  • When all workers have terminated and respawnWorkers has not been set to true, the cluster manager will automatically terminate itself as well.
  • The cluster manager and its workers send messages back and forth so if you add your own event listener to the spawned workers, you'll need an if or switch to focus on your messages.