Unzipit Example Parallel decompression

by Gregg Tavares

CSS

img { max-width: 200px; padding: 5px; }

JavaScript

import {unzip, setOptions} from 'https://unpkg.com/[email protected]/dist/unzipit.module.js';

setOptions({
  workerURL: 'https://unpkg.com/[email protected]/dist/unzipit-worker.module.js',
  numWorkers: 2,
});


(async function() {

	const {entries} = await unzip('https://greggman.github.io/unzipit/test/data/large.zip');
  const names = Object.keys(entries).filter(name => name.endsWith('.jpg'));
  const blobs = await Promise.all(names.map(name => entries[name].blob()));
  names.forEach((name, i) => {
    const img = new Image();
    img.title = name;
    img.src = URL.createObjectURL(blobs[i]);
    document.body.appendChild(img);
  });

}());