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/oat-qr-fountain

v0.1.1

Published

LT fountain coding + QR frame render/decode for optical artifact transport

Readme

@johnhenry/oat-qr-fountain

npm version license

LT (Luby Transform) fountain coding plus QR frame render/decode — the wire format underneath <optical-send> and <optical-receive>. An artifact becomes an endless stream of independently-decodable packets: the receiver doesn't need every frame, or frames in order, just enough of them. That's what makes the optical link tolerant of a shaky camera, glare, and missed frames.

npm install @johnhenry/oat-qr-fountain

Quick start (pure fountain round trip, no QR involved)

import {
  prepareSource,
  generatePackets,
  counterSeeds,
  FountainDecoder
} from '@johnhenry/oat-qr-fountain';

const bytes = new TextEncoder().encode('some artifact bytes'.repeat(50));
const artifactId = new Uint8Array(16); // 16 bytes identifying this session

const source = prepareSource(bytes, 128, artifactId); // 128-byte blocks
const decoder = new FountainDecoder(source.sourceBlockCount, source.blockSize, source.totalLength);

for (const packet of generatePackets(source, counterSeeds())) {
  if (decoder.addPacket(packet)) break; // true once the transfer completes
}

const reconstructed = decoder.reconstruct();

generatePackets is an infinite generator — it never runs out. Loop until the decoder reports complete (or your own frame budget runs out), not until the generator does, because it won't.

The traps

  • This layer verifies nothing. Reconstruction gives you bytes, not trust. A corrupted packet that slips through XOR reassembly produces a corrupted reconstruction — it's @johnhenry/oat-protocol's digest and signature verification that catches it. Never treat reconstruct() output as verified.
  • artifactId must be exactly 16 bytes — encodePacket throws otherwise.
  • Duplicates and foreign packets are cheap, mismatched sessions are not. The decoder silently ignores duplicate seeds, but addPacket throws on a packet whose sourceBlockCount/blockSize don't match the session — catch it if you're feeding frames from a channel that can interleave transfers.
  • Smaller blocks tolerate more loss but need more frames. blockSize is the loss-resilience/throughput dial; the reference elements use ~200-byte QR frames and land around 700 KB/min at 12fps after the ~30% redundancy the fountain code adds.
  • Randomness must agree. Encoder and decoder derive each packet's neighbor set from the packet's seed via the same PRNG (mulberry32) — pass counterSeeds() (or any deterministic seed source) to generatePackets for reproducible fixtures.

Entrypoints — import only the half you use

qrcode (the encoder) and jsqr (the decoder) are both large, and almost no application needs both: a sender only renders, a receiver only scans. Three subpath entrypoints keep the other one out of your bundle entirely.

| Entrypoint | Contains | Pulls in | | --- | --- | --- | | @johnhenry/oat-qr-fountain/fountain | packet framing, LT code, encoder/decoder, PacketCycle | neither | | @johnhenry/oat-qr-fountain/encode | renderPacketToCanvas, renderPacketToDataUrl | qrcode | | @johnhenry/oat-qr-fountain/decode | decodePacketFromImageData | jsqr | | @johnhenry/oat-qr-fountain | all of the above | both, minus whatever your bundler shakes out |

// sender: renders frames, never scans them
import { prepareSource, generatePackets } from '@johnhenry/oat-qr-fountain/fountain';
import { renderPacketToCanvas } from '@johnhenry/oat-qr-fountain/encode';

// receiver: scans frames, never renders them
import { FountainDecoder } from '@johnhenry/oat-qr-fountain/fountain';
import { decodePacketFromImageData } from '@johnhenry/oat-qr-fountain/decode';

Measured with esbuild (minified, gzip -9), an encode-only import is 9.6 KB and a decode-only import 46.3 KB; before the split both were ~54 KB, because a single module imported qrcode and jsqr at top level and neither of those packages declares sideEffects, so no bundler could prove the unused half unreachable. The package root now tree-shakes correctly too — the subpaths matter most for Node and for bundlers that ignore sideEffects, where nothing is shaken out at all.

API surface

| Area | Exports | | --- | --- | | Fountain coding | prepareSource, generatePackets, counterSeeds, FountainDecoder (addPacket, isComplete, progress, packetsSeen, reconstruct) | | Packet framing | OatPacket, encodePacket, decodePacket (compact fixed-header binary — decodePacket returns null for malformed/foreign frames rather than throwing) | | QR rendering | renderPacketToCanvas, renderPacketToDataUrl, PacketCycle (frame scheduler), decodePacketFromImageData | | LT internals | mulberry32, robustSolitonTable, sampleDegree, chooseNeighbors, neighborsForSeed, xorInPlace |

Most applications never touch this package directly — <optical-send> / <optical-receive> (and @johnhenry/oat-sim for headless testing) wrap it. Reach for it directly when building a custom transport or codec on the same FEC layer.

Docs

Full documentation: https://opensource.johnhenry.me/oat/ — see the protocol & codecs page.

License

MIT