Skip to content

wawrzy/qrcode-wasm

Repository files navigation

qrcode-wasm

DEMO

Web Assembly Qrcode generator

Usage

import { QrCodeWasm } from 'qrcode-wasm';

const generator = new QrCodeWasm({ debug: true });

generator.encode('HELLO WORLD').then(async (buffer) => {
	// buffer = Int32Array
	// [Side size of Matrix (total size = Side Size * Side Size), 1, 0, 1, 0, 0 ....]
	// 1 = Dark Module
	// 0 = White Module

	const dataURL = await generator.png(200 /* PNG size in Pixel */);
});

Webpack

If you want to use this package with webpack you must include the main.wasm file in your build output. You can customize the name or path to this file with the wasmPath option.

const generator = new QrCodeWasm({ wasmPath: 'scripts/custom.wasm' });

Errors

CODE DESCRIPTION
ERR_ENC Message encoding not supported
ERR_TLONG Message is too long

Build with

Typescript

Assemblyscript

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published