From d6853c28ef355471951354d61359c5d5b3a9c983 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 23 Jul 2026 09:34:16 +0000 Subject: [PATCH] perf: extract function from loop in seo-crawl-audit.mjs Co-authored-by: lsb11 <269203137+lsb11@users.noreply.github.com> --- seo-crawl-audit.mjs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/seo-crawl-audit.mjs b/seo-crawl-audit.mjs index f623e1c..23ae19c 100644 --- a/seo-crawl-audit.mjs +++ b/seo-crawl-audit.mjs @@ -28,6 +28,14 @@ const norm = (href) => { return href; }; +const collectSchemaTypes = (node, acc) => { + if (!node || typeof node !== 'object') return acc; + if (Array.isArray(node)) { node.forEach((n) => collectSchemaTypes(n, acc)); return acc; } + if (node['@type']) acc.push(node['@type']); + Object.values(node).forEach((v) => collectSchemaTypes(v, acc)); + return acc; +}; + for (const f of files) { const rel = '/' + relative(DIST, f).replace(/index\.html$/, '').replace(/\.html$/, '/'); const html = readFileSync(f, 'utf8'); @@ -40,14 +48,7 @@ for (const f of files) { const schemaTypes = [...html.matchAll(/