我使用以下有效的代码
但我想知道 API 何时完成提取 并完成该过程,有没有办法用这个库来完成它? 它基于yauzl
https://www.npmjs.com/package/extract-zip
var extract = require('extract-zip')
extract(source, {dir: target}, function (err) {
// extraction is complete. make sure to handle the err
})
我没有找到该过程完成的任何事件,但也许我错过了一些东西?
最佳答案
该模块不会触发事件。但是,只要解压缩过程完成(或发生错误),就会调用回调函数。这是通知您该过程已完成的唯一方式。您可以将流程完成后需要运行的逻辑放在那里。
var extract = require('extract-zip')
extract(source, {dir: target}, function (err) {
// extraction is complete. make sure to handle the err
// If you are here the process of unzipping is done (or an error occurred)
})
如果你确实想要事件,你可以看看底层的 yauzl
包,因为它广泛使用事件和流。
关于node.js - 解压过程完成的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51472560/