tools: replace for loop with map()

Refs: https://github.com/nodejs/node/pull/41406#discussion_r778979676
Co-authored-by: Tobias Nießen <tniessen@tnie.de>

PR-URL: https://github.com/nodejs/node/pull/41451
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
This commit is contained in:
Rich TrottandTobias Nießen authored and Michaël Zasso committed 2022-01-14 16:22:49 +01:00
1 parent fa84353952
commit ec337b2019
1 file changed
+1 -5
+1 -5
View File
@@ -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);