From 799f8503bee19293f14ffe57f1bdf47e20bb36ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Fri, 28 Jan 2022 17:41:16 +0100 Subject: [PATCH] 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 Reviewed-By: Mestery Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Luigi Pinca --- tools/doc/alljson.mjs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/doc/alljson.mjs b/tools/doc/alljson.mjs index 88f25bba40a149..47b0d6a14dab33 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(//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(//g)) { } // Mark source as seen. - seen[json] = true; + seen.add(json); } // Write results.