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

@slidoapp/qrcode

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slidoapp/qrcode - npm Package Compare versions

Comparing version 2.0.0-preview to 2.0.0-preview2

12

package.json
{
"name": "@slidoapp/qrcode",
"description": "QRCode / 2d Barcode api with both server side and client side support using canvas",
"version": "2.0.0-preview",
"description": "Generate Quick Response (QR) codes using JavaScript in a browser, server side code, or using a command line tool.",
"version": "2.0.0-preview2",
"author": "Ryan Day <soldair@gmail.com>",

@@ -42,5 +42,5 @@ "contributors": [

"dependencies": {
"dijkstrajs": "^1.0.1",
"pngjs": "^5.0.0",
"yargs": "^15.3.1"
"dijkstrajs": "^1.0.3",
"pngjs": "^7.0.0",
"yargs": "^17.7.2"
},

@@ -70,3 +70,3 @@ "devDependencies": {

"engines": {
"node": ">=10.13.0"
"node": ">=18"
},

@@ -73,0 +73,0 @@ "standard": {

# node-qrcode
> QR code/2d barcode generator.
> Generate Quick Response (QR) codes using JavaScript in a browser, server side code, or using a command line tool.
![build status](https://img.shields.io/github/actions/workflow/status/slidoapp/node-qrcode/build.yml?style=flat-square)
[![npm](https://img.shields.io/npm/v/%40slidoapp%2Fqrcode)](https://www.npmjs.com/package%40slidoapp%2Fqrcode)
[![npm](https://img.shields.io/npm/dt%40slidoapp%2Fqrcode.svg?style=flat-square)](https://www.npmjs.com/package%40slidoapp%2Fqrcode)
[![npm](https://img.shields.io/npm/l%40slidoapp%2Fqrcode.svg?style=flat-square)](https://github.com/slidoapp/node-qrcode/blob/main/license)
[![npm](https://img.shields.io/npm/v/%40slidoapp%2Fqrcode.svg?style=flat-square)](https://www.npmjs.com/package%40slidoapp%2Fqrcode)
[![npm](https://img.shields.io/npm/dt/%40slidoapp%2Fqrcode.svg?style=flat-square)](https://www.npmjs.com/package/%40slidoapp%2Fqrcode)
[![npm](https://img.shields.io/npm/l/%40slidoapp%2Fqrcode.svg?style=flat-square)](https://github.com/slidoapp/node-qrcode/blob/main/license)

@@ -49,3 +49,3 @@ - [Highlights](#highlights)

```
```text
Usage: qrcode [options] <input string>

@@ -77,7 +77,8 @@

```
If not specified, output type is guessed from file extension.<br>
If not specified, output type is guessed from file extension.
Recognized extensions are `png`, `svg` and `txt`.
### Browser
`node-qrcode` can be used in browser through module bundlers like [Browserify](https://github.com/substack/node-browserify) and [Webpack](https://github.com/webpack/webpack) or by including the precompiled bundle present in `build/` folder.
The `@slidoapp/qrcode` can be used in browser through module bundlers like [Browserify](https://github.com/substack/node-browserify) and [Webpack](https://github.com/webpack/webpack) or by including the precompiled bundle present in `build/` folder.

@@ -97,3 +98,3 @@ #### Module bundlers

// index.js -> bundle.js
var QRCode = require('qrcode')
var QRCode = require('@slidoapp/qrcode')
var canvas = document.getElementById('canvas')

@@ -125,6 +126,6 @@

### NodeJS
Require the module `qrcode`
Require the module `@slidoapp/qrcode`
```javascript
var QRCode = require('qrcode')
var QRCode = require('@slidoapp/qrcode')

@@ -138,3 +139,3 @@ QRCode.toDataURL('I am a pony!', function (err, url) {

```js
var QRCode = require('qrcode')
var QRCode = require('@slidoapp/qrcode')

@@ -150,3 +151,3 @@ QRCode.toString('I am a pony!',{type:'terminal'}, function (err, url) {

```javascript
import QRCode from 'qrcode'
import QRCode from '@slidoapp/qrcode'

@@ -176,3 +177,3 @@ // With promises

Higher levels offer a better error resistance but reduce the symbol's capacity.<br>
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)

@@ -192,3 +193,3 @@ is possible to safely use a low error level such as `Low` or `Medium`.

Error level can be set through `options.errorCorrectionLevel` property.<br>
Error level can be set through `options.errorCorrectionLevel` property.
If not specified, the default value is `M`.

@@ -205,6 +206,7 @@

The QR Code versions range from version **1** to version **40**.<br>
Each version has a different number of modules (black and white dots), which define the symbol's size.
For version 1 they are `21x21`, for version 2 `25x25` e so on.
Higher is the version, more are the storable data, and of course bigger will be the QR Code symbol.
The QR Code versions range from version **1** to version **40**.
Each version has a different number of modules (black and white dots), which define size of the symbol.
For version 1 symbol size is `21x21` modules, for version 2 `25x25` and so on up to `177x177` modules
for the largest symbol size.
The higher the version, the more data can be stored in the QR code and of course the bigger the symbol will be.

@@ -222,4 +224,4 @@ The table below shows the maximum number of storable characters in each encoding mode and for each error correction level.

QR Code version can be set through `options.version` property.<br>
If no version is specified, the more suitable value will be used. Unless a specific version is required, this option is not needed.
QR Code version can be set through `options.version` property.
If no version is specified, the most suitable value will be used. Unless a specific version is required, this option is not needed.

@@ -233,4 +235,4 @@ ```javascript

## Encoding modes
Modes can be used to encode a string in a more efficient way.<br>
A mode may be more suitable than others depending on the string content.
Modes can be used to encode a string in a more efficient way.
A mode may be more suitable than the others depending on the data content.
A list of supported modes are shown in the table below:

@@ -245,8 +247,8 @@

Choose the right mode may be tricky if the input text is unknown.<br>
In these cases **Byte** mode is the best choice since all characters can be encoded with it. (See [Multibyte characters](#multibyte-characters))<br>
Choosing the right mode may be tricky if the input text is unknown.
In these cases **Byte** mode is the best choice since all characters can be encoded with it (see [Multibyte characters](#multibyte-characters)).
However, if the QR Code reader supports mixed modes, using [Auto mode](#auto-mode) may produce better results.
### Mixed modes
Mixed modes are also possible. A QR code can be generated from a series of segments having different encoding modes to optimize the data compression.<br>
Mixed modes are also possible. A QR code can be generated from a series of segments having different encoding modes to optimize the data compression.
However, switching from a mode to another has a cost which may lead to a worst result if it's not taken into account.

@@ -256,4 +258,4 @@ See [Manual mode](#manual-mode) for an example of how to specify segments with different encoding modes.

### Auto mode
By **default**, automatic mode selection is used.<br>
The input string is automatically splitted in various segments optimized to produce the shortest possible bitstream using mixed modes.<br>
By **default**, automatic mode selection is used.
The input string is automatically splitted in various segments optimized to produce the shortest possible bitstream using mixed modes.
This is the preferred way to generate the QR Code.

@@ -269,3 +271,3 @@

Any other combinations of segments and modes will result in a longer bitstream.<br>
Any other combinations of segments and modes will result in a longer bitstream.
If you need to keep the QR Code size small, this mode will produce the best results.

@@ -275,7 +277,7 @@

If auto mode doesn't work for you or you have specific needs, is also possible to manually specify each segment with the relative mode.
In this way no segment optimizations will be applied under the hood.<br>
In this way no segment optimizations will be applied under the hood.
Segments list can be passed as an array of object:
```javascript
var QRCode = require('qrcode')
var QRCode = require('@slidoapp/qrcode')

@@ -293,4 +295,4 @@ var segs = [

### Kanji mode
With kanji mode is possible to encode characters from the Shift JIS system in an optimized way.<br>
Unfortunately, there isn't a way to calculate a Shifted JIS values from, for example, a character encoded in UTF-8, for this reason a conversion table from the input characters to the SJIS values is needed.<br>
With kanji mode is possible to encode characters from the Shift JIS system in an optimized way.
Unfortunately, there isn't a way to calculate a Shifted JIS values from, for example, a character encoded in UTF-8, for this reason a conversion table from the input characters to the SJIS values is needed.
This table is not included by default in the bundle to keep the size as small as possible.

@@ -305,4 +307,4 @@

```javascript
var QRCode = require('qrcode')
var toSJIS = require('qrcode/helper/to-sjis')
var QRCode = require('@slidoapp/qrcode')
var toSJIS = require('@slidoapp/qrcode/helper/to-sjis')

@@ -336,3 +338,3 @@ QRCode.toDataURL(kanjiString, { toSJISFunc: toSJIS }, function (err, url) {

// WARNING: Element values will be clamped to 0-255 even if your data contains higher values.
const QRCode = require('qrcode')
const QRCode = require('@slidoapp/qrcode')
QRCode.toFile(

@@ -348,3 +350,3 @@ 'foo.png',

// Uint8ClampedArray example
const QRCode = require('qrcode')
const QRCode = require('@slidoapp/qrcode')

@@ -362,3 +364,3 @@ QRCode.toFile(

// WARNING: Element values will be clamped to 0-255 even if your data contains higher values.
const QRCode = require('qrcode')
const QRCode = require('@slidoapp/qrcode')

@@ -425,7 +427,7 @@ QRCode.toFile(

<br>
#### `toCanvas(canvasElement, text, [options], [cb(error)])`
#### `toCanvas(text, [options], [cb(error, canvas)])`
Draws qr code symbol to canvas.<br>
Draws qr code symbol to canvas.
If `canvasElement` is omitted a new canvas is returned.

@@ -461,7 +463,7 @@

<br>
#### `toDataURL(text, [options], [cb(error, url)])`
#### `toDataURL(canvasElement, text, [options], [cb(error, url)])`
Returns a Data URI containing a representation of the QR Code image.<br>
Returns a Data URI containing a representation of the QR Code image.
If provided, `canvasElement` will be used as canvas to generate the data URI.

@@ -481,10 +483,10 @@

- ###### `type`
Type: `String`<br>
Type: `String`
Default: `image/png`
Data URI format.<br>
Possible values are: `image/png`, `image/jpeg`, `image/webp`.<br>
Data URI format.
Possible values are: `image/png`, `image/jpeg`, `image/webp`.
- ###### `rendererOpts.quality`
Type: `Number`<br>
Type: `Number`
Default: `0.92`

@@ -521,7 +523,7 @@

```
<br>
#### `toString(text, [options], [cb(error, string)])`
Returns a string representation of the QR Code.<br>
Returns a string representation of the QR Code.

@@ -536,6 +538,6 @@

- ###### `type`
Type: `String`<br>
Type: `String`
Default: `utf8`
Output format.<br>
Output format.
Possible values are: `terminal`,`utf8`, and `svg`.

@@ -558,3 +560,3 @@

<br>

@@ -566,3 +568,3 @@

<br>

@@ -585,6 +587,6 @@ #### `toCanvas(canvas, text, [options], [cb(error)])`

<br>
#### `toDataURL(text, [options], [cb(error, url)])`
Returns a Data URI containing a representation of the QR Code image.<br>
Returns a Data URI containing a representation of the QR Code image.
Only works with `image/png` type for now.

@@ -605,6 +607,6 @@

<br>
#### `toString(text, [options], [cb(error, string)])`
Returns a string representation of the QR Code.<br>
Returns a string representation of the QR Code.
If choosen output format is `svg` it will returns a string containing xml code.

@@ -619,6 +621,6 @@

- ###### `type`
Type: `String`<br>
Type: `String`
Default: `utf8`
Output format.<br>
Output format.
Possible values are: `utf8`, `svg`, `terminal`.

@@ -641,7 +643,7 @@

<br>
#### `toFile(path, text, [options], [cb(error)])`
Saves QR Code to image file.<br>
If `options.type` is not specified, the format will be guessed from file extension.<br>
Saves QR Code to image file.
If `options.type` is not specified, the format will be guessed from file extension.
Recognized extensions are `png`, `svg`, `txt`.

@@ -661,10 +663,10 @@

- ###### `type`
Type: `String`<br>
Type: `String`
Default: `png`
Output format.<br>
Output format.
Possible values are: `png`, `svg`, `utf8`.
- ###### `rendererOpts.deflateLevel` **(png only)**
Type: `Number`<br>
Type: `Number`
Default: `9`

@@ -675,3 +677,3 @@

- ###### `rendererOpts.deflateStrategy` **(png only)**
Type: `Number`<br>
Type: `Number`
Default: `3`

@@ -701,3 +703,3 @@

<br>

@@ -720,3 +722,3 @@ #### `toFileStream(stream, text, [options])`

<br>

@@ -727,3 +729,3 @@ ### Options

##### `version`
Type: `Number`<br>
Type: `Number`

@@ -733,19 +735,19 @@ QR Code version. If not specified the more suitable value will be calculated.

##### `errorCorrectionLevel`
Type: `String`<br>
Type: `String`
Default: `M`
Error correction level.<br>
Error correction level.
Possible values are `low, medium, quartile, high` or `L, M, Q, H`.
##### `maskPattern`
Type: `Number`<br>
Type: `Number`
Mask pattern used to mask the symbol.<br>
Possible values are `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`.<br>
Mask pattern used to mask the symbol.
Possible values are `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`.
If not specified the more suitable value will be calculated.
##### `toSJISFunc`
Type: `Function`<br>
Type: `Function`
Helper function used internally to convert a kanji to its Shift JIS value.<br>
Helper function used internally to convert a kanji to its Shift JIS value.
Provide this function if you need support for Kanji mode.

@@ -755,3 +757,3 @@

##### `margin`
Type: `Number`<br>
Type: `Number`
Default: `4`

@@ -762,3 +764,3 @@

##### `scale`
Type: `Number`<br>
Type: `Number`
Default: `4`

@@ -769,3 +771,3 @@

##### `small`
Type: `Boolean`<br>
Type: `Boolean`
Default: `false`

@@ -776,22 +778,22 @@

##### `width`
Type: `Number`<br>
Type: `Number`
Forces a specific width for the output image.<br>
If width is too small to contain the qr symbol, this option will be ignored.<br>
Forces a specific width for the output image.
If width is too small to contain the qr symbol, this option will be ignored.
Takes precedence over `scale`.
##### `color.dark`
Type: `String`<br>
Type: `String`
Default: `#000000ff`
Color of dark module. Value must be in hex format (RGBA).<br>
Color of dark module. Value must be in hex format (RGBA).
Note: dark color should always be darker than `color.light`.
##### `color.light`
Type: `String`<br>
Type: `String`
Default: `#ffffffff`
Color of light module. Value must be in hex format (RGBA).<br>
Color of light module. Value must be in hex format (RGBA).
<br>

@@ -805,8 +807,11 @@ ## GS1 QR Codes

## Credits
This lib is based on "QRCode for JavaScript" which Kazuhiko Arase thankfully MIT licensed.
The source code is based on the [QRCode for JavaScript](https://github.com/kazuhikoarase/qrcode-generator) by Kazuhiko Arase,
licenced under [MIT License](https://github.com/kazuhikoarase/qrcode-generator/blob/master/LICENSE).
## License
[MIT](https://github.com/soldair/node-qrcode/blob/master/license)
The word "QR Code" is registered trademark of:<br>
DENSO WAVE INCORPORATED
Source code is licensed under [MIT License](https://github.com/soldair/node-qrcode/blob/master/license).
The word "QR Code" is registered trademark of [DENSO WAVE INCORPORATED](https://www.denso-wave.com)
in Japan and other countries.

Sorry, the diff of this file is not supported yet

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