Method
writeVariableInt
(s: IWriteable, value: number)
Source from the content-addressed store, hash-verified
| 168 | } |
| 169 | |
| 170 | public static writeVariableInt(s: IWriteable, value: number): void { |
| 171 | const array: Uint8Array = new Uint8Array(4); |
| 172 | let n: number = 0; |
| 173 | do { |
| 174 | array[n++] = value & 0x7f; |
| 175 | value >>= 7; |
| 176 | } while (value > 0); |
| 177 | while (n > 0) { |
| 178 | n--; |
| 179 | if (n > 0) { |
| 180 | s.writeByte(array[n] | 0x80); |
| 181 | } else { |
| 182 | s.writeByte(array[n]); |
| 183 | } |
| 184 | } |
| 185 | } |
| 186 | } |
Tested by
no test coverage detected