jszip
jszip copied to clipboard
FEATURE REQUEST: make async process abortable
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.
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.