From 3fef7596b3f22cc356b58e848e9d78f0c02a8594 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Tue, 10 Dec 2024 16:57:04 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(y-provider)=20create=20utils=20functi?= =?UTF-8?q?on=20toBase64?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add utility function to convert BitArray to Base64 string. This is required for creating Base64-encoded documents, as the frontend do. --- src/frontend/servers/y-provider/src/utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/frontend/servers/y-provider/src/utils.ts b/src/frontend/servers/y-provider/src/utils.ts index 53f750dd..4eb9e30c 100644 --- a/src/frontend/servers/y-provider/src/utils.ts +++ b/src/frontend/servers/y-provider/src/utils.ts @@ -7,3 +7,7 @@ export function logger(...args: any[]) { console.log(...args); } } + +export const toBase64 = function (str: Uint8Array) { + return Buffer.from(str).toString('base64'); +};