Skip to content

Commit

Permalink
tools: use Set instead of { [key]: true } object
Browse files Browse the repository at this point in the history
PR-URL: nodejs#41675
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
tniessen authored and Linkgoron committed Jan 31, 2022
1 parent b08dbe5 commit 791365f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions tools/doc/allhtml.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ let apicontent = '';

// Identify files that should be skipped. As files are processed, they
// are added to this list to prevent dupes.
const seen = {
'all.html': true,
'index.html': true
};
const seen = new Set(['all.html', 'index.html']);

for (const link of toc.match(/<a.*?>/g)) {
const href = /href="(.*?)"/.exec(link)[1];
if (!htmlFiles.includes(href) || seen[href]) continue;
if (!htmlFiles.includes(href) || seen.has(href)) continue;
const data = fs.readFileSync(new URL(`./${href}`, source), 'utf8');

// Split the doc.
Expand Down Expand Up @@ -68,7 +65,7 @@ for (const link of toc.match(/<a.*?>/g)) {
.trim() + '\n';

// Mark source as seen.
seen[href] = true;
seen.add(href);
}

// Replace various mentions of index with all.
Expand Down

0 comments on commit 791365f

Please sign in to comment.