perf: async read file (#3531)

This commit is contained in:
Archer
2025-01-05 16:57:35 +08:00
committed by archer
parent 2bf1fce32a
commit 2066094047
7 changed files with 61 additions and 53 deletions

View File

@@ -44,13 +44,15 @@ const parsePowerPoint = async ({
}
// Returning an array of all the xml contents read using fs.readFileSync
const xmlContentArray = files.map((file) => {
try {
return fs.readFileSync(`${decompressPath}/${file.path}`, encoding);
} catch (err) {
return fs.readFileSync(`${decompressPath}/${file.path}`, 'utf-8');
}
});
const xmlContentArray = await Promise.all(
files.map((file) => {
try {
return fs.promises.readFile(`${decompressPath}/${file.path}`, encoding);
} catch (err) {
return fs.promises.readFile(`${decompressPath}/${file.path}`, 'utf-8');
}
})
);
let responseArr: string[] = [];