我使用以下有效的代码

但我想知道提取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/

10-11 06:30