目标
对文本做小写化频率统计,取前 20 个字符渲染哈希条形图,条宽随最大计数缩放保证可读。
要点
统计阶段只保留 [a-z0-9];渲染按频次降序、同频按字符序,行尾附精确计数。示例输出以 e ##### 5 开头。
提示
标点与多字节字素簇被有意忽略——这是字母频率分析而非完整 Unicode 文本统计。
验证
node –test 验证大小写折叠与排序;CLI 对全字母句输出频次排序的图表。 复现命令:
node --test histogram.test.mjs
node histogram.mjs input.txt
预期输出要点:For a sample text the CLI prints one line per character with a frequency-sorted bar chart built from hash marks.
实测证据:Node 22.23.2: node –test -> 2 passed; CLI printed a frequency-sorted chart led by e ##### 5 for the pangram sample.