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

@ashaffah/barcodes

v0.1.4

Published

Universal bar/QR code generation library for TypeScript & JavaScript — zero dependencies, works in browser, Node and Deno.

Readme

@ashaffah/barcodes

A universal bar/QR code generation library for TypeScript & JavaScript. Zero runtime dependencies, works in the browser, Node and Deno. A faithful port of the Rust barcodes crate — every symbology is verified against real decoders (ZXing, zbar, dmtxread) or, for the 4-state postal codes, bit-for-bit against zint.

Features

  • 17 symbologies: linear, 2D and postal
  • Zero runtime dependencies
  • SVG output built in (toSVG()); raw module data for custom rendering
  • ESM + CJS, fully typed
  • Universal: browser, Node, Deno

Install

npm install @ashaffah/barcodes

Usage

Every encoder exposes a static encode() that returns a Barcode:

import { Ean13, QrCode, toSVG } from "@ashaffah/barcodes";

// Linear
const ean = Ean13.encode("5901234123457");
const svg = ean.toSVG(); // -> "<svg ...>...</svg>"
console.log(ean.data.kind); // "linear"

// QR (auto numeric/alphanumeric/byte selection)
const qr = QrCode.encode("https://example.com");
console.log(qr.data.kind); // "matrix"

Raw modules

Barcode.data is a discriminated union you can render however you like:

const qr = QrCode.encode("HELLO");
if (qr.data.kind === "matrix") {
  const { modules, width, height } = qr.data; // modules[y][x] === true → dark
}

const bc = Ean13.encode("5901234123457");
if (bc.data.kind === "linear") {
  const { bars, height } = bc.data; // bars[i] === true → dark bar
}

SVG options

ean.toSVG({ moduleSize: 6, foreground: "#111", background: "#fff", linearQuiet: 20 });

QR options

QrCode.encode() uses sensible defaults (ECC Medium, automatic version and mask). For control, pass options or use the native API:

import { QrCode, Ecc } from "@ashaffah/barcodes";

QrCode.encode("payload", { ecl: Ecc.HIGH, minVersion: 5, mask: 3 });

// Native API with getModule():
const q = QrCode.encodeText("payload", { ecl: Ecc.QUARTILE });
q.getModule(0, 0); // boolean
q.version; // 1..40

Supported symbologies

| Symbology | Class | Verified with | | --------------------------- | ------------ | ------------------ | | EAN-13 | Ean13 | ZXing + zbar | | EAN-8 | Ean8 | ZXing + zbar | | UPC-A | UpcA | ZXing + zbar | | UPC-E | UpcE | ZXing + zbar | | Code 128 (A/B/C) | Code128 | ZXing + zbar | | Code 39 | Code39 | ZXing + zbar | | Code 93 | Code93 | ZXing + zbar | | Codabar | Codabar | ZXing + zbar | | ITF (Interleaved 2 of 5) | Itf | ZXing + zbar | | GS1-128 | Gs1_128 | ZXing + zbar | | GS1 DataBar Omnidirectional | DataBar | ZXing + zbar | | QR Code (Model 2) | QrCode | ZXing + zbar | | Data Matrix (ECC 200) | DataMatrix | ZXing + dmtxread | | PDF417 | Pdf417 | ZXing | | Aztec Code | Aztec | ZXing | | USPS Intelligent Mail (IMb) | Imb | zint + USPS vector | | Royal Mail RM4SCC | Rm4scc | zint |

Input notes

  • EAN/UPC: pass with or without the trailing check digit — it is computed and validated automatically.
  • Codabar: A/B start/stop guards are added automatically; pass bare data.
  • GS1-128: parenthesized AI format, e.g. Gs1_128.encode("(01)0123...").
  • DataBar: 13- or 14-digit GTIN.
  • IMb: Imb.encode("01234567094987654321-01234567891") (20-digit tracker, optional - + 0/5/9/11-digit routing code). Postal 4-state codes render as a 3-row matrix (ascender / tracker / descender).

Errors

Encoders throw EncodeError (with a .kind of "InvalidInput", "InvalidCharacter" or "DataTooLong") on invalid input.

License

MIT