aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/lib/ts/crc32.worker.ts
blob: 57c1bc9b4f82f9b5fe0bf17c6c97af4a66fba3d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
// TODO: Think about using a WebAssembly implementation of CRC32 instead of JavaScript.
// WHY? The JavaScript implementation is not very extensible and is not very fast.
import crc32 from 'crc/crc32';

onmessage = async (message: MessageEvent<File>) => {
  const file = message.data;
  const buffer = await file.arrayBuffer();
  const crc = crc32(buffer);
  postMessage(crc);
};