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

wave-threaded-server

v1.0.0

Published

Full-stack library combining wave-driven server concurrency with client-side routing

Readme

wave-threaded-server

A wave-driven concurrency controller for Node.js using Express and worker threads. Designed to adaptively manage load using a configurable wave shape, backpressure, and automatic worker scaling.

Ideal for stateless task processing under fluctuating load using adaptive concurrency control.


Features

  • 🌊 Wave-based concurrency: Controls worker count using a sine wave model with load-aware shaping.
  • 🔁 Backpressure queueing: Smoothly queues excess requests and avoids overload.
  • ⚙️ Stateless task execution: Distributes tasks via worker threads with retries and failure tracking.
  • 📈 Adaptive tuning: Adjusts wave amplitude/period based on latency feedback.
  • 🔍 Built-in metrics & healthcheck: Easily monitor performance and status.

Installation

npm install wave-threaded-server

Usage

1. Setup an Express App

const express = require('express');
const {
  WaveController,
  waveMiddleware,
  runStatelessTask,
  exposeMetrics,
  exposeHealthCheck
} = require('wave-threaded-server');

const app = express();
const wave = new WaveController();

app.locals.taskFn = async (x) => {
  // Simulate async computation
  await new Promise(r => setTimeout(r, 50));
  return x * 2;
};

app.use(waveMiddleware({ waveController: wave }));

// Stateless route (uses worker threads)
app.get('/compute', async (req, res, next) => next());

// Optional: Metrics and health endpoints
exposeMetrics(app);
exposeHealthCheck(app);

app.listen(3000, () => console.log('Server running on port 3000'));

2. Test It

curl http://localhost:3000/compute

API

WaveController(options)

Adaptive concurrency controller.

  • options.period: Wave period in ms.
  • options.amplitude: Maximum number of workers.
  • options.offset: Phase offset in ms.
  • options.shapeFn(phase): Custom wave shape (optional).

waveMiddleware({ waveController, isStateless })

Middleware that routes GET/POST differently and applies backpressure queueing.

runStatelessTask(data, waveController)

Runs a task in a worker thread with retries and backoff.

await runStatelessTask({ value: 10 }, wave);

exposeMetrics(app, path?)

Adds a /metrics route returning wave and worker stats.

exposeHealthCheck(app, path?)

Adds a /health route returning a basic health status.


Environment Variables

| Name | Description | Default | |------|-------------|---------| | WAVE_PERIOD | Wave period in ms | 10000 | | WAVE_AMPLITUDE | Max concurrency | CPU count | | WAVE_MIN_THREADS | Minimum concurrency | 1 | | WAVE_LATENCY_TARGET_MS | Target latency | 200 | | WAVE_QUEUE_MAX_SIZE | Max queue size | 1000 |


License

MIT