From b28cd514ae46909a961e8007b622734bb62f8af3 Mon Sep 17 00:00:00 2001 From: nuintun Date: Mon, 13 Apr 2020 16:11:08 +0800 Subject: [PATCH] :art: Update files --- examples/qrcode.js | 20 ++++++++++---------- package.json | 2 +- src/qrcode/encoder/Writer.ts | 18 +++++++++--------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/qrcode.js b/examples/qrcode.js index 8f5325f1..50180201 100644 --- a/examples/qrcode.js +++ b/examples/qrcode.js @@ -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 @@ -1240,7 +1240,7 @@ 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); @@ -1248,7 +1248,7 @@ 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); @@ -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; } @@ -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; }; /** @@ -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]); diff --git a/package.json b/package.json index 5c1b7120..fc30ef18 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/qrcode/encoder/Writer.ts b/src/qrcode/encoder/Writer.ts index 6ca02378..d023db42 100644 --- a/src/qrcode/encoder/Writer.ts +++ b/src/qrcode/encoder/Writer.ts @@ -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; @@ -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); } @@ -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; @@ -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; } @@ -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