(num: number)
| 64 | } |
| 65 | |
| 66 | function encodeInteger(num: number): string { |
| 67 | let result = ''; |
| 68 | |
| 69 | if (num < 0) { |
| 70 | num = (-num << 1) | 1; |
| 71 | } else { |
| 72 | num <<= 1; |
| 73 | } |
| 74 | |
| 75 | do { |
| 76 | let clamped = num & 31; |
| 77 | num >>>= 5; |
| 78 | |
| 79 | if (num > 0) { |
| 80 | clamped |= 32; |
| 81 | } |
| 82 | |
| 83 | result += integerToChar[clamped]; |
| 84 | } while (num > 0); |
| 85 | |
| 86 | return result; |
| 87 | } |