const fs=require('fs');
const path='chat/public/builder.js';
const src=fs.readFileSync(path,'utf8');
let lo=0,hi=src.length,mid;let lastGood=0;
while(lo<hi){mid=Math.floor((lo+hi)/2);
 try{new Function(src.slice(0,mid)); lastGood=mid; lo=mid+1;}catch(e){hi=mid;}
}
const start=Math.max(0,lastGood-200), end=Math.min(src.length, lastGood+200);
const context=src.slice(start,end);
const before=src.slice(0,lastGood);
const linesBefore=before.split('\n').length;
console.log('approx failure at char index', lastGood, 'around line', linesBefore);
console.log('---context---');
console.log(context);
