Social Media Photo by Risto Kokkonen on Unsplash
Based on @zxing/library, this module exports a scan({ facingMode = 'environment' })
or write(text[, options])
async utilities that helps users finding a QR Code and grab its result as data, or show one on any page.
The facingMode property is described on MDN.
// pre-bundled file @ https://cdn.jsdelivr.net/npm/@webreflection/qrcode/dist.js
import { scan, write } from '@webreflection/qrcode';
const result = await scan();
// result.text, result.bytes, result.format
console.log(result);
// regenerate the QR code (SVG)
document.body.appendChild(
await write(result.text)
// pass { canvas } element to have
// an image drawn in it instead
);
The LICENSE is the same used in @zxing/library
as I haven't added/done much else in here, just re-packaged and added minimalistic logic to help scanning.