From: Ward Cunningham Date: Fri, 29 Nov 2024 18:10:42 +0000 (-0800) Subject: summarize usage X-Git-Url: https://dreyeck.freedombox.rocks/gitweb/idiomatic.git/commitdiff_plain/1d14f8b4c3061f3bbecbbd2df4c230a9dd1fd985 summarize usage --- diff --git a/index.js b/index.js index b8d5a57..b1a1a24 100644 --- a/index.js +++ b/index.js @@ -75,7 +75,7 @@ app.get('/usage', (req,res) => { const files = counter() const doit = (branch,stack) => { if(branch.type==type && branch[field]==key)list.push(` - + ${stack.at(-1)} ${sxpr(stack[width ?? 2], depth ?? 3)}`) } @@ -89,17 +89,17 @@ app.get('/usage', (req,res) => { const m = id => ` − ` const d = id => `${id} ${p(id)} ${m(id)}` res.send(style('usage',key)+` -

${files.tally().map(([k,v]) => `
${v}${k}`).join("\n")}
+

${files.total()} uses in ${files.size()} files + ${files.tally().map(([k,v]) => `
${v}${k}`).join("\n")}

— ${d('width')} ${d('depth')} —

${list.join("\n")}
`) }) app.get('/nesting', (req,res) => { - const {file,type,start,end} = req.query + const {file,type,key,start,end} = req.query const result = [] const doit = (branch,stack) => { if(stack.at(-1)==file && branch.type==type && branch.start==start && branch.end==end) { - const file = stack.at(-1) const path = stack.slice(0,-1).map((n,i) => ` ${n.type}: @@ -111,7 +111,7 @@ app.get('/nesting', (req,res) => { } } visitor.wander(mods,doit) - res.send(style('nesting')+`${result.join("


")}`) + res.send(style('nesting',key)+`${result.join("
")}`) })