我正在尝试使用 archive.extractFiles 函数来获取路径和文件。此函数不等待列表数组填充,而是立即返回空数组。
import {Archive} from 'libarchive.js/main.js';
Archive.init({
workerUrl: '/libarchive.js/dist/worker-bundle.js'
});
public async getFileAndPath(fileList) {
const list = [];
console.log(fileList);
const archive = await Archive.open(fileList);
await archive.extractFiles(async entry => {
console.log(entry);
list.push(entry);
});
// console.log(obj);
return list;
}
How to make this function wait inside extractFiles.