From 3d0980ea89d3a27def74bbd321c0c97e467b8320 Mon Sep 17 00:00:00 2001 From: davikstone Date: Tue, 23 Jan 2024 20:10:52 +0100 Subject: [PATCH] update --- .husky/pre-push | 4 -- lib/helpers/qrcode.js | 144 +++++++++++++++++++++--------------------- 2 files changed, 72 insertions(+), 76 deletions(-) delete mode 100755 .husky/pre-push diff --git a/.husky/pre-push b/.husky/pre-push deleted file mode 100755 index c5893f3622..0000000000 --- a/.husky/pre-push +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -npm run pretty && npx eslint . --fix diff --git a/lib/helpers/qrcode.js b/lib/helpers/qrcode.js index c57d1901e8..a5ced737ab 100644 --- a/lib/helpers/qrcode.js +++ b/lib/helpers/qrcode.js @@ -518,24 +518,24 @@ var QRCode; }, getMask: function (maskPattern, i, j) { switch (maskPattern) { - case QRMaskPattern.PATTERN000: - return (i + j) % 2 == 0; - case QRMaskPattern.PATTERN001: - return i % 2 == 0; - case QRMaskPattern.PATTERN010: - return j % 3 == 0; - case QRMaskPattern.PATTERN011: - return (i + j) % 3 == 0; - case QRMaskPattern.PATTERN100: - return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0; - case QRMaskPattern.PATTERN101: - return ((i * j) % 2) + ((i * j) % 3) == 0; - case QRMaskPattern.PATTERN110: - return (((i * j) % 2) + ((i * j) % 3)) % 2 == 0; - case QRMaskPattern.PATTERN111: - return (((i * j) % 3) + ((i + j) % 2)) % 2 == 0; - default: - throw new Error('bad maskPattern:' + maskPattern); + case QRMaskPattern.PATTERN000: + return (i + j) % 2 == 0; + case QRMaskPattern.PATTERN001: + return i % 2 == 0; + case QRMaskPattern.PATTERN010: + return j % 3 == 0; + case QRMaskPattern.PATTERN011: + return (i + j) % 3 == 0; + case QRMaskPattern.PATTERN100: + return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0; + case QRMaskPattern.PATTERN101: + return ((i * j) % 2) + ((i * j) % 3) == 0; + case QRMaskPattern.PATTERN110: + return (((i * j) % 2) + ((i * j) % 3)) % 2 == 0; + case QRMaskPattern.PATTERN111: + return (((i * j) % 3) + ((i + j) % 2)) % 2 == 0; + default: + throw new Error('bad maskPattern:' + maskPattern); } }, getErrorCorrectPolynomial: function (errorCorrectLength) { @@ -548,42 +548,42 @@ var QRCode; getLengthInBits: function (mode, type) { if (1 <= type && type < 10) { switch (mode) { - case QRMode.MODE_NUMBER: - return 10; - case QRMode.MODE_ALPHA_NUM: - return 9; - case QRMode.MODE_8BIT_BYTE: - return 8; - case QRMode.MODE_KANJI: - return 8; - default: - throw new Error('mode:' + mode); + case QRMode.MODE_NUMBER: + return 10; + case QRMode.MODE_ALPHA_NUM: + return 9; + case QRMode.MODE_8BIT_BYTE: + return 8; + case QRMode.MODE_KANJI: + return 8; + default: + throw new Error('mode:' + mode); } } else if (type < 27) { switch (mode) { - case QRMode.MODE_NUMBER: - return 12; - case QRMode.MODE_ALPHA_NUM: - return 11; - case QRMode.MODE_8BIT_BYTE: - return 16; - case QRMode.MODE_KANJI: - return 10; - default: - throw new Error('mode:' + mode); + case QRMode.MODE_NUMBER: + return 12; + case QRMode.MODE_ALPHA_NUM: + return 11; + case QRMode.MODE_8BIT_BYTE: + return 16; + case QRMode.MODE_KANJI: + return 10; + default: + throw new Error('mode:' + mode); } } else if (type < 41) { switch (mode) { - case QRMode.MODE_NUMBER: - return 14; - case QRMode.MODE_ALPHA_NUM: - return 13; - case QRMode.MODE_8BIT_BYTE: - return 16; - case QRMode.MODE_KANJI: - return 12; - default: - throw new Error('mode:' + mode); + case QRMode.MODE_NUMBER: + return 14; + case QRMode.MODE_ALPHA_NUM: + return 13; + case QRMode.MODE_8BIT_BYTE: + return 16; + case QRMode.MODE_KANJI: + return 12; + default: + throw new Error('mode:' + mode); } } else { throw new Error('type:' + type); @@ -942,16 +942,16 @@ var QRCode; }; QRRSBlock.getRsBlockTable = function (typeNumber, errorCorrectLevel) { switch (errorCorrectLevel) { - case QRErrorCorrectLevel.L: - return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0]; - case QRErrorCorrectLevel.M: - return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1]; - case QRErrorCorrectLevel.Q: - return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2]; - case QRErrorCorrectLevel.H: - return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3]; - default: - return undefined; + case QRErrorCorrectLevel.L: + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0]; + case QRErrorCorrectLevel.M: + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1]; + case QRErrorCorrectLevel.Q: + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2]; + case QRErrorCorrectLevel.H: + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3]; + default: + return undefined; } }; function QRBitBuffer() { @@ -1131,7 +1131,7 @@ var QRCode; var Drawing = useSVG ? svgDrawer : !_isSupportCanvas() - ? (function () { + ? (function () { var Drawing = function (el, htOption) { this._el = el; this._htOption = htOption; @@ -1197,7 +1197,7 @@ var QRCode; return Drawing; })() - : (function () { + : (function () { // Drawing in Canvas function _onMakeImage() { this._elImage.src = this._elCanvas.toDataURL('image/png'); @@ -1427,18 +1427,18 @@ var QRCode; var nLimit = 0; switch (nCorrectLevel) { - case QRErrorCorrectLevel.L: - nLimit = QRCodeLimitLength[i][0]; - break; - case QRErrorCorrectLevel.M: - nLimit = QRCodeLimitLength[i][1]; - break; - case QRErrorCorrectLevel.Q: - nLimit = QRCodeLimitLength[i][2]; - break; - case QRErrorCorrectLevel.H: - nLimit = QRCodeLimitLength[i][3]; - break; + case QRErrorCorrectLevel.L: + nLimit = QRCodeLimitLength[i][0]; + break; + case QRErrorCorrectLevel.M: + nLimit = QRCodeLimitLength[i][1]; + break; + case QRErrorCorrectLevel.Q: + nLimit = QRCodeLimitLength[i][2]; + break; + case QRErrorCorrectLevel.H: + nLimit = QRCodeLimitLength[i][3]; + break; } if (length <= nLimit) {