Display current song

This commit is contained in:
2026-01-02 19:37:08 +01:00
parent c3f594d102
commit cb01a59051
5 changed files with 312 additions and 32 deletions

11
tools/check_counts.js Normal file
View File

@@ -0,0 +1,11 @@
const fs = require('fs');
const path = 'd:/Sites/Work/RadioCast/src/main.js';
const s = fs.readFileSync(path,'utf8');
const counts = {'(':0,')':0,'{':0,'}','[':0,']':0,'`':0,'"':0,"'":0};
for (const ch of s) { if (counts.hasOwnProperty(ch)) counts[ch]++; }
console.log('counts:', counts);
// Also print last 50 characters and line count
console.log('length:', s.length);
const lines = s.split(/\r?\n/);
console.log('lines:', lines.length);
for (let i = Math.max(0, lines.length-20); i < lines.length; i++) console.log((i+1)+': '+lines[i]);

24
tools/find_unclosed.cjs Normal file
View File

@@ -0,0 +1,24 @@
const fs = require('fs');
const path = 'd:/Sites/Work/RadioCast/src/main.js';
const s = fs.readFileSync(path,'utf8');
const lines = s.split(/\r?\n/);
let balance = 0;
let maxBalance = 0;
let maxLine = -1;
for (let i=0;i<lines.length;i++){
const line = lines[i];
for (const ch of line){
if (ch==='{' ) balance++;
else if (ch==='}') balance--;
}
if (balance>maxBalance){ maxBalance = balance; maxLine = i+1; }
}
console.log('final balance:', balance, 'maxBalance:', maxBalance, 'maxLine:', maxLine);
console.log('last 40 lines:');
for (let i=Math.max(0, lines.length-40); i<lines.length;i++) console.log((i+1)+': '+lines[i]);
// Print context around maxLine
if (maxLine>0){
console.log('\nContext around max imbalance at line', maxLine);
for (let i=Math.max(1, maxLine-5); i<=Math.min(lines.length, maxLine+5); i++) console.log(i+': '+lines[i-1]);
}

24
tools/find_unclosed.js Normal file
View File

@@ -0,0 +1,24 @@
const fs = require('fs');
const path = 'd:/Sites/Work/RadioCast/src/main.js';
const s = fs.readFileSync(path,'utf8');
const lines = s.split(/\r?\n/);
let balance = 0;
let maxBalance = 0;
let maxLine = -1;
for (let i=0;i<lines.length;i++){
const line = lines[i];
for (const ch of line){
if (ch==='{' ) balance++;
else if (ch==='}') balance--;
}
if (balance>maxBalance){ maxBalance = balance; maxLine = i+1; }
}
console.log('final balance:', balance, 'maxBalance:', maxBalance, 'maxLine:', maxLine);
console.log('last 40 lines:');
for (let i=Math.max(0, lines.length-40); i<lines.length;i++) console.log((i+1)+': '+lines[i]);
// Print context around maxLine
if (maxLine>0){
console.log('\nContext around max imbalance at line', maxLine);
for (let i=Math.max(1, maxLine-5); i<=Math.min(lines.length, maxLine+5); i++) console.log(i+': '+lines[i-1]);
}

24
tools/find_unmatched.cjs Normal file
View File

@@ -0,0 +1,24 @@
const fs=require('fs');
const path='d:/Sites/Work/RadioCast/src/main.js';
const s=fs.readFileSync(path,'utf8');
const lines=s.split(/\r?\n/);
const stack=[];
for(let i=0;i<lines.length;i++){
const line=lines[i];
for(let j=0;j<line.length;j++){
const ch=line[j];
if(ch==='{' ) stack.push({line:i+1,col:j+1});
else if(ch==='}'){
if(stack.length>0) stack.pop(); else console.log('Unmatched closing } at',i+1,j+1);
}
}
}
console.log('Unmatched openings left:', stack.length);
if(stack.length>0) console.log('First unmatched opening at', stack[0]);
if(stack.length>0) console.log('Last unmatched opening at', stack[stack.length-1]);
if(stack.length>0){
const sidx=Math.max(1, stack[stack.length-1].line-5);
const eidx=Math.min(lines.length, stack[stack.length-1].line+5);
console.log('\nContext:');
for(let i=sidx;i<=eidx;i++) console.log(i+': '+lines[i-1]);
}