New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@primecode/async-qrcode

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@primecode/async-qrcode

Async QR code generator, C++ implementation

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29
increased by7.41%
Maintainers
1
Weekly downloads
 
Created
Source

@primecode/async-qrcode

Async QR code generator, C++ implementation

The typical use case for this high speed Node.js module is to convert data-strings in QR code - svg. C++ AsyncWorker is used to perform non blocking task for generation of svg image ( qr code ) in another thread.

Most modern macOS, Windows and Linux systems running Node.js v10+ do not require any additional install or runtime dependencies.

  • Installation
  • Usage
  • Styling
  • API
  • Credits

Installation

Inside your project folder do:

npm install --save @primecode/async-qrcode

Usage

NodeJS

Require the module @primecode/async-qrcode

const { QrCode, Types, Ecl } = require('@primecode/async-qrcode');

QrCode.generate({
  data: "string to transform",
  border: 2,
  type: Types.ROUND,
  ecl: Ecl.MEDIUM,
  minVersion: 1,
  maxVersion: 40,
  mask: 0,
  boostEcl: false,
  color: '#000',
  background:'#fff'
}).then((svg) => {
  console.log(svg) //SVG String
}).catch((e) => {
  console.log(e);
});

QrCode.generate({
  data: "another string to transform",
  type: Types.SQUARE,
}).then((svg) => {
  console.log(svg) //SVG String
}).catch((e) => {
  console.log(e);
});

Typescript

Import the module @primecode/async-qrcode

import { QrCode, Ecl, Types } from '@primecode/async-qrcode';

// With promises
QrCode.generate({
  data: "string to transform",
  border: 2,
  type: Types.ROUND,
  ecl: Ecl.MEDIUM,
  minVersion: 1,
  maxVersion: 40,
  mask: 0,
  boostEcl: false,
  color: '#000',
  background:'#fff'
})
.then(url => {
  console.log(url)
})
.catch(err => {
  console.error(err)
});

QrCode.generate({
  data: "another string to transform",
  type: Types.SQUARE,
}).then((svg) => {
  console.log(svg) //SVG String
}).catch((e) => {
  console.log(e);
});

Error correction level

Error correction capability allows to successfully scan a QR Code even if the symbol is dirty or damaged. Four levels are available to choose according to the operating environment.

Higher levels offer a better error resistance but reduce the symbol's capacity.
If the chances that the QR Code symbol may be corrupted are low (for example if it is showed through a monitor) is possible to safely use a low error level such as Low or Medium.

Possible levels are shown below:

LevelError resistance
L (Low)~7%
M (Medium)~15%
Q (Quartile)~25%
H (High)~30%

The percentage indicates the maximum amount of damaged surface after which the symbol becomes unreadable.

Styling

SQUARE

{
  data: "string to transform",
  type: Types.SQUARE,
}

ROUND

{
  data: "string to transform",
  type: Types.ROUND,
}

CIRCLE

{
  data: "string to transform",
  type: Types.CIRCLE,
}

COLORED

{
  data: "string to transform",
  color: '#c11616',
  background:'#d2e0f1',
  type: Types.ROUND,
}

API

generate([options])

Generate QR Code svg.

See generate.

options
{
        data: string, //Text to encode
        border: number, // Border separator in svg image
        type: number, // Types.SQUARE | Types.ROUND | Types.CIRCLE
        ecl: number, // Ecl.LOW | Ecl.MEDIUM | Ecl.QUARTILE | Ecl.HIGH,
        minVersion: number, // Value between 1 - 40: Increase the error correction level
        maxVersion: number, // Value between 1 - 40: Increase the error correction level
        mask: number, // User can specify mask pattern manually, value between 0 - 7
        boostEcl: boolean, // User can specify absolute error correction level, or allow the library to boost it if it doesn't increase the version number
        color: string, // Dot color in image
        background: string // SVG bacground color
}
returns

Type: Promise<String>

Credits

Software is based on "QRCode c++ library" - Project Nayuki https://www.nayuki.io/page/qr-code-generator-library.

License - MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

  • The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

  • The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the Software or the use or other dealings in the Software.

Keywords

FAQs

Package last updated on 26 Aug 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc