yazl
yazl copied to clipboard
RE: API to predict final zipfile size
This is a follow up of #1 .
I see that we can get the final zipfile size in the callback to .end
. However, I would like to know that size way before adding files, so I can pass it along the pipeline before creating the archive.
Would it be possible to add another API to return the predicted size for a list of inputs whose size is provided?
For example:
yazl.size(
fs.readdirSync("my/folder", { withFileTypes: true }).map(dirEntry => {
return {
...dirEntry,
size: fs.statSync(dirEntry.name).size,
};
}),
{
compress: false,
},
);
Basically, it takes a list of file-like entries, with required name
and size
properties, and returns the final zipfile size.
It's fine to return -1 when the size can't be determined, but when it does (such as the size
option is passed along the stream), the size should be computed. It's nicer that yazl
exposes this number so that the calculation adheres to its method of archiving.