From ec337b20194950be70f7b820b2e6da6cbde40bc4 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 9 Jan 2022 05:32:56 -0800 Subject: [PATCH] tools: replace for loop with map() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: https://github.com/nodejs/node/pull/41406#discussion_r778979676 Co-authored-by: Tobias Nießen PR-URL: https://github.com/nodejs/node/pull/41451 Reviewed-By: Tobias Nießen Reviewed-By: Anna Henningsen Reviewed-By: Anto Aravinth --- tools/doc/allhtml.mjs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tools/doc/allhtml.mjs b/tools/doc/allhtml.mjs index c597bebdbcf99a..3c45b149861a5c 100644 --- a/tools/doc/allhtml.mjs +++ b/tools/doc/allhtml.mjs @@ -101,12 +101,8 @@ all = all.slice(0, apiStart.index + apiStart[0].length) + fs.writeFileSync(new URL('./all.html', source), all, 'utf8'); // Validate all hrefs have a target. -const ids = new Set(); const idRe = / id="([^"]+)"/g; -const idMatches = all.matchAll(idRe); -for (const match of idMatches) { - ids.add(match[1]); -} +const ids = new Set([...all.matchAll(idRe)].map((match) => match[1])); const hrefRe = / href="#([^"]+)"/g; const hrefMatches = all.matchAll(hrefRe);