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

postwire

v0.1.0

Published

High-throughput, reliable, ordered stream abstraction over any postMessage boundary

Readme

postwire

A high-throughput, reliable, ordered stream abstraction over any postMessage boundary — iframe, web worker, service worker, MessageChannel.

Drop it into your existing postMessage wiring. Get stream semantics with backpressure, ordering, typed errors, and feature-detected fast paths.

Install

# npm
npm install postwire

# pnpm
pnpm add postwire

# JSR
npx jsr add @postwire/core

Quickstart

// main.ts — initiator side (parent page / main thread)
import { createChannel, createStream, createWorkerEndpoint } from "postwire";

const worker = new Worker("./worker.js", { type: "module" });
const endpoint = createWorkerEndpoint(worker);
const channel = createChannel(endpoint);

await channel.capabilityReady;

const { writable } = createStream(channel);
const writer = writable.getWriter();

for (const chunk of chunks) {
  await writer.write(chunk);
}
await writer.close();
// worker.ts — responder side
import { createChannel, createStream, createWorkerEndpoint } from "postwire";

const endpoint = createWorkerEndpoint(self as DedicatedWorkerGlobalScope);
const channel = createChannel(endpoint, { role: "responder" });

channel.onStream(() => {
  const { readable } = createStream(channel);
  readable.pipeTo(new WritableStream({
    write(chunk) { console.log("received", chunk); }
  }));
});

What does this do?

  • Reliable + ordered delivery — credit-based flow control with a reorder buffer; out-of-order frames are reassembled before surfacing to the consumer
  • Backpressure end-to-end — WHATWG Streams desiredSize wired to the credit window; pipeTo/pipeThrough stall the writer when the reader is slow
  • Three API surfaces — low-level send/onChunk/close, Node-style EventEmitter, or WHATWG { readable, writable } pair
  • Four endpoint adaptersWorker, MessagePort, Window (cross-origin iframe), ServiceWorker/Client
  • Feature-detected fast paths — transferable ArrayBuffer (zero-copy), structured-clone fallback, opt-in SharedArrayBuffer ring (cross-origin-isolated only)
  • Relay topologycreateRelayBridge forwards frames between two channels without reassembly; credits propagate end-to-end
  • Multiplex mode — multiple concurrent logical streams over one endpoint; per-stream credit windows are independent
  • Strict CSP compatible — no eval, no new Function; WASM path is opt-in with explicit caller CSP relaxation
  • Lifecycle safety — BFCache (pagehide), heartbeat for service workers, endpoint teardown (CHANNEL_DEAD/CHANNEL_FROZEN/CHANNEL_CLOSED)
  • Typed errors — every failure is a StreamError with a stable .code discriminant (see docs/errors.md)
  • Zero runtime dependencies

Documentation

| Document | Contents | |---|---| | docs/api/lowlevel.md | createLowLevelStream — the primitive all adapters compose on | | docs/api/emitter.md | createEmitterStream — Node-style EventEmitter wrapper | | docs/api/streams.md | createStream — WHATWG { readable, writable } pair | | docs/endpoints.md | Four endpoint adapters: Worker, MessagePort, Window, ServiceWorker | | docs/topology.md | Two-party, relay bridge, multiplex mode | | docs/errors.md | All StreamError.code values with recovery patterns | | docs/security.md | Origin validation, strict CSP, COOP/COEP, trust boundaries | | docs/benchmarks.md | Throughput/latency table from benchmarks/results/baseline.json | | docs/decisions.md | Architecture decision log |

Examples

| Example | Description | |---|---| | examples/01-parent-iframe | Parent sends 1 MB blob to sandboxed iframe via createStream | | examples/02-main-worker | Main thread streams data to a Worker; delivery rate logged | | examples/03-three-hop | Worker → main relay → strict-CSP iframe; live chunk counter | | examples/04-multiplex | Two concurrent streams over one MessageChannel | | examples/05-strict-csp | Sandboxed iframe receives 512 KB payload under script-src 'self' |

Run any example: cd examples/01-parent-iframe && pnpm install && pnpm dev

License

MIT