Skip to content

Commit

Permalink
🎨 Update files
Browse files Browse the repository at this point in the history
  • Loading branch information
nuintun committed Apr 13, 2020
1 parent b69aee5 commit b28cd51
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions examples/qrcode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @module QRCode
* @license MIT
* @version 2.0.0
* @version 2.0.1
* @author nuintun
* @description A pure JavaScript QRCode encode and decode library.
* @see https://github.com/nuintun/qrcode#readme
Expand Down Expand Up @@ -1240,15 +1240,15 @@
buffer.put(encoding, 21);
}
}
function prepareData(version, errorCorrectionLevel, hasEncodingHint, chunks) {
function prepareData(version, errorCorrectionLevel, encodingHint, chunks) {
var dLength = chunks.length;
var buffer = new BitBuffer();
var rsBlocks = RSBlock.getRSBlocks(version, errorCorrectionLevel);
for (var i = 0; i < dLength; i++) {
var data = chunks[i];
var mode = data.getMode();
// Default set encoding UTF-8 when has encoding hint
if (hasEncodingHint && mode === exports.Mode.Byte) {
if (encodingHint && mode === exports.Mode.Byte) {
appendECI(data.encoding, buffer);
}
buffer.put(mode, 4);
Expand Down Expand Up @@ -1342,7 +1342,7 @@
this.chunks = [];
this.matrixSize = 0;
this.matrix = [];
this.hasEncodingHint = false;
this.encodingHint = false;
this.auto = this.version === 0;
this.errorCorrectionLevel = exports.ErrorCorrectionLevel.L;
}
Expand Down Expand Up @@ -1410,16 +1410,16 @@
* @returns {boolean}
*/
Encoder.prototype.getEncodingHint = function () {
return this.hasEncodingHint;
return this.encodingHint;
};
/**
* @public
* @method setEncodingHint
* @param {boolean} hasEncodingHint
* @param {boolean} encodingHint
* @returns {Encoder}
*/
Encoder.prototype.setEncodingHint = function (hasEncodingHint) {
this.hasEncodingHint = hasEncodingHint;
Encoder.prototype.setEncodingHint = function (encodingHint) {
this.encodingHint = encodingHint;
return this;
};
/**
Expand Down Expand Up @@ -1622,14 +1622,14 @@
var errorCorrectionLevel = this.errorCorrectionLevel;
if (this.auto) {
for (this.version = 1; this.version <= 40; this.version++) {
(_a = prepareData(this.version, errorCorrectionLevel, this.hasEncodingHint, chunks)),
(_a = prepareData(this.version, errorCorrectionLevel, this.encodingHint, chunks)),
(buffer = _a[0]),
(rsBlocks = _a[1]),
(maxDataCount = _a[2]);
if (buffer.getLengthInBits() <= maxDataCount) break;
}
} else {
(_b = prepareData(this.version, errorCorrectionLevel, this.hasEncodingHint, chunks)),
(_b = prepareData(this.version, errorCorrectionLevel, this.encodingHint, chunks)),
(buffer = _b[0]),
(rsBlocks = _b[1]),
(maxDataCount = _b[2]);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nuintun/qrcode",
"version": "2.0.0",
"version": "2.0.1",
"description": "A pure JavaScript QRCode encode and decode library.",
"main": "es5/index.js",
"module": "esnext/index.js",
Expand Down
18 changes: 9 additions & 9 deletions src/qrcode/encoder/Writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function appendECI(encoding: number, buffer: BitBuffer) {
function prepareData(
version: number,
errorCorrectionLevel: ErrorCorrectionLevel,
hasEncodingHint: boolean,
encodingHint: boolean,
chunks: QRData[]
): prepareData {
const dLength: number = chunks.length;
Expand All @@ -61,7 +61,7 @@ function prepareData(
const mode: Mode = data.getMode();

// Default set encoding UTF-8 when has encoding hint
if (hasEncodingHint && mode === Mode.Byte) {
if (encodingHint && mode === Mode.Byte) {
appendECI((data as QRByte).encoding, buffer);
}

Expand Down Expand Up @@ -182,7 +182,7 @@ export class Encoder {
private chunks: QRData[] = [];
private matrixSize: number = 0;
private matrix: boolean[][] = [];
private hasEncodingHint: boolean = false;
private encodingHint: boolean = false;
private auto: boolean = this.version === 0;
private errorCorrectionLevel: ErrorCorrectionLevel = ErrorCorrectionLevel.L;

Expand Down Expand Up @@ -258,17 +258,17 @@ export class Encoder {
* @returns {boolean}
*/
public getEncodingHint(): boolean {
return this.hasEncodingHint;
return this.encodingHint;
}

/**
* @public
* @method setEncodingHint
* @param {boolean} hasEncodingHint
* @param {boolean} encodingHint
* @returns {Encoder}
*/
public setEncodingHint(hasEncodingHint: boolean): Encoder {
this.hasEncodingHint = hasEncodingHint;
public setEncodingHint(encodingHint: boolean): Encoder {
this.encodingHint = encodingHint;

return this;
}
Expand Down Expand Up @@ -517,12 +517,12 @@ export class Encoder {

if (this.auto) {
for (this.version = 1; this.version <= 40; this.version++) {
[buffer, rsBlocks, maxDataCount] = prepareData(this.version, errorCorrectionLevel, this.hasEncodingHint, chunks);
[buffer, rsBlocks, maxDataCount] = prepareData(this.version, errorCorrectionLevel, this.encodingHint, chunks);

if (buffer.getLengthInBits() <= maxDataCount) break;
}
} else {
[buffer, rsBlocks, maxDataCount] = prepareData(this.version, errorCorrectionLevel, this.hasEncodingHint, chunks);
[buffer, rsBlocks, maxDataCount] = prepareData(this.version, errorCorrectionLevel, this.encodingHint, chunks);
}

// Calc module count
Expand Down

0 comments on commit b28cd51

Please sign in to comment.