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

@atolljs/node

v0.1.6

Published

Node runtime adapter — node:worker_threads pools, no framework

Downloads

873

Readme

@atolljs/node

CI codecov Socket Badge

node:worker_threads runtime adapter for @atolljs/core — lets WorkerPool and connectWorker run on Node's Worker (an EventEmitter) instead of the DOM surface they expect. No framework required.

Atoll — package documentation

Install

npm install @atolljs/core @atolljs/node

Usage

// pool.ts — a WorkerPool backed by node:worker_threads
import { Worker } from 'node:worker_threads';
import { createNodePool } from '@atolljs/node';
import { counterMemory } from './counter.memory';

export const pool = createNodePool({
  // The factory may return a node:worker_threads.Worker directly — the
  // adapter wraps it, so new Worker(new URL(...)) stays bundler-detectable.
  worker: () => new Worker(new URL('./counter.worker.js', import.meta.url)),
  sharedMemory: counterMemory,
  poolSize: 4,
});
// counter.worker.ts — the worker entry; the shim binds self = parentPort
// before defineWorker's bootstrap evaluates, so import it first.
import '@atolljs/node/shim';
import { defineWorker } from '@atolljs/core';
import { counterMemory } from './counter.memory';

export const counterWorker = defineWorker({
  sharedMemory: counterMemory,
  methods: {
    increment(delta: number) {
      const next = counterMemory.count.read() + delta;
      counterMemory.count.write(next);
      return next;
    },
  },
});

API

  • createNodePool({ worker, sharedMemory?, tasks?, … }) — a WorkerPool with the adapter baked in. worker accepts a path/URL or a factory returning either a Node or DOM-style Worker.
  • createNodeWorker(nodeWorker) / NodeWorkerAdapter — wrap a Node Worker (or worker file path) for connectWorker or a hand-built WorkerPool.
  • @atolljs/node/shim — worker-side entry shim; import first so self = parentPort is bound before defineWorker's bootstrap evaluates.
  • withSharedBuffer + bindSharedBuffer — share one contract buffer across pools. Wrap a worker factory with withSharedBuffer(spawn, bufferOrThunk) so every spawn is fed pool.sharedBuffer (thunk evaluated per spawn — respawns included); the worker entry awaits bindSharedBuffer() to bind all contracts. For message-only pools whose workers read another pool's memory.
  • @atolljs/node/http — two offload topologies:
    • createHttpCluster (Node ≥ 26): the main thread accepts TCP connections with pauseOnConnect and transfers each net.Socket to a pool worker, where serveHttp feeds it into an http.Server owned by the worker — parsing, routing, and serialization all off-thread.
    • routeHttpGateway (any Node): path-level ownership — the main thread parses HTTP once and proxies matched prefixes to worker-owned internal listeners (serveHttp(app, { listen: 0 })). Pin /api/a/* to worker A, /api/b/* to worker B, serve the rest on main. WebSocket upgrades match the same prefixes and are tunneled end-to-end; for embedding into a host framework, workerHttpPorts + proxyToWorker (+proxyUpgradeToWorker on the server's upgrade event) expose the same machinery as mountable middleware (see examples/nestjs housed API). See examples/http-offload and docs/frameworks/node.md.
  • @atolljs/node/redis — shared-memory persistence via Redis (persistSharedMemory / redisMemoryAdapter): field regions mirror to a Redis hash on a version-diff flush, restore into the buffer at boot, and optionally replicate across processes over a pub/sub channel. Pass it as persistence on createNodePool (or AtollModule.registerPool) — the pool attaches it after bind and calls stop() on terminate().

Notes

  • SharedArrayBuffer works in Node with no headers — cross-origin isolation is a browser-only requirement.
  • Building a NestJS app? @atolljs/nestjs wraps this adapter in DI providers and decorator-based method offload.

Documentation