From 0bdd173cba535a9d2e8cb5d93edc9cf1f48bdb86 Mon Sep 17 00:00:00 2001 From: riddhi-b Date: Sun, 8 Dec 2024 10:08:20 -0500 Subject: [PATCH] replaced for loops --- src/app/components/tags-auto/tags.worker.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/app/components/tags-auto/tags.worker.ts b/src/app/components/tags-auto/tags.worker.ts index bdb73916..5ed912f7 100644 --- a/src/app/components/tags-auto/tags.worker.ts +++ b/src/app/components/tags-auto/tags.worker.ts @@ -28,8 +28,7 @@ function getCleanTwoWordMap( const twoWordFreqMap: Map = new Map(); - potentialTwoWordMap.forEach((val: number, key: string) => { - + for (const [key, val] of potentialTwoWordMap.entries()) { if (val > 3) { // set a variable here instead! let newCounter: number = 0; @@ -40,8 +39,7 @@ function getCleanTwoWordMap( } } } - }); - + }; return twoWordFreqMap; } @@ -56,14 +54,14 @@ function getPotentialTwoWordTags( ): Map { const potentialTwoWordMap: Map = new Map(); - oneWordFreqMap.forEach((val: number, key: string) => { + for (const [key, val] of oneWordFreqMap) { findTwoWords( potentialTwoWordMap, key, onlyFileNames, oneWordFreqMap ); - }); + } return potentialTwoWordMap; } @@ -83,14 +81,13 @@ function findTwoWords( onlyFileNames: string[], oneWordFreqMap: Map ): void { - const filesContainingTheSingleWord: string[] = []; - onlyFileNames.forEach((fileName) => { + for (const fileName of onlyFileNames) { if (fileName.includes(singleWord)) { filesContainingTheSingleWord.push(fileName); } - }); + } filesContainingTheSingleWord.forEach((fileName) => {