async function startWork() {
mutable jobFinished = false;
mutable jobStarted = true;
let normalEntries = [];
let workerEntries = [];
mutable result = { normalEntries, workerEntries };
console.log('started downloading!');
const batchUrls = makeBatchUrl();
normalEntries = [
...result.normalEntries,
...(await Promise.all(batchUrls.map(fetchNormal)))
];
mutable result = { normalEntries, workerEntries };
const _batchUrls = makeBatchUrl();
const worker = new Worker(workerScript);
workerEntries = [
...result.workerEntries,
...(await Promise.all(_batchUrls.map(urls => fetchWorker(worker, urls))))
];
worker.terminate();
console.log('started worker downloading!');
mutable result = { normalEntries, workerEntries };
mutable jobFinished = true;
}