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

performance-helpers

v1.0.3

Published

Performance toolbox

Readme

performance-helpers

npm version npm downloads GitHub stars License: MIT

logo

Highly tuned lightweight toolbox for high-performance Node/browser code: zero-copy buffer helpers for worker messaging, an environment-agnostic worker abstraction (WorkerAgnostic), an LRU TTL cache with a memoizer, a fully-featured worker pool wrapper, a tiny runtime debug logger, and much more:

Caching

Parallelizing

Logging

Utils

When to use what

Check the Quick Guide

Quick start

Requirements: Node.js and npm.

Install dependencies:

npm install

Install the package from npm for direct use in your project:

npm install --save performance-helpers
# or
yarn add performance-helpers

Run tests:

npm run test

Run coverage (v8):

npm run test:coverage

Quality bar

Helpers intended to be Tier 1 in this repository should meet a consistent bar:

  • dedicated guide plus README coverage
  • concise JSDoc for public constructor options and methods
  • focused regression tests for edge cases and failure paths
  • repo-wide coverage stays above the Vitest thresholds, and Tier 1 promotion work raises the helper's own file coverage to the same bar
  • no known open correctness bugs in the public contract

Helpers that remain larger or more experimental can stay as advanced helpers, but Tier 1 helpers should be predictable, narrow in scope, and cheap to maintain.

Current classification notes:

  • PowerPool is an advanced helper by design. It has a broader surface area than the narrow Tier 1 primitives, so coverage and maintenance expectations should be interpreted with that scope in mind.
  • PowerRateLimit is treated as a metric outlier for function coverage. Its public behavior and rollback paths are heavily covered; the remaining low function number is not currently considered a release blocker on its own.
  • Promotion work should prioritize public correctness, narrow APIs, and edge-case coverage before chasing residual coverage misses in broad orchestration helpers.

Build (Vite):

npm run build

Generate docs (Typedoc):

npm run docs

Usage examples

Import everything from the package entry:

import {
  o2b,
  o2u8,
  u82o,
  b2o,
  PowerCache,
  PowerMemoizer,
  PowerTimedCache,
  PowerPool,
  PowerLogger,
  PowerThrottle,
  PowerSlidingWindow,
  PowerRateLimit,
  PowerQueue,
  PowerSemaphore,
  PowerDefer,
  PowerTTLMap,
  nowMs,
  measureSync,
  measureAsync,
  PowerCircuit,
  PowerRetry,
  PowerDeadline,
  PowerHistogram,
  PowerBackpressure,
  PowerBatch,
  PowerBulkhead,
  PowerLatch,
  PowerObserver,
  PowerEventBus,
} from 'performance-helpers';

Import a single helper or utility when you want the smallest possible bundle:

import { PowerCache } from 'performance-helpers/powerCache';
import { nowMs } from 'performance-helpers/now';
import { normalizeError } from 'performance-helpers/errors';

The package is marked as side-effect free, so bundlers can treeshake unused exports from the root entry as well.

CDN usage

You can import the package directly from a CDN for quick demos. Example using unpkg (ES module support):

<script type="module">
  import { PowerMemoizer } from 'https://unpkg.com/performance-helpers@latest?module';
  const fetchUser = async (id) => fetch(`/users/${id}`).then((r) => r.json());
  const pm = new PowerMemoizer(fetchUser);
  console.log(await pm.run(1));
</script>

Or using jsDelivr:

<script type="module">
  import { PowerCache } from 'https://cdn.jsdelivr.net/npm/performance-helpers@latest/dist/index.js';
  const cache = new PowerCache();
  cache.set('a', 1);
  console.log(cache.get('a'));
</script>

UMD example (script tag):

<script src="https://unpkg.com/performance-helpers@latest/dist/performance-helpers.umd.js"></script>
<script>
  // UMD builds attach a global. Use the global that your build exposes.
  const lib = window.PerformanceHelpers;
  const { PowerCache } = lib || {};
  const cache = new PowerCache();
  cache.set('a', 2);
  console.log(cache.get('a'));
</script>

Worker support: Node and the browser

WorkerAgnostic (re-exported from performance-helpers/WorkerAgnostic) gives you one transparent API for spawning and talking to a worker whether you are on Node.js (worker_threads) or in a browser / Web Worker context (Web Worker). PowerPool uses it under the hood, so the pool is environment-agnostic too.

import WorkerAgnostic, { detectEnv, preloadNode } from 'performance-helpers/WorkerAgnostic';

console.log(detectEnv()); // 'node' | 'browser' | 'webworker' | 'unknown'

const worker = new WorkerAgnostic('./myWorker.js', { type: 'module' });
worker.addEventListener('message', (ev) => console.log(ev.data));
worker.postMessage({ hello: 'world' });
await worker.terminate();

What is transparent:

  • Worker creation from a path string, a factory function, or a constructor — the correct native worker is chosen for the runtime.
  • The event model (addEventListener/removeEventListener and Node-style on/off) and postMessage(message, transfer) transfer lists.
  • Message payloads are normalized to { data } (Node delivers the value directly; Web Workers deliver a MessageEvent whose payload is on .data).
  • terminate() always returns a Promise.

Caveats you should know:

  1. Pure-ESM Node + string-source workers need one await preloadNode() call before constructing the worker (or set globalThis.Worker, or pass a factory function). This is the only non-transparent seam. CJS/vitest, factory-function sources, and all browser paths do not need it.

    import WorkerAgnostic, { preloadNode } from 'performance-helpers/WorkerAgnostic';
    await preloadNode();
    const worker = new WorkerAgnostic('./myWorker.js', { type: 'module' });
  2. Transparency covers creation and messaging, not your worker's internals. WorkerAgnostic spawns the correct native worker and unifies the API, but the worker source file you write must still be valid for its target runtime (Node worker_threads uses parentPort; a browser worker uses self.onmessage). It does not transpile worker code between environments.

  3. Browser usage requires a bundler or an ESM CDN. The package ships as raw ESM source (no prebuilt UMD/browser bundle is required for the worker layer). In a bundler or a <script type="module"> from a CDN, WorkerAgnostic resolves the worker URL against import.meta.url / document.currentScript / location.href and falls back to the plain string.

API docs

See the full API documentation

License

MIT.