feat: added google migration support (BETA) v.1.2.0

This commit is contained in:
Savely Savianok
2025-03-17 15:30:03 +03:00
parent fb6ece773c
commit 21c7646c71
8 changed files with 99 additions and 13 deletions

View File

@@ -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;

View File

@@ -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 = [];