* Performs decode on given content. * @protected * @param {Chain} content * @return {number[]|string|Uint8Array|Chain} Decoded content
(content)
| 88 | * @return {number[]|string|Uint8Array|Chain} Decoded content |
| 89 | */ |
| 90 | performDecode (content) { |
| 91 | const { key: rows, offset } = this.getSettingValues() |
| 92 | const length = content.getLength() |
| 93 | |
| 94 | // Cycle after which fence matrix repeats |
| 95 | const cycle = rows * 2 - 2 |
| 96 | |
| 97 | // Create result array of code points |
| 98 | const result = new Array(length) |
| 99 | |
| 100 | let j = -1 |
| 101 | let x, y |
| 102 | |
| 103 | // Go through virtual matrix rows (y) and cols (x) |
| 104 | for (y = 0; y < rows; y++) { |
| 105 | for (x = 0; x < length; x++) { |
| 106 | // Check if the current x-y-position is situated on the zigzag fence |
| 107 | if ((y + x + offset) % cycle === 0 || (y - x - offset) % cycle === 0) { |
| 108 | // Set result for the current x-position |
| 109 | result[x] = content.getCodePointAt(++j) |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | return result |
| 115 | } |
| 116 | } |
nothing calls this directly
no test coverage detected