* Performs decode on given content. * @protected * @param {Chain} content * @return {number[]|string|Uint8Array|Chain} Decoded content
(content)
| 116 | * @return {number[]|string|Uint8Array|Chain} Decoded content |
| 117 | */ |
| 118 | performDecode (content) { |
| 119 | const tapMark = this.getSettingValue('tapMark').getCodePoints() |
| 120 | const tapMarkLength = tapMark.length |
| 121 | const input = content.getCodePoints() |
| 122 | |
| 123 | let coordinates = '' |
| 124 | let i = 0 |
| 125 | let j = -1 |
| 126 | let value = 0 |
| 127 | |
| 128 | // Iterate through tap marks |
| 129 | while ((j = ArrayUtil.indexOfSlice(input, tapMark, j + 1)) !== -1) { |
| 130 | // Check if the current dot is adjacent to the previous one |
| 131 | if (i === 0 || j === i + tapMarkLength) { |
| 132 | // Increase current coordinate value |
| 133 | value++ |
| 134 | } else { |
| 135 | // Append coordinate |
| 136 | coordinates += value.toString() |
| 137 | value = 1 |
| 138 | } |
| 139 | |
| 140 | i = j |
| 141 | } |
| 142 | |
| 143 | // Append last coordinate |
| 144 | coordinates += value.toString() |
| 145 | |
| 146 | // Decode coordinates using Polybius square |
| 147 | return this._polybiusSquare.decode(coordinates) |
| 148 | } |
| 149 | } |
nothing calls this directly
no test coverage detected