(value: string, ecl: ErrorCorrectionLevel)
| 62 | const matrixCache = new Map<string, boolean[][]>(); |
| 63 | |
| 64 | const getCachedMatrix = (value: string, ecl: ErrorCorrectionLevel): boolean[][] => { |
| 65 | const key = `${ecl}|${value}`; |
| 66 | const hit = matrixCache.get(key); |
| 67 | if (hit) { |
| 68 | matrixCache.delete(key); |
| 69 | matrixCache.set(key, hit); |
| 70 | return hit; |
| 71 | } |
| 72 | const m = encodeQR(value, 'raw', { ecc: eclMap[ecl], border: 0 }); |
| 73 | matrixCache.set(key, m); |
| 74 | if (matrixCache.size > MATRIX_CACHE_MAX) { |
| 75 | const first = matrixCache.keys().next().value; |
| 76 | if (first !== undefined) matrixCache.delete(first); |
| 77 | } |
| 78 | return m; |
| 79 | }; |
| 80 | |
| 81 | type RenderPlan = { |
| 82 | N: number; |
no test coverage detected