feat: ported protobuf decoder
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"use bigint"
|
||||
export function decodeVarint(buffer, offset) {
|
||||
let res = BigInt(0);
|
||||
let res = this.BigInt(0);
|
||||
let shift = 0;
|
||||
let byte = 0;
|
||||
|
||||
@@ -10,11 +9,12 @@ export function decodeVarint(buffer, offset) {
|
||||
}
|
||||
|
||||
byte = buffer[offset++];
|
||||
console.log(this)
|
||||
|
||||
const multiplier = exponentiate(BigInt(2), BigInt(shift));
|
||||
const thisByteValue = multiply(BigInt(byte & 0x7f), multiplier);
|
||||
const multiplier = this.BigInt(2) ** this.BigInt(shift);
|
||||
const thisByteValue = this.BigInt(byte & 0x7f) * multiplier;
|
||||
shift += 7;
|
||||
res = add(res, thisByteValue);
|
||||
res = res + thisByteValue;
|
||||
} while (byte >= 0x80);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user