feat: added google migration support (BETA) v.1.2.0
This commit is contained in:
@@ -9,7 +9,6 @@ export function decodeVarint(buffer, offset) {
|
||||
}
|
||||
|
||||
byte = buffer[offset++];
|
||||
console.log(this)
|
||||
|
||||
const multiplier = this.BigInt(2) ** this.BigInt(shift);
|
||||
const thisByteValue = this.BigInt(byte & 0x7f) * multiplier;
|
||||
|
||||
@@ -25,6 +25,32 @@ function leftpad(str, len, pad) {
|
||||
);
|
||||
}
|
||||
|
||||
export function encode(bytes) {
|
||||
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
||||
let bits = 0;
|
||||
let value = 0;
|
||||
let output = '';
|
||||
|
||||
for (let i = 0; i < bytes.length; i++) {
|
||||
value = (value << 8) | bytes[i];
|
||||
bits += 8;
|
||||
|
||||
while (bits >= 5) {
|
||||
output += alphabet[(value >>> (bits - 5)) & 0x1F];
|
||||
bits -= 5;
|
||||
}
|
||||
}
|
||||
|
||||
if (bits > 0) {
|
||||
output += alphabet[(value << (5 - bits)) & 0x1F];
|
||||
}
|
||||
|
||||
const paddingLength = (8 - (output.length % 8)) % 8;
|
||||
output += '='.repeat(paddingLength);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
export function base64decode(base64) {
|
||||
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
let result = [];
|
||||
|
||||
Reference in New Issue
Block a user