diff options
author | Rich Trott <rtrott@gmail.com> | 2022-01-08 19:46:56 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-09 03:46:56 +0000 |
commit | e2470890574d3d4ccafb8250a1de887351b4e9a6 (patch) | |
tree | 5bae1753a1fd9fd282498945bd17a70385e0150d /tools | |
parent | 154857893149e0a8b9beffce5d96e92b143b6ef3 (diff) | |
download | node-new-e2470890574d3d4ccafb8250a1de887351b4e9a6.tar.gz |
tools: replace while+exec() with matchAll()
PR-URL: https://github.com/nodejs/node/pull/41406
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/doc/allhtml.mjs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/doc/allhtml.mjs b/tools/doc/allhtml.mjs index 13fda2c573..c597bebdbc 100644 --- a/tools/doc/allhtml.mjs +++ b/tools/doc/allhtml.mjs @@ -103,12 +103,13 @@ fs.writeFileSync(new URL('./all.html', source), all, 'utf8'); // Validate all hrefs have a target. const ids = new Set(); const idRe = / id="([^"]+)"/g; -let match; -while (match = idRe.exec(all)) { +const idMatches = all.matchAll(idRe); +for (const match of idMatches) { ids.add(match[1]); } const hrefRe = / href="#([^"]+)"/g; -while (match = hrefRe.exec(all)) { +const hrefMatches = all.matchAll(hrefRe); +for (const match of hrefMatches) { if (!ids.has(match[1])) throw new Error(`link not found: ${match[1]}`); } |