jszip icon indicating copy to clipboard operation
jszip copied to clipboard

FEATURE REQUEST: make async process abortable

Open paolobenve opened this issue 3 years ago • 1 comments

It seems that there isn't any way to abort the creatinon of a zip file. The only thing you can do is not to "download" the generated zip to the disk.

It would be a nice feature to be able to abort the process.

paolobenve avatar Feb 02 '22 17:02 paolobenve

FWIW this cancellation functionality is offered in fflate. All of the asynchronous APIs can be terminated.

import { zip, strToU8 } from 'fflate';
const terminate = zip({ 'ex.txt': strToU8('hello world') }, (err, result) => {
  // result is a Uint8Array that contains the ZIP file
});
if (needToCancel) {
  // Aborts the ZIP creation immediately
  terminate();
}

If you want to do this with JSZip it's actually still possible. You just need to run JSZip in a worker thread and terminate the worker it if you need to abort.

101arrowz avatar May 18 '22 17:05 101arrowz