aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/lib/ts/truncate.worker.ts
blob: eaa65fe48bdbaaa596543d9ff7761229eafb982e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
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('Worker successfully loaded!');