qr-ts
v1.0.3
Published
Create QR code on HTML canvas
Downloads
16
Readme
qr-ts
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