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

@plinthjs/horizon

v0.1.0

Published

Mason queue supervisor and metrics (the Laravel Horizon equivalent, headless).

Readme

@plinthjs/horizon

Mason's queue supervisor and metrics, a headless Laravel Horizon equivalent built on @plinthjs/queue (there is no dashboard UI). A Supervisor manages a pool of worker slots draining one or more queues, a MasterSupervisor coordinates several supervisors, and a MetricsRecorder reports throughput, runtimes, wait times and processed/failed counts.

Mason models a Horizon "process" as a logical concurrency slot over an injected work loop, so scaling, load balancing and the running / paused / terminated lifecycle are deterministic and testable without spawning OS processes.

Install

npm install @plinthjs/horizon

Usage

import { ArrayQueue } from '@plinthjs/queue'
import { pendingSizeFor, Supervisor, workLoopFor } from '@plinthjs/horizon'

const queue = new ArrayQueue()

const supervisor = new Supervisor(
  workLoopFor(queue), // each slot drains the queue once per tick via queue.work()
  { queues: ['default', 'emails'], maxProcesses: 4, balance: 'auto' },
  pendingSizeFor(queue), // load probe used by 'auto' balancing
)

supervisor.start() // supervisors start 'paused'
await supervisor.tick() // { processed, failed } for one round across every slot

// Or loop until paused/terminated, or until the predicate says stop.
let rounds = 0
await supervisor.run(() => ++rounds < 10)

supervisor.terminate() // a terminated supervisor cannot be restarted

Scaling and balancing

supervisor.processCount() // 4
supervisor.processes() // { default: 2, emails: 2 }
supervisor.processesFor('emails') // 2
supervisor.scale(2) // clamped to 1..maxProcesses
supervisor.rebalance() // force an 'auto' rebalance now; returns the allocation
supervisor.watching() // ['default', 'emails']

The balance option picks the strategy:

  • 'off' (default): every slot works the first queue.
  • 'simple': slots are split evenly across the queues.
  • 'auto': slots follow each queue's pending size, moving at most balanceMaxShift slots per rebalance, keeping at least minProcesses per queue, and waiting balanceCooldownMs between rebalances (measured with the injectable now clock).

Master supervisor

import { MasterSupervisor } from '@plinthjs/horizon'

const master = new MasterSupervisor({ web: webSupervisor }).add('mail', mailSupervisor)

master.start()
await master.tick() // summed { processed, failed } across children
master.state() // 'running' if any child runs
master.states() // { web: 'running', mail: 'running' }
master.processes() // slots summed per queue
master.pause().continue().terminate()

Metrics

import { MetricsRecorder } from '@plinthjs/horizon'

let now = 0
const metrics = new MetricsRecorder({ now: () => now, throughputWindowMs: 60_000 })

metrics
  .recordJob({ queue: 'emails', runtimeMs: 120, status: 'processed', waitMs: 30 })
  .recordJob({ queue: 'emails', runtimeMs: 80, status: 'failed' })

metrics.processed('emails') // 1
metrics.failed() // 1
metrics.averageRuntime('emails') // 100
metrics.throughput('emails') // jobs per minute within the window
metrics.forQueue('emails') // { queue, processed, failed, averageRuntimeMs, averageWaitMs, throughputPerMinute }
metrics.snapshot() // { at, overall, queues }