qr-ts
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

qr-ts

GitHub top language Build LICENSE

Create QR code on HTML canvas.

The main purpose of creating this library is learning TypeScript, different build tools and the QR code algorithm.

For production usage, please choose node-qrcode.

The original version is on legacy branch, which was developed during an undergraduate web-developing course.

Installation

yarn add qr-ts

Usage

Browser

<body>
<div id="main"></div>
<script type="application/javascript" src="node_modules/qr-ts/dist/browser/index.js"></script>
<script>
  const code = qr.renderOnCanvas(qr.generate("test"), "output");
  const prev = document.getElementById("output");
  if (prev != null) prev.replaceWith(code);
  else document.getElementById("main").appendChild(code);
</script>
</body>

CommonJS

const qr = require("qr-ts");
// This prints out the instance of QR class, see docs for more info
console.log(qr.generate("test")); 

run with node index.js

ESM/TypeScript

import * as qr from "qr-ts";
console.log(qr.generate("test")); // same as above

run with esm or ts-node

i.e. node -r esm index.mjs or ts-node index.ts

Deployment

Documentations

Readme

Keywords

Package Sidebar

Install

npm i qr-ts

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

1.96 MB

Total Files

94

Last publish

Collaborators

  • samarium