You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
25 KiB
1 line
25 KiB
2 years ago
|
{"ast":null,"code":"var Mode = require('./mode');\n\nvar Polynomial = require('./Polynomial');\n\nvar math = require('./math');\n\nvar QRMaskPattern = {\n PATTERN000: 0,\n PATTERN001: 1,\n PATTERN010: 2,\n PATTERN011: 3,\n PATTERN100: 4,\n PATTERN101: 5,\n PATTERN110: 6,\n PATTERN111: 7\n};\nvar QRUtil = {\n PATTERN_POSITION_TABLE: [[], [6, 18], [6, 22], [6, 26], [6, 30], [6, 34], [6, 22, 38], [6, 24, 42], [6, 26, 46], [6, 28, 50], [6, 30, 54], [6, 32, 58], [6, 34, 62], [6, 26, 46, 66], [6, 26, 48, 70], [6, 26, 50, 74], [6, 30, 54, 78], [6, 30, 56, 82], [6, 30, 58, 86], [6, 34, 62, 90], [6, 28, 50, 72, 94], [6, 26, 50, 74, 98], [6, 30, 54, 78, 102], [6, 28, 54, 80, 106], [6, 32, 58, 84, 110], [6, 30, 58, 86, 114], [6, 34, 62, 90, 118], [6, 26, 50, 74, 98, 122], [6, 30, 54, 78, 102, 126], [6, 26, 52, 78, 104, 130], [6, 30, 56, 82, 108, 134], [6, 34, 60, 86, 112, 138], [6, 30, 58, 86, 114, 142], [6, 34, 62, 90, 118, 146], [6, 30, 54, 78, 102, 126, 150], [6, 24, 50, 76, 102, 128, 154], [6, 28, 54, 80, 106, 132, 158], [6, 32, 58, 84, 110, 136, 162], [6, 26, 54, 82, 110, 138, 166], [6, 30, 58, 86, 114, 142, 170]],\n G15: 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0,\n G18: 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0,\n G15_MASK: 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1,\n getBCHTypeInfo: function (data) {\n var d = data << 10;\n\n while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {\n d ^= QRUtil.G15 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15);\n }\n\n return (data << 10 | d) ^ QRUtil.G15_MASK;\n },\n getBCHTypeNumber: function (data) {\n var d = data << 12;\n\n while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {\n d ^= QRUtil.G18 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18);\n }\n\n return data << 12 | d;\n },\n getBCHDigit: function (data) {\n var digit = 0;\n\n while (data != 0) {\n digit++;\n data >>>= 1;\n }\n\n return digit;\n },\n getPatternPosition: function (typeNumber) {\n return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];\n },\n getMask: function (maskPattern, i, j) {\n switch (maskPattern) {\n case QRMaskPattern.PATTERN000:\n return (i + j) % 2 == 0;\n\n case QRMaskPattern.PATTERN001:\n return i % 2 == 0;\n\n case QRMaskPattern.PATTERN010:\n return j % 3 == 0;\n\n case QRMaskPattern.PATTERN011:\n return (i + j) % 3 == 0;\n\n case QRMaskPattern.PATTERN100:\n return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;\n\n case QRMaskPattern.PATTERN101:\n return i * j % 2 + i * j % 3 == 0;\n\n case QRMaskPattern.PATTERN110:\n return (i * j % 2 + i * j % 3) % 2 == 0;\n\n case QRMaskPattern.PATTERN111:\n return (i * j % 3 + (i + j) % 2) % 2 == 0;\n\n default:\n throw new Error(\"bad maskPattern:\" + maskPattern);\n }\n },\n getErrorCorrectPolynomial: function (errorCorrectLength) {\n var a = new Polynomial([1], 0);\n\n for (var i = 0; i < errorCorrectLength; i++) {\n a = a.multiply(new Polynomial([1, math.gexp(i)], 0));\n }\n\n return a;\n },\n getLengthInBits: function (mode, type) {\n if (1 <= type && type < 10) {\n // 1 - 9\n switch (mode) {\n case Mode.MODE_NUMBER:\n return 10;\n\n case Mode.MODE_ALPHA_NUM:\n return 9;\n\n case Mode.MODE_8BIT_BYTE:\n return 8;\n\n case Mode.MODE_KANJI:\n return 8;\n\n default:\n throw new Error(\"mode:\" + mode);\n }\n } else if (type < 27) {\n // 10 - 26\n switch (mode) {\n case Mode.MODE_NUMBER:\n return 12;\n\n case Mode.MODE_ALPHA_NUM:\n return 11;\n\n case Mode.MODE_8BIT_BYTE:\n return 16;\n\n case Mode.MODE_KANJI:\n return 10;\n\n default:\n throw new Error(\"mode:\" + mode);\n }\n } else if (type < 41) {\n // 27 - 40\n switch (mode) {\n cas
|