aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/lib/ts
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/lib/ts')
-rw-r--r--app/src/lib/ts/download.ts32
-rw-r--r--app/src/lib/ts/truncate.worker.ts14
2 files changed, 23 insertions, 23 deletions
diff --git a/app/src/lib/ts/download.ts b/app/src/lib/ts/download.ts
index c3e98b0..48debec 100644
--- a/app/src/lib/ts/download.ts
+++ b/app/src/lib/ts/download.ts
@@ -5,33 +5,33 @@ export default async function saveFile(blob: ArrayBuffer, suggestedName: string
'showSaveFilePicker' in window &&
(() => {
try {
- return window.self === window.top;
+ return window.self === window.top
} catch {
- return false;
+ return false
}
- })();
+ })()
if (supportsFSAccess) {
try {
const handle = await window.showSaveFilePicker({
- suggestedName: suggestedName
- });
- const writable = await handle.createWritable();
- await writable.write(blob);
- await writable.close();
- return;
+ suggestedName: suggestedName,
+ })
+ const writable = await handle.createWritable()
+ await writable.write(blob)
+ await writable.close()
+ return
} catch (err: unknown) {
// TypeScript
if ((err as Error)?.name !== 'AbortError') {
- return Promise.reject(err);
+ return Promise.reject(err)
}
}
} else {
- const anchor = document.createElement('a');
- anchor.download = suggestedName ?? 'truncated';
- anchor.href = URL.createObjectURL(new Blob([blob]));
- anchor.click();
- URL.revokeObjectURL(anchor.href);
- document.body.removeChild(anchor);
+ const anchor = document.createElement('a')
+ anchor.download = suggestedName ?? 'truncated'
+ anchor.href = URL.createObjectURL(new Blob([blob]))
+ anchor.click()
+ URL.revokeObjectURL(anchor.href)
+ document.body.removeChild(anchor)
}
}
diff --git a/app/src/lib/ts/truncate.worker.ts b/app/src/lib/ts/truncate.worker.ts
index 9ddf63c..da75041 100644
--- a/app/src/lib/ts/truncate.worker.ts
+++ b/app/src/lib/ts/truncate.worker.ts
@@ -1,9 +1,9 @@
-import type { TruncateRequest, TruncateResponse } from '../types/truncate-worker';
+import type { TruncateRequest, TruncateResponse } from '../types/truncate-worker'
onmessage = async (message: MessageEvent<TruncateRequest>) => {
- console.log('File received. Truncating...');
- const file = message.data.file;
- const buffer = await file.arrayBuffer();
- const truncated = buffer.slice(0, message.data.size);
- postMessage({ file: truncated } as TruncateResponse);
-};
+ console.log('File received. Truncating...')
+ const file = message.data.file
+ const buffer = await file.arrayBuffer()
+ const truncated = buffer.slice(0, message.data.size)
+ postMessage({ file: truncated } as TruncateResponse)
+}