Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 7x 7x 7x 7x 7x 7x 7x 7x 7x 2x 2x 2x 2x 2x 2x 226x 197x 197x 157x 42x 42x 157x 149x 157x 157x 129x | import { QrPolynomial } from '../utils/qr-polynomial'
import { gexp } from '../utils/qr-math.util'
/**
* memoize getErrorCorrectPolynomial as it is called multiple times when generating QR Code
*/
const memoECPolynomials = [
QrPolynomial([1], 0),
]
/**
* @param {number} errorCorrectLength - error correction codeword count
* @returns {ReturnType<QrPolynomial>} error correction polynomial
*/
export function getErrorCorrectPolynomial (errorCorrectLength) {
if (memoECPolynomials.length > errorCorrectLength) {
return memoECPolynomials[errorCorrectLength]
}
const lastIndex = memoECPolynomials.length - 1
let polynomial = memoECPolynomials[lastIndex]
for (let i = lastIndex; i < errorCorrectLength; i += 1) {
polynomial = polynomial.multiply(QrPolynomial([1, gexp(i)], 0))
memoECPolynomials.push(polynomial)
}
return polynomial
};
|