Skip to content

Commit d7db768

Browse files
committed
refactor: use set instead of array
1 parent 4d1282c commit d7db768

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/license-plugin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ class LicensePlugin {
154154
let dir = path.resolve(path.parse(id).dir);
155155
let pkg = null;
156156

157-
const scannedDirs = [];
157+
const scannedDirs = new Set();
158158

159159
this.debug(`iterative over directory tree, starting with: ${dir}`);
160160

161-
while (dir && dir !== this._cwd && !scannedDirs.includes(dir)) {
161+
while (dir && dir !== this._cwd && !scannedDirs.has(dir)) {
162162
// Try the cache.
163163
if (this._cache.has(dir)) {
164164
pkg = this._cache.get(dir);
@@ -170,7 +170,7 @@ class LicensePlugin {
170170
break;
171171
}
172172

173-
scannedDirs.push(dir);
173+
scannedDirs.add(dir);
174174

175175
this.debug(`looking for package.json file in: ${dir}`);
176176
const pkgPath = path.join(dir, 'package.json');

0 commit comments

Comments
 (0)