mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-21 09:23:00 +00:00
refactor: use standard prettier formatting
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
* meaning some chars are swapped for compatibility
|
||||
*/
|
||||
export async function toBase64(blob: Blob): Promise<string> {
|
||||
return new Promise(async resolve => {
|
||||
const reader = new FileReader()
|
||||
return new Promise(async (resolve) => {
|
||||
const reader = new FileReader();
|
||||
reader.onloadend = function () {
|
||||
resolve(
|
||||
`${(reader.result as string)
|
||||
@@ -14,17 +14,20 @@ export async function toBase64(blob: Blob): Promise<string> {
|
||||
.replaceAll("+", ".")
|
||||
.replaceAll("/", "_")
|
||||
.replaceAll("=", "-")}`,
|
||||
)
|
||||
}
|
||||
reader.readAsDataURL(blob)
|
||||
})
|
||||
);
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
});
|
||||
}
|
||||
|
||||
export async function fromBase64(base64: string, fetch = window.fetch): Promise<Blob> {
|
||||
export async function fromBase64(
|
||||
base64: string,
|
||||
fetch = window.fetch,
|
||||
): Promise<Blob> {
|
||||
return fetch(
|
||||
`data:application/octet-stream;base64,${base64
|
||||
.replaceAll(".", "+")
|
||||
.replaceAll("_", "/")
|
||||
.replaceAll("-", "=")}`,
|
||||
).then(it => it.blob())
|
||||
).then((it) => it.blob());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user