X-Git-Url: https://dreyeck.freedombox.rocks/gitweb/idiomatic.git/blobdiff_plain/7d3a9854e6d5e13961db099f73efc29cda4d68bb..ef2285e8811ba79f54986e32767aa75a87191f86:/index.js?ds=inline diff --git a/index.js b/index.js index b8d5a57..ff1804c 100644 --- a/index.js +++ b/index.js @@ -37,7 +37,7 @@ app.get('/index', async (req,res,next) => { console.log(new Date().toLocaleTimeString(), 'index') const reductions = counter() const doit = branch => {reductions.count(branch.type)} - visitor.wander(mods,doit) + visitor.walk(mods,doit) const result = `

${reductions.size()} non-terminals
${reductions.total()} reductions @@ -59,7 +59,7 @@ app.get('/terminal', (req,res) => { const {type,field} = req.query const lits = counter() const doit = branch => {if(branch.type==type) lits.count(branch[field])} - visitor.wander(mods,doit) + visitor.walk(mods,doit) const result = style('terminal',type)+`

${lits.size()} uniques
${lits.total()} total @@ -75,11 +75,11 @@ 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)}`) } - visitor.wander(mods,doit) + visitor.walk(mods,doit) const vis = row => row.split(/\n/)[3].trim().replaceAll(/<.*?>/g,'').replaceAll(/\.\.+/g,'..') list.sort((a,b) => vis(a)>vis(b) ? 1 : -1) const q = (id,delta) => Object.entries(req.query) @@ -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}: @@ -110,8 +110,8 @@ app.get('/nesting', (req,res) => {

${escape(JSON.stringify(hit,omit,2))}
`) } } - visitor.wander(mods,doit) - res.send(style('nesting')+`${result.join("
")}`) + visitor.walk(mods,doit) + res.send(style('nesting',key)+`${result.join("
")}`) })