From 86ece9843f496388a409f1636efb189c94c37320 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);