aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/lib/ts/truncate.worker.ts
blob: ad000113132cc03cf6b1a0a72c67293f9b4ae19f (plain) (blame)
1
2
3
4
5
6
7
8
9
import type { TruncateRequest, TruncateResponse } from '../types/truncate-worker';

onmessage = async (message: MessageEvent<TruncateRequest>) => {
  const file = message.data.file;
  const buffer = await file.arrayBuffer();
  const truncated = buffer.slice(0, message.data.size);

  postMessage({ file: truncated } as TruncateResponse);
};