Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: use Set instead of { [key]: true } object #41695

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions tools/doc/alljson.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,14 @@ const results = {

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

// Extract (and concatenate) the selected data from each document.
// Expand hrefs found in json to include source HTML file.
for (const link of toc.match(/<a.*?>/g)) {
const href = /href="(.*?)"/.exec(link)[1];
const json = href.replace('.html', '.json');
if (!jsonFiles.includes(json) || seen[json]) continue;
if (!jsonFiles.includes(json) || seen.has(json)) continue;
const data = JSON.parse(
fs.readFileSync(new URL(`./${json}`, source), 'utf8')
.replace(/<a href=\\"#/g, `<a href=\\"${href}#`)
Expand All @@ -49,7 +46,7 @@ for (const link of toc.match(/<a.*?>/g)) {
}

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

// Write results.
Expand Down