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

@raptorqr/core

v0.1.1

Published

Protocol, packetization, FEC, QR encode/decode APIs for RaptorQR

Readme

@raptorqr/core

Protocol, packetization, FEC, QR encode/decode, GIF, and reconstruction APIs for RaptorQR.

Use this package for application code. It wraps the generated WASM package, owns the transport packet format, and keeps browser/Node loading details out of higher-level callers.

Entrypoints

import { ... } from '@raptorqr/core';
import { ... } from '@raptorqr/core/browser';
import { ... } from '@raptorqr/core/node';

Use the root entrypoint for environment-neutral protocol, FEC, sender, GIF, and reconstruction helpers.

Use @raptorqr/core/browser when browser-only QR rendering/decoding is needed.

Use @raptorqr/core/node from Node or the CLI. It initialises fast_qr from filesystem/package WASM bytes and exposes terminal-friendly QR matrix rendering.

Subpath imports are available for:

@raptorqr/core/fec/*
@raptorqr/core/gif/*
@raptorqr/core/preprocess/*
@raptorqr/core/protocol/*
@raptorqr/core/qr/*
@raptorqr/core/reconstruct/*
@raptorqr/core/sender/*
@raptorqr/core/wasm/*

Send With RaptorQ

RaptorQ is the primary sender path for new transfers.

import { DEFAULT_RAPTORQ_REPAIR_PERCENT } from '@raptorqr/core/fec/codec';
import { MAX_PAYLOAD_SIZE } from '@raptorqr/core/protocol/constants';
import { packetizeRaptorQ } from '@raptorqr/core/sender/raptorq_packetizer';

const bytes = new Uint8Array([1, 2, 3]);

const result = await packetizeRaptorQ(
  bytes,
  false,                 // isText
  true,                  // compress when it helps
  'document.pdf',        // optional filename for file transfers
  'application/pdf',     // optional MIME type for file transfers
  {
    maxTransportPayloadSize: MAX_PAYLOAD_SIZE,
    repairPercent: DEFAULT_RAPTORQ_REPAIR_PERCENT,
  },
);

for (const packet of result.packets) {
  // Render each transport packet as a QR symbol.
}

result.packets are complete RaptorQR transport packets: 8-byte header, RaptorQ payload, and CRC32C trailer.

Important result fields:

result.packets;          // Uint8Array[] ready for QR rendering
result.sourcePacketIndices; // canonical indexes of systematic source packets
result.repairPacketIndices; // canonical indexes of RaptorQ repair packets
result.totalGenerations; // RaptorQ packet count in this path
result.sourceGenerations;// estimated source packet count
result.dataLength;       // preprocessed payload length
result.isCompressed;     // whether deflate-raw was applied
result.symbolSize;       // transport payload size used by the RaptorQ codec

Schedule RaptorQ Playback

Playback scheduling changes packet order without copying or modifying packet bytes.

import {
  createRaptorQPlaybackOrders,
  type RaptorQPlaybackStrategy,
} from '@raptorqr/core/sender/raptorq_playback';

const strategy: RaptorQPlaybackStrategy = 'balanced';
const orders = createRaptorQPlaybackOrders(
  result.sourcePacketIndices,
  result.repairPacketIndices,
  strategy,
);

const firstLivePass = orders.initialOrder.map((index) => result.packets[index]!);
const repeatedPass = orders.loopOrder.map((index) => result.packets[index]!);

fast-start uses source-first ordering for every pass. balanced uses a source-first initial pass and evenly interleaved repeated passes. even-spread interleaves source and repair packets from the first pass. The interleave ratio is derived from the packets actually generated by the configured repair rate.

Decode RaptorQ Packets

Use the packet parser to validate the transport wrapper, then pass each RaptorQ payload to the decoder.

import { RaptorQWasmDecoder } from '@raptorqr/core/fec/raptorq_wasm';
import { parsePacket } from '@raptorqr/core/protocol/packet';

const first = parsePacket(receivedPackets[0]!);
const decoder = await RaptorQWasmDecoder.create(
  first.header.dataLength,
  first.payload.length,
);

let decoded: Uint8Array | null = null;

for (const encoded of receivedPackets) {
  const packet = parsePacket(encoded);
  decoded = decoder.push(packet.payload);
  if (decoded) break;
}

If first.header.compressed is true, inflate the decoded preprocessed payload before presenting it. File metadata is preserved by the sender preprocessing layer.

Render QR Codes

Browser:

import { renderQRCodeImageData } from '@raptorqr/core/browser';

const imageData = await renderQRCodeImageData(
  packet,
  10,          // QR version
  'M',         // ECC level
  4,           // pixels per module
  'fast-qr-wasm',
);

Node/CLI:

import { encodeQRCodeMatrix } from '@raptorqr/core/node';

const matrix = await encodeQRCodeMatrix(packet, 10, 'M');

matrix is boolean[][], where true is a dark QR module.

Decode QR Codes

Browser decoding is exposed from the QR modules:

import { decodeQRFromCanvas } from '@raptorqr/core/qr/qr_decode';

const decoded = await decodeQRFromCanvas(imageData);
if (decoded) {
  const bytes = decoded.bytes;
}

Legacy JS RLNC

The JS RLNC sender path is deprecated and is never used as a RaptorQ fallback. It remains available only through the explicit legacy entrypoint:

import {
  packetizeLegacyRlnc,
  scheduleLegacyRlncFrames,
} from '@raptorqr/core/sender/legacy_rlnc';

Keep new sender code on packetizeRaptorQ. The legacy module is intentionally isolated so it can be removed later without touching the RaptorQ path.