(index: number)
| 121 | } |
| 122 | |
| 123 | get(index: number): string | undefined { |
| 124 | if (!this.hasIndex(index)) { |
| 125 | return undefined; |
| 126 | } |
| 127 | |
| 128 | let str = ''; |
| 129 | const chars = this.rangeCount(this.startCode, this.endCode); |
| 130 | |
| 131 | for (let toIndex = index, i = 0; i < this.maxStrWidth; i += 1) { |
| 132 | const opStrWidth = this.maxStrWidth - i; |
| 133 | const opStrTableSize = this.getWidthToSize(opStrWidth); |
| 134 | |
| 135 | const segmentSize = opStrTableSize / chars; |
| 136 | |
| 137 | const segmentIndex = Math.floor(toIndex / segmentSize); |
| 138 | str += String.fromCharCode(this.startCode + segmentIndex); |
| 139 | |
| 140 | toIndex -= segmentIndex * segmentSize; |
| 141 | if (toIndex === 0) { |
| 142 | break; |
| 143 | } |
| 144 | toIndex -= 1; |
| 145 | } |
| 146 | |
| 147 | return str; |
| 148 | } |
| 149 | |
| 150 | previous(str: string): string | undefined { |
| 151 | if (!this.has(str)) return undefined; |
no test coverage detected