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

@johnhenry/math-plus-telemetry

v0.0.3

Published

Shared event schema + sink registry for math-plus (issue #10) — a stable stream any UI can consume later, with a zero-cost no-op default

Readme

@johnhenry/math-plus-telemetry

npm version license

Shared event schema + sink registry for the math-plus family (issue #10): a stable stream any UI can consume later, with a zero-cost no-op default. Zero runtime dependencies.

The differentiated panel this eventually enables isn't loss curves (TensorBoard already does those well) — it's JS↔WASM memory residency and copy accounting: which tensors live in linear memory and how many bytes cross the boundary per step. docs/spikes/wasm-baseline.md measured this exact cost causing a 4x swing that was invisible until benchmarked; Python tooling has no equivalent because NumPy never crosses that boundary.

Install

npm install @johnhenry/math-plus-telemetry

Quick start

import { setSink, hasSink, metric, type TrainingEvent } from "@johnhenry/math-plus-telemetry";

const events: TrainingEvent[] = [];
setSink((e) => events.push(e)); // install a collector
hasSink(); // true

metric("r1", 3, "loss", 0.42); // -> { type: "metric", runId: "r1", step: 3, name: "loss", value: 0.42, time: ... }

setSink(null); // restore the no-op default

Consuming what siblings emit — installing a sink is all it takes:

import { setSink } from "@johnhenry/math-plus-telemetry";

setSink((e) => console.log(e.type, e));

// tensor-autograd: backward() emits a "trace" span (name "backward",
// category "autograd"); every optimizer's step() emits "optim/gradNorm".
// tensor-wasm: the arena allocator emits "wasm/alloc.bytes" and
// "wasm/alloc.calls" per allocation.

Event schema

TrainingEvent is a discriminated union on type:

| type | Fields | |---|---| | run.start | runId, time, config, environment? | | metric | runId, step, time, name, value | | tensor.summary | runId, step, name, tensor: TensorSummary | | artifact | runId, step?, name, kind (checkpoint/image/audio/table/json), ref | | trace | runId, step, spans: [{ name, start, duration, category }] |

TensorSummary carries shape/dtype/device plus stats (min/max/ mean/std/finite fraction) and an optional histogram. It structurally cannot carry raw values — emit summaries, never tensor dumps, by default.

API

  • setSink(sink | null) — install a sink; null restores the no-op.
  • hasSink() — whether a real sink is installed.
  • emit(event) — raw emission.
  • Convenience emitters: startRun, metric, tensorSummary, artifact, trace.
  • timed(runId, step, spanName, category, fn) — run fn, emitting a trace span; when no sink is installed it skips even the performance.now() calls.

How "zero-cost" actually works

The default sink is a real empty function (null-object pattern), so emit() is an unconditional call with no branch. The real savings come from producers guarding payload construction with hasSink() — e.g. the optimizers only compute the global gradient L2 norm when a sink exists, and tensor-wasm's per-alloc metrics stay exactly zero-cost on the zero-allocation ...Into path (issue #3) when unused.

Things to know before relying on it

  • Single global slot, not a list. setSink replaces the previous sink silently; two consumers cannot coexist, and there is no unsubscribe token. In tests, always setSink(null) in a finally/afterEach.
  • Installing a sink switches on real work globally. hasSink() is a global check: a sink installed for loss curves also enables optim's grad-norm computation and the WASM allocator's per-alloc metric pair.
  • Two time bases. startRun/metric stamp Date.now(); timed() spans use performance.now(). trace.spans[].start is not comparable to metric.time.
  • tensor-wasm hardcodes runId: "wasm" with the alloc counter as step — its metrics won't correlate with an autograd run's runId/step.

Provenance

Part of the math-plus monorepo — the engineering side of the @johnhenry/math family. Docs for the whole family: https://opensource.johnhenry.me/math/.