From ef30f835d04038a1cbec06fbe35a70037e926cd6 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Thu, 28 Sep 2023 08:42:25 -0500 Subject: Lint Signed-off-by: Matt Strapp --- app/src/lib/ts/download.ts | 59 +++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 29 deletions(-) (limited to 'app/src/lib/ts/download.ts') diff --git a/app/src/lib/ts/download.ts b/app/src/lib/ts/download.ts index a6167d7..16712fb 100644 --- a/app/src/lib/ts/download.ts +++ b/app/src/lib/ts/download.ts @@ -1,33 +1,34 @@ // Yoinked from https://web.dev/patterns/files/save-a-file/ for the polyfill export default async function saveFile(blob: ArrayBuffer, suggestedName: string | undefined) { - const supportsFSAccess = 'showSaveFilePicker' in window && - (() => { - try { - return window.self === window.top; - } catch { - return false; - } - })(); + const supportsFSAccess = + 'showSaveFilePicker' in window && + (() => { + try { + return window.self === window.top; + } catch { + return false; + } + })(); - if (supportsFSAccess) { - try { - const handle = await window.showSaveFilePicker({ - suggestedName: suggestedName, - }) - const writable = await handle.createWritable(); - await writable.write(blob); - await writable.close(); - } catch (err: unknown) { - // TypeScript - if ((err as Error)?.name !== 'AbortError') { - console.error(err); - } - } - } else { - const anchor = document.createElement('a'); - anchor.download = suggestedName ?? 'truncated'; - anchor.href = URL.createObjectURL(new Blob([blob])); - anchor.click(); - } -} \ No newline at end of file + if (supportsFSAccess) { + try { + const handle = await window.showSaveFilePicker({ + suggestedName: suggestedName + }); + const writable = await handle.createWritable(); + await writable.write(blob); + await writable.close(); + } catch (err: unknown) { + // TypeScript + if ((err as Error)?.name !== 'AbortError') { + console.error(err); + } + } + } else { + const anchor = document.createElement('a'); + anchor.download = suggestedName ?? 'truncated'; + anchor.href = URL.createObjectURL(new Blob([blob])); + anchor.click(); + } +} -- cgit v1.2.3