Skip to content

Commit 9d23a27

Browse files
tniessendanielleadams
authored andcommitted
tools: use Set instead of { [key]: true } object
Refs: #41675 PR-URL: #41695 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Mestery <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 7bf2be5 commit 9d23a27

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

tools/doc/alljson.mjs

+3-6
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,14 @@ const results = {
2323

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

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

5148
// Mark source as seen.
52-
seen[json] = true;
49+
seen.add(json);
5350
}
5451

5552
// Write results.

0 commit comments

Comments
 (0)