1.0.3 • Published 1 year ago
async-zip-parser v1.0.3
async-zip-parser
This package was created for my use case that couldn't be handled by node-unzipper because of a bug in node v18 and higher with the Parse function and async iterators.
The bug was that the function threw the following error: ERR_STREAM_PREMATURE_CLOSE: Premature close
When the Parse function was used with async iterators, in my edited version of the code the bug doesn't exist.
Most of the code is copied from node-unzipper but I made some optimizations and updates according to my needs.
Usage
const zip = fs.createReadStream('input.zip').pipe(asyncZipParser.ParseZip());
for await (const entry of zip) {
const fileName = entry.path;
const type = entry.type;
const size = entry.vars.uncompressedSize;
entry.pipe(fs.createWriteStream(`output/${fileName}`));
}