Socket
Socket
Sign inDemoInstall

corcojs-qrcode-sample

Package Overview
Dependencies
8
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    corcojs-qrcode-sample

A sample corcojs qr code generator implementation in JavaScript.


Version published
Weekly downloads
4.9K
increased by245700%
Maintainers
1
Install size
263 kB
Created
Weekly downloads
 

Readme

Source

QR Code Generator

Getting Started

  1. Include corcojs-qrcode.js in your html.
  2. Prepare a place holder.
  3. Generate QR and render it.
<script type="text/javascript" src="corcojs-qrcode.js"></script>
<div id="placeHolder"></div>
var typeNumber = 4;
var errorCorrectionLevel = 'L';
var qr = qrcode(typeNumber, errorCorrectionLevel);
qr.addData('Hi!');
qr.make();
document.getElementById('placeHolder').innerHTML = qr.createImgTag();

API Documentation

corcojs-QRCodeFactory

corcojs-qrcode(typeNumber, errorCorrectionLevel) => corcojs-QRCode

Create a corcojs-QRCode Object.

ParamTypeDescription
typeNumbernumberType number (1 ~ 40), or 0 for auto detection.
errorCorrectionLevelstringError correction level ('L', 'M', 'Q', 'H')
corcojs-qrcode.stringToBytes(s) : number[]

Encodes a string into an array of number(byte) using any charset. This function is used by internal. Overwrite this function to encode using a multibyte charset.

ParamTypeDescription
sstringstring to encode

corcojs-QRCode

addData(data, mode) => void

Add a data to encode.

ParamTypeDescription
datastringstring to encode
modestringMode ('Numeric', 'Alphanumeric', 'Byte'(default), 'Kanji')
make() => void

Make a QR Code.

getModuleCount() => number

The number of modules(cells) for each orientation. [Note] call make() before this function.

isDark(row, col) => boolean

The module at row and col is dark or not. [Note] call make() before this function.

ParamTypeDescription
rownumber0 ~ moduleCount - 1
colnumber0 ~ moduleCount - 1
createDataURL(cellSize, margin) => string
createImgTag(cellSize, margin, alt) => string
createSvgTag(cellSize, margin) => string
createTableTag(cellSize, margin) => string
createASCII(cellSize, margin) => string

Helper functions for HTML. [Note] call make() before these functions.

ParamTypeDescription
cellSizenumberdefault: 2
marginnumberdefault: cellSize * 4
altstring(optional)
createSvgTag(opts) => string
ParamTypeDescription
optsobjectdefault: {}
opts.cellSizenumberdefault: 2
opts.marginnumberdefault: cellSize * 4
opts.scalablebooleandefault: false
renderTo2dContext(context, cellSize) => void

--

This implementation is based on JIS X 0510:1999.

The word 'QR Code' is registered trademark of DENSO WAVE INCORPORATED
http://www.denso-wave.com/corcojs-qrcode/faqpatent-e.html

Keywords

FAQs

Last updated on 11 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc