refactor: move b64ToBuf from libweb

This commit is contained in:
Derrick Hammer 2023-09-08 08:41:52 -04:00
parent bb1229eeb2
commit b46bd6048e
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 1 deletions

View File

@ -115,4 +115,9 @@ function encodeU64(num: bigint): [Uint8Array, Err] {
return [encoded, null];
}
export { objAsString, addContextToErr, encodeU64, decodeU64 };
function bufToB64(buf: Uint8Array): string {
const b64Str = btoa(String.fromCharCode(...buf));
return b64Str.replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
}
export { objAsString, addContextToErr, encodeU64, decodeU64, bufToB64 };