0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 06:50:43 -05:00

Reduced nesting

This commit is contained in:
Chomp 2025-01-06 15:16:32 +00:00
parent fc7b33cd53
commit 2e4f15d5a8

View File

@ -124,25 +124,25 @@ export class ImporterUtil {
while (filesToProcess.length !== 0) {
const fileNode = filesToProcess.dequeue();
if (!fileNode) continue;
if (this.vfs.getFileExtension(fileNode.fileName) === "json") {
const filePathAndName = `${fileNode.filePath}${fileNode.fileName}`;
promises.push(
this.vfs
.readFileAsync(filePathAndName)
.then(async (fileData) => {
onReadCallback(filePathAndName, fileData);
return this.jsonUtil.deserializeWithCacheCheckAsync<any>(fileData, filePathAndName);
})
.then(async (fileDeserialized) => {
onObjectDeserialized(filePathAndName, fileDeserialized);
const strippedFilePath = this.vfs.stripExtension(filePathAndName).replace(filepath, "");
this.placeObject(fileDeserialized, strippedFilePath, result, strippablePath);
})
.then(() => progressWriter.increment()),
);
if (!fileNode || this.vfs.getFileExtension(fileNode.fileName) !== "json") {
continue;
}
const filePathAndName = `${fileNode.filePath}${fileNode.fileName}`;
promises.push(
this.vfs
.readFileAsync(filePathAndName)
.then(async (fileData) => {
onReadCallback(filePathAndName, fileData);
return this.jsonUtil.deserializeWithCacheCheckAsync<any>(fileData, filePathAndName);
})
.then(async (fileDeserialized) => {
onObjectDeserialized(filePathAndName, fileDeserialized);
const strippedFilePath = this.vfs.stripExtension(filePathAndName).replace(filepath, "");
this.placeObject(fileDeserialized, strippedFilePath, result, strippablePath);
})
.then(() => progressWriter.increment()),
);
}
await Promise.all(promises).catch((e) => console.error(e));