diff options
author | Tobias Nießen <tniessen@tnie.de> | 2022-01-28 19:41:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-28 19:41:16 +0300 |
commit | 334fb38435950091a66be7c51f1d50ddc6285bfc (patch) | |
tree | 22145937b2575105854c87e2712f08a569b3c049 /tools | |
parent | f98a785dab1a7f520b0cc8e102771b6c5c24a36e (diff) |
tools: use Set instead of { [key]: true } object
Refs: https://github.com/nodejs/node/pull/41675
PR-URL: https://github.com/nodejs/node/pull/41695
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/doc/alljson.mjs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/tools/doc/alljson.mjs b/tools/doc/alljson.mjs index 88f25bba40a..47b0d6a14da 100644 --- a/tools/doc/alljson.mjs +++ b/tools/doc/alljson.mjs @@ -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}#`) @@ -49,7 +46,7 @@ for (const link of toc.match(/<a.*?>/g)) { } // Mark source as seen. - seen[json] = true; + seen.add(json); } // Write results. |