From 2e4f15d5a887a27aa26fefd64a459c0ac530efe8 Mon Sep 17 00:00:00 2001 From: Chomp Date: Mon, 6 Jan 2025 15:16:32 +0000 Subject: [PATCH] Reduced nesting --- project/src/utils/ImporterUtil.ts | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/project/src/utils/ImporterUtil.ts b/project/src/utils/ImporterUtil.ts index 4329bef9..5de75e03 100644 --- a/project/src/utils/ImporterUtil.ts +++ b/project/src/utils/ImporterUtil.ts @@ -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(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(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));