We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const { zip } = require('compressing'); const fs = require('fs') const zipStream = new zip.Stream(); zipStream.addEntry('test.html') setTimeout(() => { zipStream.addEntry('yarn.lock') setTimeout(() => { zipStream.addEntry('package.json') setTimeout(() => { zipStream.pipe(fs.createWriteStream('test.zip')); }, 3000) }, 3000) }, 3000)
这段代码最终压缩包里只会有test.html ,原因是每次addEntry后都会调用 finalize ,会使依赖的yazl.zipFile 调用end,调用了end后,会使zipFile处理完最后一个文件后如果没有其他Entry就关闭流,导致压缩结束,所以处理完已添加的文件前如果 addEntry 没调用到,流就会关闭,再调用就不起作用, 所以安全起见,addEntry 要一次性同步调完,或者需要异步用yazl
The text was updated successfully, but these errors were encountered:
我使用for循环依次addEntry,每次add的是个流,发现压缩后的文件偶发性的会减少
Sorry, something went wrong.
No branches or pull requests
const { zip } = require('compressing');
const fs = require('fs')
const zipStream = new zip.Stream();
zipStream.addEntry('test.html')
setTimeout(() => {
zipStream.addEntry('yarn.lock')
setTimeout(() => {
zipStream.addEntry('package.json')
setTimeout(() => {
zipStream.pipe(fs.createWriteStream('test.zip'));
}, 3000)
}, 3000)
}, 3000)
这段代码最终压缩包里只会有test.html ,原因是每次addEntry后都会调用 finalize ,会使依赖的yazl.zipFile 调用end,调用了end后,会使zipFile处理完最后一个文件后如果没有其他Entry就关闭流,导致压缩结束,所以处理完已添加的文件前如果 addEntry 没调用到,流就会关闭,再调用就不起作用,
所以安全起见,addEntry 要一次性同步调完,或者需要异步用yazl
The text was updated successfully, but these errors were encountered: