this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 43 lines 2.1 kB view raw
1import { readFileSync } from 'fs'; 2 3const pop = JSON.parse(readFileSync('./data/collector-results/popularityBcdMap.json')); 4const keys = Object.keys(pop); 5 6const prefixes = {}; 7let nullCount = 0; 8let withData = 0; 9for (const k of keys) { 10 if (pop[k] === null || !pop[k].bcd_entries) { nullCount++; continue; } 11 withData++; 12 const bcds = pop[k].bcd_entries.map(e => Object.keys(e)[0]); 13 for (const b of bcds) { 14 const prefix = b.split('.').slice(0, 2).join('.'); 15 prefixes[prefix] = (prefixes[prefix] || 0) + 1; 16 } 17} 18console.log('Total features in map:', keys.length); 19console.log('With popularity data:', withData); 20console.log('Null/missing:', nullCount); 21console.log('\nBCD prefix distribution:'); 22Object.entries(prefixes).sort((a, b) => b[1] - a[1]).forEach(([p, c]) => console.log(' ', p, c)); 23 24// Now classify which BCD prefixes map to HTTP Archive observables 25console.log('\n--- HTTP Archive Mapping Feasibility ---'); 26const mappable = { css_properties: 0, css_atrules: 0, css_selectors: 0, css_types: 0, html_elements: 0, api: 0, js_builtins: 0, other: 0 }; 27for (const k of keys) { 28 if (pop[k] === null || !pop[k].bcd_entries) continue; 29 const bcds = pop[k].bcd_entries.map(e => Object.keys(e)[0]); 30 let mapped = false; 31 for (const b of bcds) { 32 if (b.startsWith('css.properties.')) { mappable.css_properties++; mapped = true; break; } 33 if (b.startsWith('css.at-rules.')) { mappable.css_atrules++; mapped = true; break; } 34 if (b.startsWith('css.selectors.')) { mappable.css_selectors++; mapped = true; break; } 35 if (b.startsWith('css.types.')) { mappable.css_types++; mapped = true; break; } 36 if (b.startsWith('html.elements.')) { mappable.html_elements++; mapped = true; break; } 37 if (b.startsWith('api.')) { mappable.api++; mapped = true; break; } 38 if (b.startsWith('javascript.builtins.')) { mappable.js_builtins++; mapped = true; break; } 39 } 40 if (!mapped) mappable.other++; 41} 42console.log('Features by primary BCD type (mappable to HTTP Archive):'); 43Object.entries(mappable).forEach(([k, v]) => console.log(' ', k, v));