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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jswork/qrjs

v1.0.3

Published

A wrapper for qr.js.

Downloads

6

Readme

qrjs

A wrapper for qr.js.

version license size download

installation

npm install @jswork/qrjs

usage

import qrcode, { ErrorCorrectLevel, QRCode } from '@jswork/qrjs';

const qr = qrcode('afei', {
  errorCorrectLevel: ErrorCorrectLevel.H,
  typeNumber: -1,
});

with canvas

yarn add canvas

import { ErrorCorrectLevel, QRCode } from '@jswork/qrjs';
import { createCanvas } from "canvas";
import fs from "fs";

// 生成二维码
const qrcode = new QRCode(-1, ErrorCorrectLevel.H);
qrcode.addData("afei");
qrcode.make();

// 获取二维码模块的大小和数据
const size = qrcode.getModuleCount();
const cellSize = 10; // 每个模块的大小,调整这个值可以改变二维码的尺寸
const margin = 4 * cellSize; // 留白的大小

// 创建Canvas
const canvas = createCanvas(
  size * cellSize + margin * 2,
  size * cellSize + margin * 2
);
const ctx = canvas.getContext("2d");

// 绘制二维码背景
ctx.fillStyle = "#ffffff";
ctx.fillRect(0, 0, canvas.width, canvas.height);

// 绘制二维码
ctx.fillStyle = "#000000";
for (let row = 0; row < size; row++) {
  for (let col = 0; col < size; col++) {
    if (qrcode.isDark(row, col)) {
      ctx.fillRect(
        margin + col * cellSize,
        margin + row * cellSize,
        cellSize,
        cellSize
      );
    }
  }
}

// 保存为PNG文件
const out = fs.createWriteStream("qrcode.png");
const stream = canvas.createPNGStream();
stream.pipe(out);
out.on("finish", () => console.log("QR code PNG file generated: qrcode.png"));

license

Code released under the MIT license.