Fix client compilation error in base64()

Context :

The base64 function tries using the btoa function and falls back to
using Buffer if btoa is not available.

Problem :

In the context of a dom, you have btoa, and you may not necessarily have
Buffer, and in the case the fallback branch creates a compilation error
"TS2591: Cannot find name 'Buffer'."

Solution :

Add a @ts-ignore in the fallback branch because we will always have
either btoa or Buffer available in the forseable future.
This commit is contained in:
Samuel Rossille 2021-12-19 11:05:42 +01:00
parent aae6306a5a
commit 21d0e116e7

View File

@ -2,6 +2,7 @@ function base64(str: string): string {
try {
return btoa(str);
} catch (err) {
// @ts-ignore
return Buffer.from(str).toString('base64');
}
}