Skip to content
This repository has been archived by the owner on Dec 17, 2022. It is now read-only.
/ qr-ts Public archive

A simple typescript library for generating QR code

License

Notifications You must be signed in to change notification settings

Samarium150/qr-ts

Repository files navigation

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