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

@z-base/qr

v1.0.2

Published

Simple managed QR display, print, and scan utilities for browser frontends.

Readme

npm version CI codecov license

qr

A simple, managed QR toolset for browser frontends. It gives SPAs a small API to display, print, and scan QR codes with typed errors and zero framework lock-in.

Compatibility

  • Runtimes: modern browsers (primary target); Node >= 18 for build/test workflows.
  • Module format: ESM-only.
  • Required browser APIs: document, <dialog>, Blob, URL.createObjectURL, and camera/media APIs for scanning.
  • TypeScript: bundled types.

Goals

  • Minimal API for common frontend QR workflows.
  • Managed UI flows for display, print, and scan.
  • Typed, explicit errors for predictable app-level handling.
  • Works cleanly in SPA environments without framework-specific code.

Installation

npm install @z-base/qr
# or
pnpm add @z-base/qr
# or
yarn add @z-base/qr

Usage

import { QR, QRError } from '@z-base/qr'

QR.display('https://example.com')
QR.print('https://example.com')

try {
  const value = await QR.scan()
  console.log(value)
} catch (error) {
  if (error instanceof QRError) {
    console.error(error.code, error.message)
  } else {
    console.error(error)
  }
}

You can also import function-level APIs directly:

import { display, print, scan } from '@z-base/qr'

API

QR.display(value: string): void

  • Opens a modal dialog with a generated QR image for value.
  • Closes on user interaction (pointer/mouse/touch/key) after a short guard delay.

QR.print(value: string): void

  • Opens a new tab with an A4 print layout of ID-1 sized QR cards.
  • Triggers the browser print dialog automatically.

QR.scan(): Promise<string>

  • Opens a modal camera scanner.
  • Resolves with decoded QR payload.
  • Rejects with QRError when scanning cannot proceed or is cancelled.
  • Uses the same short interaction guard delay pattern as display() before close listeners activate.

Errors

The package throws QRError with semantic code values:

  • VALUE_IS_NOT_A_STRING
  • QR_ENCODE_FAILED
  • NO_CAMERA_AVAILABLE
  • CAMERA_CHECK_FAILED
  • SCAN_CANCELLED
  • SCAN_START_FAILED

Runtime Notes

  • This package is browser-first and UI-driven.
  • scan() requires camera permission and a compatible device/browser.
  • print() relies on popup/new-tab behavior and browser print support.
  • Dialog/content/backdrop fade transitions are best-effort and may vary slightly by engine capabilities.

Tests

  • Suite: unit + integration (Node), E2E (Playwright)
  • Matrix: Chromium / Firefox / WebKit + mobile emulation (Pixel 5, iPhone 12)
  • Coverage: c8 - 100% statements/branches/functions/lines

License

Apache-2.0