From d7db76807249384d6230372247e5a235123b4c83 Mon Sep 17 00:00:00 2001 From: Mickael Jeanroy Date: Sun, 10 Mar 2024 23:40:05 +0100 Subject: [PATCH] refactor: use set instead of array --- src/license-plugin.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/license-plugin.js b/src/license-plugin.js index 579db9cb..f5d24071 100644 --- a/src/license-plugin.js +++ b/src/license-plugin.js @@ -154,11 +154,11 @@ class LicensePlugin { let dir = path.resolve(path.parse(id).dir); let pkg = null; - const scannedDirs = []; + const scannedDirs = new Set(); this.debug(`iterative over directory tree, starting with: ${dir}`); - while (dir && dir !== this._cwd && !scannedDirs.includes(dir)) { + while (dir && dir !== this._cwd && !scannedDirs.has(dir)) { // Try the cache. if (this._cache.has(dir)) { pkg = this._cache.get(dir); @@ -170,7 +170,7 @@ class LicensePlugin { break; } - scannedDirs.push(dir); + scannedDirs.add(dir); this.debug(`looking for package.json file in: ${dir}`); const pkgPath = path.join(dir, 'package.json');