Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
davikstone2 committed Jan 23, 2024
1 parent cafce0a commit 3d0980e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 76 deletions.
4 changes: 0 additions & 4 deletions .husky/pre-push

This file was deleted.

144 changes: 72 additions & 72 deletions lib/helpers/qrcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Check failure on line 521 in lib/helpers/qrcode.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 3 tabs but found 4
return (i + j) % 2 == 0;

Check failure on line 522 in lib/helpers/qrcode.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 4 tabs but found 5
case QRMaskPattern.PATTERN001:

Check failure on line 523 in lib/helpers/qrcode.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 3 tabs but found 4
return i % 2 == 0;

Check failure on line 524 in lib/helpers/qrcode.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 4 tabs but found 5
case QRMaskPattern.PATTERN010:

Check failure on line 525 in lib/helpers/qrcode.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 3 tabs but found 4
return j % 3 == 0;

Check failure on line 526 in lib/helpers/qrcode.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 4 tabs but found 5
case QRMaskPattern.PATTERN011:

Check failure on line 527 in lib/helpers/qrcode.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 3 tabs but found 4
return (i + j) % 3 == 0;

Check failure on line 528 in lib/helpers/qrcode.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 4 tabs but found 5
case QRMaskPattern.PATTERN100:

Check failure on line 529 in lib/helpers/qrcode.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 3 tabs but found 4
return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;

Check failure on line 530 in lib/helpers/qrcode.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 4 tabs but found 5
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) {
Expand All @@ -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);
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -1131,7 +1131,7 @@ var QRCode;
var Drawing = useSVG
? svgDrawer
: !_isSupportCanvas()
? (function () {
? (function () {
var Drawing = function (el, htOption) {
this._el = el;
this._htOption = htOption;
Expand Down Expand Up @@ -1197,7 +1197,7 @@ var QRCode;

return Drawing;
})()
: (function () {
: (function () {
// Drawing in Canvas
function _onMakeImage() {
this._elImage.src = this._elCanvas.toDataURL('image/png');
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 3d0980e

Please sign in to comment.